Author Topic: Doing something on GetModule based int  (Read 337 times)

Legacy_The Great Thief

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Doing something on GetModule based int
« on: May 17, 2012, 07:19:29 am »


               I cannot figure out for the life of me why this isn't working.

Situation: I have a room where when you step onto this platform, a bunch of pretty pink electric-like walls surround the entire square. There is a boss, two bodyguards, and seven corpses on the floor. I want this to happen: Player steps into square, player kills the three NPC's, and the seven corpses rise as zombies. When all the seven zombies are dead, the walls will disappear.

Now, I'm attempting to do this with GetModule() to set the global int. For debugging purposes, I set for the three NPC's to say the value of the global int over their heads, and they do indeed count to 3.

The problem: These corpses will not respond to the variable on heartbeat, and I'm probably doing it wrong.

void main()
{
if (GetLocalInt(GetModule(), "bonecaller1") > 2){

   effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    string sCreature = "zombie1";

  object oMonster = CreateObject(OBJECT_TYPE_CREATURE, sCreature, GetLocation(OBJECT_SELF));
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eMind, oMonster);
   SetPlotFlag(OBJECT_SELF, FALSE);
   DestroyObject(OBJECT_SELF, 0.5);
}
}


And... Second question. I'm having trouble finding anything of use via Google/Lexicon for having something happen to multiple objects of the same tag. I have about 30 waypoints with the same tag around the square, and I'd like the generic trigger to spawn walls to all of them at once without having to go into each and every WP to change the tag. Is this possible? 
               
               

               


                     Modifié par The Great Thief, 17 mai 2012 - 06:19 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #1 on: May 17, 2012, 10:18:47 am »


               As far as your first question gos, you lost me. I am kinda sleepy though.

Your second question, to create an object at each waypoint of the same tag, you could do somthing like so:

void main()
{
    int iNth = 0;
    object oWallWP = GetObjectByTag("Tag of wall WP", iNth);
    location lWallWP;

    while (GetIsObjectValid(oWallWP))
    {
        lWallWP = GetLocation(oWallWP);
        CreateObject(OBJECT_TYPE_PLACEABLE, "resref of wall", lWallWP);
        iNth++;
        oWallWP = GetObjectByTag("Tag of wall WP", iNth);
    }
}
               
               

               
            

Legacy_The Great Thief

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #2 on: May 17, 2012, 07:10:24 pm »


               Hm. I'll have to try that. But the first part is more important at the moment. '<img'> So I'll try to clarify.

There was a base script in the standard portion of the placables where you could lay a "zombie corpse", which would spawn a zombie next to it as well as destroy itself to make it seem like a zombie rising.

I edited this script so that the three NPC's, with their OnDeath scripts, add +1 to the
GetModule(), "bonecaller1"
int. I have them speak the string of that int as they die instead of say their normal thing at the moment, and when they all die, they do count to 3.

On the bunch-of-corpses' OnHeartbeat events, I'm trying to get them to acknowledge that the module int "bonecaller1" is 3, and do what they otherwise would with the base script where they spawn a creature as well as destroy the corpse. I get to that part in the tests and they don't respond at all!

EDIT: I got them to spawn. ...But the corpses won't disappear now. '<img'> 
               
               

               


                     Modifié par The Great Thief, 18 mai 2012 - 12:21 .
                     
                  


            

Legacy_The Great Thief

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #3 on: May 18, 2012, 02:27:19 am »


               All right. This is making me crazy. I have one script like this:

void main()
{
  object oCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
  if (GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
  {
   effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
   string sCreature = "Lvl1Zombie";

  object oMonster = CreateObject(OBJECT_TYPE_CREATURE, sCreature, GetLocation(OBJECT_SELF));
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eMind, oMonster);
   SetPlotFlag(OBJECT_SELF, FALSE);
   DestroyObject(OBJECT_SELF, 0.5);
}}

This one works. It makes the zombie rise, it destroys itself after. The problem:

void main()
{

if (GetLocalInt(GetModule(), "bonecaller1") == 3){
object oTarget;
object oSpawn;
location lTarget;

oTarget = OBJECT_SELF;
lTarget = GetLocation(oTarget);
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "lvl1zombie001", lTarget);
oTarget = oSpawn;

SetPlotFlag(OBJECT_SELF, FALSE);
  oTarget = OBJECT_SELF;
  DestroyObject(oTarget, 0.0);

}}

This one does not work. I mean, it spawns the creature just fine, and it even acts as if it's destroyed in the sense that the heartbeat doesn't spawn more than one creature. But the physical being, the placable/corpse, does not disappear. 
               
               

               


                     Modifié par The Great Thief, 18 mai 2012 - 01:27 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #4 on: May 18, 2012, 08:35:55 am »


               Well your script can be shortened up a bit. You had a lot of redundant "oTarget" and un-needed "oSpawn". But the problem might be as simple as keeping a delay in the destroy object. No delay can cause issues occasionally. So maybe something like so:

void main()
{
    if (GetLocalInt(GetModule(), "bonecaller1") == 3)
    {
        location lTarget = GetLocation(OBJECT_SELF);
        CreateObject(OBJECT_TYPE_CREATURE, "lvl1zombie001", lTarget);
        SetPlotFlag(OBJECT_SELF, FALSE);//You probably don't even need this line.
        DestroyObject(OBJECT_SELF, 0.5);//Keep some delay in here.
    }
}
               
               

               


                     Modifié par GhostOfGod, 18 mai 2012 - 07:36 .
                     
                  


            

Legacy_The Great Thief

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #5 on: May 18, 2012, 11:12:37 am »


               I tried that particular timing the first time. '<img'> Then I tried 2.0. Didn't work either way.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #6 on: May 18, 2012, 01:47:13 pm »


               Is the placeable set to static in the toolset?  I believe that's the setting that prevents placeables from being removed by a DestroyObject call.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #7 on: May 18, 2012, 02:12:07 pm »


               I dont think static is the problem, If it was the script would not even run on a static placable.  Static was my first guess also.  
The SetPlotFlag is not needed.  Plot only stops things from being destroued by combat.  It has no effect on destroy object. 
My only guess is that at some point you set the destroyable flag.   try using SetIsDestroyable
               
               

               
            

Legacy_The Great Thief

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Doing something on GetModule based int
« Reply #8 on: May 18, 2012, 11:47:17 pm »


               Well I'm a silly ass. They were all static. '<img'> I didn't know a static object couldn't destroy itself. .. In fact, I wasn't aware it was an option to be neither usable nor static. I thought it was one or the other.

Thanks, that fixed it.