I should start by pointing out that I'm not a scripter, this has been put together initially using the latest version of Lilac Soul's generator and then slowly modified one line at a time.
The Task - spawn "force wall" placeables across the entrances to six cells. These can then be destroyed individually using the lever outside each cell. The spawn script is in a trigger by the level entrance.
My Current Problem - I'm spawning a force wall every time my test toon crosses the trigger. I can only guess at the mayhem if a whole party was to cross it!
I have tried adding a bit that destroys the existing wall before respawning it, I now understand from the Lexicon that it will not work that way.
I have tried adding a local variable when the wall is spawned but that doesn't seem to work either though that is probably due to my own incompetance.
I'm using a "Kill Anything" script of my own devising, it goes in the "onUsed" slot of a lever or switch and will destroy any object whose tag is set as a variable on the switch. (I'll put that code at the end). (I have removed the line that reset the variable). This part works just fine.
Here is my current spawn script -/*
* Script generated by LS Script Generator, v.TK.0
*
* sp_elian_wall_oe
*
* Spawns cell doors (force wall vfx)in Elians_Zoo_Too area
*/
// Put this script OnEnter.
void main()
{
object oTarget;
object oSpawn;
// Get the creature who triggered this event.
object oPC = GetEnteringObject();
// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;
/* // Destroy any Existing Walls.
DestroyObject(GetObjectByTag("elian_wall_1"));
DestroyObject(GetObjectByTag("elian_wall_2"));
DestroyObject(GetObjectByTag("elian_wall_3"));
DestroyObject(GetObjectByTag("elian_wall_4"));
DestroyObject(GetObjectByTag("elian_wall_5"));
DestroyObject(GetObjectByTag("elian_wall_6"));
*/
// Spawn Force Walls.
//if(GetLocalInt(OBJECT_SELF, "Elian_Wall_1_Exists") == TRUE) return;
//SetLocalInt(OBJECT_SELF, "Elian_Wall_1_Exists", TRUE);
oTarget = GetWaypointByTag("WP_Elian_Wall_1");
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_1", GetLocation(oTarget));
//if(GetLocalInt(OBJECT_SELF, "Elian_Wall_2_Exists") == TRUE) return;
//SetLocalInt(OBJECT_SELF, "Elian_Wall_2_Exists", TRUE);
oTarget = GetWaypointByTag("WP_Elian_Wall_2");
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_2", GetLocation(oTarget));
//if(GetLocalInt(OBJECT_SELF, "Elian_Wall_3_Exists") == TRUE) return;
//SetLocalInt(OBJECT_SELF, "Elian_Wall_3_Exists", TRUE);
oTarget = GetWaypointByTag("WP_Elian_Wall_3");
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_3", GetLocation(oTarget));
//if(GetLocalInt(OBJECT_SELF, "Elian_Wall_4_Exists") == TRUE) return;
//SetLocalInt(OBJECT_SELF, "Elian_Wall_4_Exists", TRUE);
oTarget = GetWaypointByTag("WP_Elian_Wall_4");
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_4", GetLocation(oTarget));
//if(GetLocalInt(OBJECT_SELF, "Elian_Wall_5_Exists") == TRUE) return;
//SetLocalInt(OBJECT_SELF, "Elian_Wall_5_Exists", TRUE);
oTarget = GetWaypointByTag("WP_Elian_Wall_5");
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_5", GetLocation(oTarget));
//if(GetLocalInt(OBJECT_SELF, "Elian_Wall_6_Exists") == TRUE) return;
//SetLocalInt(OBJECT_SELF, "Elian_Wall_6_Exists", TRUE);
oTarget = GetWaypointByTag("WP_Elian_Wall_6");
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_6", GetLocation(oTarget));
}
My "Kill_Anything" Script -/* p_kill_object_ou
*
* Destroys an object who’s tag is set as a variable on the switch
*
* 1. Place on a switch "onUsed" event
* 2. Set a string variable "Kill_Tag" to the tag of the item you want to destroy.
* 3. Set a string variable "Switch_Sound" to the sound you want the switch to make.
*/
void main()
{
object oTarget;
effect eVFX = EffectVisualEffect(VFX_IMP_REMOVE_CONDITION);
string sTag = GetLocalString (OBJECT_SELF, "Kill_Tag");
string sSound = GetLocalString (OBJECT_SELF, "Switch_Sound");
// Get the creature who triggered this event.
object oPC = GetLastUsedBy();
// Destroy the object (not fully effective until this script ends).
PlaySound (sSound);
oTarget = GetObjectByTag(sTag);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oTarget);
DestroyObject(oTarget, 1.0);
}
Any assistance would be greatly appreciated.
Modifié par Tyndrel, 23 novembre 2012 - 03:43 .