Author Topic: Spawning and destroying six (and only six) placeables.  (Read 331 times)

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
Spawning and destroying six (and only six) placeables.
« on: November 23, 2012, 03:41:09 pm »


               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.  ':crying:'
               
               

               


                     Modifié par Tyndrel, 23 novembre 2012 - 03:43 .
                     
                  


            

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
Spawning and destroying six (and only six) placeables.
« Reply #1 on: November 23, 2012, 03:51:50 pm »


               I did make all the green bits green but it seems that was a waste of time.  '<img'>
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Spawning and destroying six (and only six) placeables.
« Reply #2 on: November 23, 2012, 04:26:03 pm »


                <pontificating...>

I'd try a sensor before spawn approach; check to see if the forcewall exists.
If it does, don't do anything (doesn't matter how many people cross the trigger how many times).
If it *doesn't*, then we create it.


//if the forcewall doesn't exist, spawn it
   // if it does, then ignore this bit
if (GetObjectByTag("elian_wall_1")==OBJECT_INVALID) { // the Forcewall doesn't exist
  oTarget = GetWaypointByTag("WP_Elian_Wall_1");
  oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall_1", GetLocation(oTarget));
}


edit: Also, give the placeable a more generic resref like "elian_wall" and give it its unique tag when you create it:
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "elian_wall", GetLocation(oTarget), FALSE, "elian_wall_1");
That way you only need the one placeable blueprint for all of your forcewalls.

<...on the value of sensors>
               
               

               


                     Modifié par Rolo Kipp, 23 novembre 2012 - 04:31 .
                     
                  


            

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
Spawning and destroying six (and only six) placeables.
« Reply #3 on: November 23, 2012, 05:27:08 pm »


               Thank you Rolo, you are a genius sir, and only needing a single placeable is the icing on the cake  '<img'>
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Spawning and destroying six (and only six) placeables.
« Reply #4 on: November 23, 2012, 05:39:53 pm »


               <beating the bird...>

If I was a genius I wouldn't have to keep kludging together compartmentalized scripts to get around the TMI limit :-P <grump. that was a compliment>
Yeah. I need something to cheer me up.
Any of that spiked punch left? <yup. no one's touched it...>
Oh, good! *starts chugging* <...since i added the snails>
*spraying punch everywhere* <*raven chuckle* just kidding>
You're a cruel bird, sometimes. <just gotta be me>
Shoulda had some of Tyndrel's cake...

<...to the punch>
               
               

               


                     Modifié par Rolo Kipp, 23 novembre 2012 - 05:40 .