Author Topic: Placeable object HB spawn Problem  (Read 351 times)

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Placeable object HB spawn Problem
« on: May 17, 2014, 02:59:56 pm »


               

Hello Everybody,


 


Here's the script,


 


//Spawns Attackers by the number of attackers that exsist untill

//Bell is destroyed

#include "x0_i0_destroy"

void main()

{

 object oPC = GetFirstPC();

 object oNPCa = GetObjectByTag("RoyalMilitia02");

 object oNPCb = GetObjectByTag("RoyalMilitia03");

 object oNPCc = GetObjectByTag("RoyalMilitia05");

 object oCapt = GetObjectByTag("MilitiaCaptain"); // In another area

 object oSound = GetObjectByTag("AlarmBellGill01");

 object oBell = OBJECT_SELF;

 object oDoor = GetObjectByTag("DrGillMainDk");

 int nType = OBJECT_TYPE_CREATURE;

 string sTemp = "royalmilitia003";

 location lLoc = GetLocation(GetWaypointByTag("WpSpRoyMil"));


 if(GetIsDead(oCapt))

 {

  SoundObjectSetVolume(oSound,0);

  SetPlotFlag(oBell,FALSE);

  DestroyObject(oBell,2.0);

 }

 else

 {

  if(GetLocalInt(oBell,"Intruder")==1) // Int set by doors or other NPCs

  {

   if(GetLocked(oDoor))

   {

    SetLocked(oDoor,FALSE);

    ActionOpenDoor(oDoor);

    DeleteLocalInt(oNPCa,"Waylay");

    DeleteLocalInt(oNPCb,"Waylay");

    DeleteLocalInt(oNPCc,"Waylay");

    DelayCommand(2.0,SoundObjectSetVolume(oSound,127));

   }

   else

   {

    if(CountAllObjectsInAreaByTag("RoyalMilitia04",OBJECT_SELF) < 2)

    {

     // Spawn Attackers

     CreateObject(nType,sTemp,lLoc,FALSE);

    }

   }

  }

  else

  {

   //Do Nothing

  }

 }

}


 


and here's the problem.


I first tested this script without the GetIsDead Condition. Worked Fine.


After, The Bell rings, and the Spawn fires twice and stops working(after the spawns are killed and there corpes are destroyed). Entering the other area and killing oCapt, stops the ringing and destroys the bell.


Ed



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Placeable object HB spawn Problem
« Reply #1 on: May 18, 2014, 03:08:46 am »


               Wow 28 people looked and said, " What an Idiot !".
What did the noob learn today ?
1) CountAllObjectsInAreaByTag, can't be an Area.
2) If you set a creature to leave a lootable corpse, he's still valid.

Problem solved
Thanks to you all for at least giving it a look.
Here's what works,
void main()
{
object oPC = GetFirstPC();
object oNPCa = GetObjectByTag("RoyalMilitia02");
object oNPCb = GetObjectByTag("RoyalMilitia03");
object oNPCc = GetObjectByTag("RoyalMilitia05");
object oCapt = GetObjectByTag("MilitiaCaptain");
object oSound = GetObjectByTag("AlarmBellGill01");
object oBell = OBJECT_SELF;
object oDoor = GetObjectByTag("DrGillMainDk");
object oSpawn = GetNearestObjectByTag("RoyalMilitia04",oPC,2);//spawns 2
object oArea = GetObjectByTag("AirimoreDocksNorth");
int nType = OBJECT_TYPE_CREATURE;
string sTemp = "royalmilitia003";
location lLoc = GetLocation(GetWaypointByTag("WpSpRoyMil"));

if(GetIsDead(oCapt))
{
SoundObjectSetVolume(oSound,0);
SetPlotFlag(oBell,FALSE);
DestroyObject(oBell,2.0);
}
else
{
if(GetLocalInt(oBell,"Intruder")==1)
{
if(GetLocked(oDoor))
{
SetLocked(oDoor,FALSE);
ActionOpenDoor(oDoor);
DeleteLocalInt(oNPCa,"Waylay");
DeleteLocalInt(oNPCb,"Waylay");
DeleteLocalInt(oNPCc,"Waylay");
DelayCommand(2.0,SoundObjectSetVolume(oSound,127));
}
else
{
if(GetIsObjectValid(oSpawn))
{
//Do Nothing
}
else
{
if(GetArea(oPC) == oArea)//if the pc leaves the area a large group of angry people forms
{
// Spawn Attackers
CreateObject(nType,sTemp,lLoc,FALSE);
}
}
}
}
else
{
//Do Nothing
}
}
}
               
               

               
            

Legacy_Vincent07

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
Placeable object HB spawn Problem
« Reply #2 on: May 18, 2014, 09:12:19 pm »


               

This sort of thing reminds me of the old Gauntlet type monster spawners.


 


Here: http://nwvault.ign.c...pts.Detail&id=3


 


Simpler one here: http://nwvault.ign.c....Detail&id=2277



               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Placeable object HB spawn Problem
« Reply #3 on: May 19, 2014, 09:58:48 pm »


               

If you run into problems with this down the road, it's probably also worth mentioning that spawned-in placeable heartbeats are very low priority. If you're not spawning them in, fine, but it is probably still worth it in terms of efficiency to do everything from a single loop in either each area or the module as a whole, using GetObjectByTag to find the spawners.


 


Funky



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Placeable object HB spawn Problem
« Reply #4 on: May 25, 2014, 03:46:45 am »


               

FunkySwerve,


Thank you. I have a few placeable HB scripts, Spawn populations,run the city lights,ect. I try to be careful about overusing them, due to all the warnings I've read in many threads. Luckily I work on an older desktop(XP, Pentium4) soo as long as It dosen't lag on my computer, I figure I'm alright. I try to keep the scripts simple and have them returning FALSE untill I need them. Thanks again.


Ed