I figured out the script for creating creatures and spawning them in areas but how do I remove a creature that is already in the area? Thanks.
Destroy creature
Débuté par
Arius23
, mars 28 2010 04:28
#1
Posté 28 mars 2010 - 04:28
#2
Posté 28 mars 2010 - 10:54
You need to get a reference to the object (so, for example, use GetObjectByTag if you know the tag) and then you destroy it (Georg says we must use Safe_Destroy_Object in the core_h library) .
Note that Safe_Destroy_Object prevents you from destroying party members and creatures flaged as plot or immortal. If you are wanting to do this then you will have to address those "issues" or (I suspect) use DestroyObject.
Note that Safe_Destroy_Object prevents you from destroying party members and creatures flaged as plot or immortal. If you are wanting to do this then you will have to address those "issues" or (I suspect) use DestroyObject.
Modifié par Sunjammer, 28 mars 2010 - 10:56 .
#3
Posté 28 mars 2010 - 04:05
I'm a scripting noob, can you give me an example using that script of simply remove a creature from an area?
#4
Posté 28 mars 2010 - 04:29
A lot will depend on what event you are running it from and what triggers the event. I'm going to assume you're using this to set up an area so I'm using one of the "area load" events but it could just as easily be run from a trigger or a useable placeable or, well, pretty much anything.
#include "core_h"
#include "utility_h"
#include "wrappers_h"
void main()
{
int bEventHandled;
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
switch(nEventType)
{
//
// (other events here)
//
case EVENT_TYPE_AREALOAD_POSTLOADEXIT:
{
object oTarget = GetObjectByTag("tag_of_creature_goes_here");
if(IsObjectValid(oTarget))
{
// NOTE: fails for party members and creatures flagged as plot or immortal
Safe_Destroy_Object(oTarget);
}
break;
}
//
// (other events here)
//
}
if (!bEventHandled)
{
HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
}
}
#5
Posté 28 mars 2010 - 08:06
it happens after a cutscene, but i figured it out thanks to the code you provided. thanks!
#6
Posté 29 mars 2010 - 04:50
You can also set a creature innactive, instead of destroying it. If there's any chance you mihgt want to bring the creatures back later, I would use this aproach. Use WR_SetObjectActive(oTarget, FALSE) instead of the safe destroy object call.





Retour en haut






