Author Topic: Spawn Spider Cocoon Script Not Working  (Read 376 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« on: March 16, 2013, 01:58:41 am »


               Hello all...

I have a script designed to destroy and then spawn spider cocoons whenever the PC enters the area, spider-infested tunnels. basically, the script is supposed to destroy all cocoons and then make 10 separate d100 rolls and on success, spawn cocoons at specific waypoints. I am a scripting neophyte and could use some help. Why is my script (below) not working? I created it using LS's Script Generator and then modified it. Obviously, I am not doing something right. Thanks in advance!

/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625    */

//Modified by Paul Postel
//Modified on 03/15/13

//Objective:
//Keep spider-infested area full of spider cocoons, even if PC has destroyed some or all
//Spider encounters regenerate so area will always have spiders; this script is to make sure there are always cocoons
//When the PC enters the area the script destroys all spider cocoons in the area
//The script will then make ten separate d100 rolls; three set to succeed at 50% while three will be set at 100%
//      so there will always be cocoons somewhere in the area
//Success means spider cocoons will be spawned at specific waypoints
//The end result is that the area will be populated with cocoons ranging from 30 to 60 in number


//Put this script OnEnter of the area


void main()
{
   // Get the creature who triggered this event.
   object oPC = GetEnteringObject();

   // Only fire for (real) PCs.
   if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )
       return;

//Destroy all cocoons in this area
object oTarget;
oTarget = GetObjectByTag("SpiderwebCocoon");

DestroyObject(oTarget, 0.0);

//Roll d100
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint A
object oSpawn;
location lTarget;
oTarget = GetWaypointByTag("SC_SpawnCocoonA");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>0) //This could be coded without the d100 roll but leaving in in case we want to change later
  return;

//If successful, spawn cocoon at waypoint B
oTarget = GetWaypointByTag("SC_SpawnCocoonB");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint C
oTarget = GetWaypointByTag("SC_SpawnCocoonC");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint D
oTarget = GetWaypointByTag("SC_SpawnCocoonD");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint E
oTarget = GetWaypointByTag("SC_SpawnCocoonE");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
  return;

//If successful, spawn cocoon at waypoint F
oTarget = GetWaypointByTag("SC_SpawnCocoonF");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
  return;

//If successful, spawn cocoon at waypoint G
oTarget = GetWaypointByTag("SC_SpawnCocoonG");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint H
oTarget = GetWaypointByTag("SC_SpawnCocoonH");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint I
oTarget = GetWaypointByTag("SC_SpawnCocoonI");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
  return;

//If successful, spawn cocoon at waypoint J
oTarget = GetWaypointByTag("SC_SpawnCocoonJ");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #1 on: March 16, 2013, 08:10:01 am »


               Any time you put a "return;" in there, you are telling the script to end. So if you put a return after an "if" and if that condtion is met, the script will end. So instead put code inside curly brackets( { } ) for those "ifs". If the condition is met, that part of the script will run. If the condition is not met, it won't. You also needed a loop to destroy all the cocoons (The loop I put in assumes that this cave is the only area in your mod that has the "SpiderwebCocoon" tag. If you are using objects with that tag elsewhere then the loop will need to be changed.). As it was you were only destroying one. I changed some of the "ifs" to show you but not all of them.


/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625 */

//Modified by Paul Postel
//Modified on 03/15/13

//Objective:
//Keep spider-infested area full of spider cocoons, even if PC has destroyed some or all
//Spider encounters regenerate so area will always have spiders; this script is to make sure there are always cocoons
//When the PC enters the area the script destroys all spider cocoons in the area
//The script will then make ten separate d100 rolls; three set to succeed at 50% while three will be set at 100%
// so there will always be cocoons somewhere in the area
//Success means spider cocoons will be spawned at specific waypoints
//The end result is that the area will be populated with cocoons ranging from 30 to 60 in number


//Put this script OnEnter of the area


void main()
{
    // Get the creature who triggered this event.
    object oPC = GetEnteringObject();

    // Only fire for (real) PCs.
    if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
    return;

    object oTarget;
    object oSpawn;
    location lTarget;
    int iNth = 0;

    //Destroy all cocoons in this area
    oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
    //loop to get all cocoons
    while (GetIsObjectValid(oTarget))
    {
        DestroyObject(oTarget, 0.0);
        iNth++;
        oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
    }

    //Roll d100
    if (d100()>50)
    {

        //If successful, spawn cocoon at waypoint A
       
        oTarget = GetWaypointByTag("SC_SpawnCocoonA");

        lTarget = GetLocation(oTarget);

        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
    }

    //Move on to the nexdt d100 roll
    if (d100()>0) //This could be coded without the d100 roll but leaving in in case we want to change later
    {
        //If successful, spawn cocoon at waypoint B
        oTarget = GetWaypointByTag("SC_SpawnCocoonB");

        lTarget = GetLocation(oTarget);

        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
    }

    //Move on to the nexdt d100 roll
    if (d100()>50)
    {

        //If successful, spawn cocoon at waypoint C
        oTarget = GetWaypointByTag("SC_SpawnCocoonC");

        lTarget = GetLocation(oTarget);

        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
    }

    //Move on to the nexdt d100 roll
    if (d100()>50)
    {
        //If successful, spawn cocoon at waypoint D
        oTarget = GetWaypointByTag("SC_SpawnCocoonD");

        lTarget = GetLocation(oTarget);

        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
    }

    //Move on to the nexdt d100 roll
    if (d100()>50)
    {

        //If successful, spawn cocoon at waypoint E
        oTarget = GetWaypointByTag("SC_SpawnCocoonE");

        lTarget = GetLocation(oTarget);

        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
    }

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
return;

//If successful, spawn cocoon at waypoint F
oTarget = GetWaypointByTag("SC_SpawnCocoonF");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
return;

//If successful, spawn cocoon at waypoint G
oTarget = GetWaypointByTag("SC_SpawnCocoonG");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
return;

//If successful, spawn cocoon at waypoint H
oTarget = GetWaypointByTag("SC_SpawnCocoonH");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
return;

//If successful, spawn cocoon at waypoint I
oTarget = GetWaypointByTag("SC_SpawnCocoonI");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//Move on to the nexdt d100 roll
if (d100()>50)
return;

//If successful, spawn cocoon at waypoint J
oTarget = GetWaypointByTag("SC_SpawnCocoonJ");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

}
               
               

               


                     Modifié par GhostOfGod, 16 mars 2013 - 08:23 .
                     
                  


            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #2 on: March 16, 2013, 12:40:42 pm »


               Thanks GoG. I should have known I would need a loop to destroy all of the cocoons (yes, they only needed to be destroyed in this area). I've seen other scripts with loops. I did not know, however, that I needed to separate the die rolls with curly brackets. Thanks for the help. I'll correct the rest of the script and try it out.

Thanks again!
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #3 on: March 16, 2013, 03:11:20 pm »


               I should send you my king weaver script.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #4 on: March 17, 2013, 02:49:23 am »


               Okay, I replaced all of the returns with the curly brackets and tested the area. It is still not spawning any cocoons. I also checked to make sure the script was in the OnEnter of the area properties...it is.

GoG, do you mind taking another look and see if I missed anything?

Thanks...here it is..

/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625 */

//Modified by Paul Postel
//Modified on 03/15/13
//Modified with help from GhostofGod, from Bioware Social Forums
//Modified on 03/16/13
//Added loop to destroy all cocoons
//Removed returns; (they were ending the script) and placed curly brackets to separate die rolls so
//  each roll would occur

//Objective:
//Keep spider-infested area full of spider cocoons, even if PC has destroyed some or all
//Spider encounters regenerate so area will always have spiders; this script is to make sure there are always cocoons
//When the PC enters the area the script destroys all spider cocoons in the area
//The script will then make ten separate d100 rolls; three set to succeed at 50% while three will be set at 100%
// so there will always be cocoons somewhere in the area
//Success means spider cocoons will be spawned at specific waypoints
//The end result is that the area will be populated with cocoons ranging from 30 to 60 in number


//Put this script OnEnter of the area


void main()
{
   // Get the creature who triggered this event.
   object oPC = GetEnteringObject();

   // Only fire for (real) PCs.
   if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
   return;

   object oTarget;
   object oSpawn;
   location lTarget;
   int iNth = 0;

   //Destroy all cocoons in this area
   oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
   //loop to get all cocoons
   while (GetIsObjectValid(oTarget))
   {
       DestroyObject(oTarget, 0.0);
       iNth++;
       oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
   }

   //Roll d100
   if (d100()>50)
   {

       //If successful, spawn cocoon at waypoint A

       oTarget = GetWaypointByTag("SC_SpawnCocoonA");

       lTarget = GetLocation(oTarget);

       oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
   }

   //Move on to the nexdt d100 roll
   if (d100()>0) //This could be coded without the d100 roll but leaving in in case we want to change later
   {
       //If successful, spawn cocoon at waypoint B
       oTarget = GetWaypointByTag("SC_SpawnCocoonB");

       lTarget = GetLocation(oTarget);

       oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
   }

   //Move on to the nexdt d100 roll
   if (d100()>50)
   {

       //If successful, spawn cocoon at waypoint C
       oTarget = GetWaypointByTag("SC_SpawnCocoonC");

       lTarget = GetLocation(oTarget);

       oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
   }

   //Move on to the nexdt d100 roll
   if (d100()>50)
   {
       //If successful, spawn cocoon at waypoint D
       oTarget = GetWaypointByTag("SC_SpawnCocoonD");

       lTarget = GetLocation(oTarget);

       oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
   }

   //Move on to the nexdt d100 roll
   if (d100()>50)
   {

       //If successful, spawn cocoon at waypoint E
       oTarget = GetWaypointByTag("SC_SpawnCocoonE");

       lTarget = GetLocation(oTarget);

       oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
   }

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
{

//If successful, spawn cocoon at waypoint F
oTarget = GetWaypointByTag("SC_SpawnCocoonF");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
{

//If successful, spawn cocoon at waypoint G
oTarget = GetWaypointByTag("SC_SpawnCocoonG");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint H
oTarget = GetWaypointByTag("SC_SpawnCocoonH");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint I
oTarget = GetWaypointByTag("SC_SpawnCocoonI");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint J
oTarget = GetWaypointByTag("SC_SpawnCocoonJ");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

}
}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #5 on: March 17, 2013, 06:08:17 am »


               At least some of the cocoons should be spawning if everything is spelled correctly. Try some debug lines in there and see what it does. I added a few as an example (highlighted green).


/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625 */

//Modified by Paul Postel
//Modified on 03/15/13
//Modified with help from GhostofGod, from Bioware Social Forums
//Modified on 03/16/13
//Added loop to destroy all cocoons
//Removed returns; (they were ending the script) and placed curly brackets to separate die rolls so
// each roll would occur

//Objective:
//Keep spider-infested area full of spider cocoons, even if PC has destroyed some or all
//Spider encounters regenerate so area will always have spiders; this script is to make sure there are always cocoons
//When the PC enters the area the script destroys all spider cocoons in the area
//The script will then make ten separate d100 rolls; three set to succeed at 50% while three will be set at 100%
// so there will always be cocoons somewhere in the area
//Success means spider cocoons will be spawned at specific waypoints
//The end result is that the area will be populated with cocoons ranging from 30 to 60 in number


//Put this script OnEnter of the area


void main()
{
// Get the creature who triggered this event.
object oPC = GetEnteringObject();

// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;

//debug line
SendMessageToPC(oPC, "Passed first test: Real PC");

object oTarget;
object oSpawn;
location lTarget;
int iNth = 0;

//Destroy all cocoons in this area
oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
//loop to get all cocoons
while (GetIsObjectValid(oTarget))
{
DestroyObject(oTarget, 0.0);
iNth++;
oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
}

//Roll d100
if (d100()>50)
{

//If successful, spawn cocoon at waypoint A

oTarget = GetWaypointByTag("SC_SpawnCocoonA");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//debug line
SendMessageToPC(oPC, "Cocoon at waypoint SC_SpawnCocoonA has spawned. If not, spelling of waypoint tag or cocoon res ref is not correct.");

}

//Move on to the nexdt d100 roll
if (d100()>0) //This could be coded without the d100 roll but leaving in in case we want to change later
{
//If successful, spawn cocoon at waypoint B
oTarget = GetWaypointByTag("SC_SpawnCocoonB");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//debug line
SendMessageToPC(oPC, "Cocoon at waypoint SC_SpawnCocoonB has spawned. If not, spelling of waypoint tag or cocoon res ref is not correct.");
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint C
oTarget = GetWaypointByTag("SC_SpawnCocoonC");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

//debug line
SendMessageToPC(oPC, "Cocoon at waypoint SC_SpawnCocoonC has spawned. If not, spelling of waypoint tag or cocoon res ref is not correct.");
}

//Move on to the nexdt d100 roll
if (d100()>50)
{
//If successful, spawn cocoon at waypoint D
oTarget = GetWaypointByTag("SC_SpawnCocoonD");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint E
oTarget = GetWaypointByTag("SC_SpawnCocoonE");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
{

//If successful, spawn cocoon at waypoint F
oTarget = GetWaypointByTag("SC_SpawnCocoonF");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>0)//This could be coded without the d100 roll but leaving in in case we want to change later
{

//If successful, spawn cocoon at waypoint G
oTarget = GetWaypointByTag("SC_SpawnCocoonG");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint H
oTarget = GetWaypointByTag("SC_SpawnCocoonH");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint I
oTarget = GetWaypointByTag("SC_SpawnCocoonI");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);
}

//Move on to the nexdt d100 roll
if (d100()>50)
{

//If successful, spawn cocoon at waypoint J
oTarget = GetWaypointByTag("SC_SpawnCocoonJ");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", lTarget);

}
}
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #6 on: March 17, 2013, 01:59:02 pm »


               If waypoints in other areas have the same name, that could also be causing a problem.  If the waypoints are not unique, then you need to use getnearest...
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #7 on: March 17, 2013, 10:17:41 pm »


               Check this out...I decided to eliminate the d100 rolls. It occurred to me that the objective is to make sure that there are always cocoons in the area. I changed the script to simply spawn in cocoons at the waypoints. I kept the different waypoints because I didn't feel like going back and changing them all to one tag but I will if I have to. I kept GoG's script to go through the loop and destroy all of the cocoons. However, my script is still not spawning cocoons. I'm pretty sure I am not declaring something right but cannot figure out what. See below....thanks in advance for the help!

/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625 */

//Modified by Paul Postel
//Modified on 03/15/13
//Modified with help from GhostofGod, from Bioware Social Forums

//Modified on 03/16/13:
// Added loop to destroy all cocoons
// Removed returns; (they were ending the script) and placed curly brackets to separate die rolls so
//  each roll would occur

//Modified on 03/17/13:
// Removed d100 die rolls to make script more in line with the objective
// Now there will always be 60 cocoons in the area, no matter how many the PC has destroyed

//Objective:
//Keep spider-infested area full of spider cocoons, even if PC has destroyed some or all
//Spider encounters regenerate so area will always have spiders; this script is to make sure there are always cocoons
//When the PC enters the area the script destroys all spider cocoons in the area
//The script will then spawn cocoons at 60 waypoints

//Put this script OnEnter of the area


void main()
{
   // Get the creature who triggered this event.
   object oPC = GetEnteringObject();

   // Only fire for (real) PCs.
   if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
   return;

   object oTarget;
   object oSpawn;
   int iNth = 0;

   //Destroy all cocoons in this area
   oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
   //loop to get all cocoons
   while (GetIsObjectValid(oTarget))
   {
       DestroyObject(oTarget, 0.0);
       iNth++;
       oTarget = GetObjectByTag("SpiderwebCocoon", iNth);
   }

   // Spawn some placeables.

   oTarget = GetWaypointByTag("SC_SpawnCocoonA");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonB");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonC");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonD");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonE");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonF");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonG");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonH");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonI");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

   oTarget = GetWaypointByTag("SC_SpawnCocoonJ");
   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "spdcocoon001", GetLocation(oTarget));

  }
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #8 on: March 17, 2013, 11:52:37 pm »


               It works perfectly.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #9 on: March 18, 2013, 12:19:40 am »


               ffbj, did you try out the script? If so, it worked for you?
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #10 on: March 18, 2013, 12:51:27 am »


               Yes I put it in a module, my test module. Placed some spider cocoons, which were destroyed on enter of the trigger, which at the same time spawned all the other cocoons at the desinated waypoints.
Things to check:
1. Make sure the resref of the created placeable is correct.
2. Check the case of the wp's and make sure they are correct.
3. Make sure you have all the wp's as unique. You can't have other wp with the same name in other areas.
If you want I can upload the test module I did onto the vault.
               
               

               


                     Modifié par ffbj, 18 mars 2013 - 12:55 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #11 on: March 18, 2013, 01:23:09 am »


               perhaps it is time to do away with the waypoints and just use the OnDeath  event.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #12 on: March 21, 2013, 12:57:13 pm »


               I wanted to let you all know that I have solved this issue. I divided the script between an OnEnter script and an OnExit script. Now when the PC enters the area the cocoons are spawned, and when they leave they are destroyed. It works perfectly.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Spawn Spider Cocoon Script Not Working
« Reply #13 on: March 21, 2013, 08:37:23 pm »


               Cool good idea.  You might like this:

//place on the onenter of a trigger around a light source, a torch for instance. Usually a 4-5 meter box. .
//make the torch or light no ambient glow and deactivated.
//Make the tag of the torch LightSource
//ffbj lightsourceon
void main()
{
object oPC=GetEnteringObject();
if (GetIsDay())
return;
if (!GetIsPC(oPC))
return;
object oTorch=GetNearestObjectByTag("LightSource", oPC);
if (GetLocalInt(oTorch, "On")== 1)
return;
  {
  effect eLightY = EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_20);
  AssignCommand(oTorch, ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
  ApplyEffectToObject( DURATION_TYPE_PERMANENT,eLightY, oTorch);
  SetPlaceableIllumination(oTorch, TRUE);
  SetLocalInt(oTorch, "On", 1);
  SetLocalInt(oPC,"Lighter", 1);
  RecomputeStaticLighting(GetArea(oTorch));
  }

}


//place on the onexit of a trigger around a light source, a torch for instance. Usually a 4-5 meter box. .
//make the torch or light no ambient glow and deactivated.
//Make the tag of the torch LightSource
//ffbj lightsourceoff
void main()
{
object oPC=GetExitingObject();

if (!GetIsPC(oPC)) return;

  object oTorch = GetNearestObjectByTag("LightSource", oPC);
  if ((GetLocalInt(oPC,"Lighter") != 1) && (GetLocalInt(oTorch,"On")!=1))
  return;
  AssignCommand(oTorch, ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
  SetPlaceableIllumination(oTorch, FALSE);
  RecomputeStaticLighting(GetArea(oTorch));
  DeleteLocalInt(oTorch, "On");
 effect eLightEffect = GetFirstEffect(oTorch);
   //Search for negative effects
   while(GetIsEffectValid(eLightEffect))

   {
       if (GetEffectType(eLightEffect) ==  EFFECT_TYPE_VISUALEFFECT)

           {
           RemoveEffect(oTorch, eLightEffect);
           }
       eLightEffect = GetNextEffect(oTorch);
   }
}