#include "events_h"
#include "global_objects_h"
#include "utility_h"
#include "wrappers_h"
void main ()
{
string sTag = GetTag(OBJECT_SELF); // who am I
// object oTarget = GetObjectByTag("wp_" + sTag + "_home");// where is my home waypoint (no longer needed)
location lTarget = Rubber_GetHome(OBJECT_SELF); // Where is my home rubberband location
event ev = GetCurrentEvent(); // What event has just be noticed
int nEventType = GetEventType(ev); // What tupe of event was noticed
int bEventHandled = FALSE;
switch (nEventType)
{
case EVENT_TYPE_DEATH:
{
// How do I get it so that this will not happen until (x) amount of time after the death of the creature calling it???
if (sTag == "woods_orge")
{
// spawn another Wood Orge at the location stored in my Rubberband Home
object oDarkSpawn = CreateObject(OBJECT_TYPE_CREATURE,R"woods_orge.utc", lTarget);
}
else if (sTag == "my_skeleton_archer")
{
// spawn another Skeleton Archer at the location stored in my Rubberband Home
object oDarkSpawn = CreateObject(OBJECT_TYPE_CREATURE,R"my_skeleton_archer.utc", lTarget);
}
}
break;
}
if (!bEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
}
How can I get this to delay creating the creature?
Débuté par
Adarkin
, janv. 30 2010 10:04
#1
Posté 30 janvier 2010 - 10:04
How can I get this to delay for x amount of time before it spawns the next creature. I have next to no scripting experience and pretty surprise I got this far! I have tried CommandWait, but that seems to be geared more toward delaying commands like CommandAttack and thus does nothing to this code. Any help would be greatly appreciated
#2
Posté 31 janvier 2010 - 10:13
Create a custom event, and signal that using DelayEvent(). Do the spawning in that custom event instead.
#3
Posté 02 février 2010 - 04:20
Here's what the code might look like. One thing that might happen with this is the creature might get destroyed on death, so the delayed event might not work, particularly if you go for a long delay. If you're having problems, you could try signaling the delayed event to the area, and putting the handling for it in the area script.
update: I've changed the code slightly to store the tag on the event. This isn't neccessary here, but if the event does get passed to the area instead, that information will have to be passes somehow and this is one way.
#include "events_h"
#include "global_objects_h"
#include "utility_h"
#include "wrappers_h"
const int EVENT_TYPE_LOCAL_DELAY_SPAWN = EVENT_TYPE_CUSTOM_EVENT_01;
void main ()
{
string sTag = GetTag(OBJECT_SELF); // who am I
// object oTarget = GetObjectByTag("wp_" + sTag + "_home");// where is my home waypoint (no longer needed)
location lTarget = Rubber_GetHome(OBJECT_SELF); // Where is my home rubberband location
event ev = GetCurrentEvent(); // What event has just be noticed
int nEventType = GetEventType(ev); // What tupe of event was noticed
int bEventHandled = FALSE;
switch (nEventType)
{
case EVENT_TYPE_DEATH:
{
event eSpawn = Event(EVENT_TYPE_LOCAL_DELAY_SPAWN);
eSpawn = SetEventString(eSpawn, 0, sTag);
DelayEvent(2.0, OBJECT_SELF, eSpawn);
}
break;
case EVENT_TYPE_LOCAL_DELAY_SPAWN:
{
string sSpawnTag = GetEventString(eSpawn, 0);
if (sTSpawnag == "woods_orge")
{
// spawn another Wood Orge at the location stored in my Rubberband Home
object oDarkSpawn = CreateObject(OBJECT_TYPE_CREATURE,R"woods_orge.utc", lTarget);
}
else if (sSpawnTag == "my_skeleton_archer")
{
// spawn another Skeleton Archer at the location stored in my Rubberband Home
object oDarkSpawn = CreateObject(OBJECT_TYPE_CREATURE,R"my_skeleton_archer.utc", lTarget);
}
}
break;
}
if (!bEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
}
update: I've changed the code slightly to store the tag on the event. This isn't neccessary here, but if the event does get passed to the area instead, that information will have to be passes somehow and this is one way.
#include "events_h"
#include "global_objects_h"
#include "utility_h"
#include "wrappers_h"
const int EVENT_TYPE_LOCAL_DELAY_SPAWN = EVENT_TYPE_CUSTOM_EVENT_01;
void main ()
{
string sTag = GetTag(OBJECT_SELF); // who am I
// object oTarget = GetObjectByTag("wp_" + sTag + "_home");// where is my home waypoint (no longer needed)
location lTarget = Rubber_GetHome(OBJECT_SELF); // Where is my home rubberband location
event ev = GetCurrentEvent(); // What event has just be noticed
int nEventType = GetEventType(ev); // What tupe of event was noticed
int bEventHandled = FALSE;
switch (nEventType)
{
case EVENT_TYPE_DEATH:
{
event eSpawn = Event(EVENT_TYPE_LOCAL_DELAY_SPAWN);
eSpawn = SetEventString(eSpawn, 0, sTag);
DelayEvent(2.0, OBJECT_SELF, eSpawn);
}
break;
case EVENT_TYPE_LOCAL_DELAY_SPAWN:
{
string sSpawnTag = GetEventString(eSpawn, 0);
if (sTSpawnag == "woods_orge")
{
// spawn another Wood Orge at the location stored in my Rubberband Home
object oDarkSpawn = CreateObject(OBJECT_TYPE_CREATURE,R"woods_orge.utc", lTarget);
}
else if (sSpawnTag == "my_skeleton_archer")
{
// spawn another Skeleton Archer at the location stored in my Rubberband Home
object oDarkSpawn = CreateObject(OBJECT_TYPE_CREATURE,R"my_skeleton_archer.utc", lTarget);
}
}
break;
}
if (!bEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
}
Modifié par DavidSims, 02 février 2010 - 04:24 .





Retour en haut






