Author Topic: Respawning Placeables Bugs  (Read 437 times)

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Respawning Placeables Bugs
« on: May 08, 2012, 09:43:53 pm »


               Overview: We have a few areas on our module that have bashable placeable objects that have a 50% chance to spawn monsters at  the killer's location. These placeables were recently modified by me to respawn after a 20 minute timer to offer persitance to these areas.

Issue: I have recently encountered odd behavior with this script which will respawn TWO placeables at the location instead of one, which will cause them to be undestroyable by melee or spells (only noticed with Webs so far). I have chalked this up to the location being invalid, by that space being occupied at the time of destruction, most noticably by a large creature size such as Dragon or Earth Elemental. Now before I go and make any changes I would like to ask you guys what would explain these double respawns? And do you have any better ways or more refined code to produce more accurate results?


void RespawnObject(string sTag, int iType, location lLoc)
{

 string sResRef = GetStringLowerCase(GetStringLeft(sTag, 16));

 CreateObject(iType, sResRef, lLoc);
}

void main()
{

//Modified by SKIPPNUTTZ 04-23-12
//Placeable Objects now respawn after 20 minutes

  string sTag = GetTag(OBJECT_SELF);
  int iType = GetObjectType(OBJECT_SELF);
  float fDelay = 1200.0; //Default: 1200.0 (20 minutes)

  //get the location of the placeable object
  location lLoc = GetLocation(OBJECT_SELF);

  //respawn the placeable object after 20 minutes
  AssignCommand(GetArea(OBJECT_SELF), DelayCommand(fDelay, RespawnObject(sTag, iType, lLoc)));

  //get the location of the killer(PC)
  location lPC = GetLocation(GetLastKiller());

  //call the creature string from variables list of placeable
  string sCreatureToSpawn = GetLocalString(OBJECT_SELF, "sCreatureToSpawn");

  //randomize the spawn chance somewhat
  int iSpawnExp = d4(1);
  if (iSpawnExp < 3)
  {
    //spawn 5 sCreatureToSpawn(s) at the player's location
    int i;
    int j = 5;
    for (i = 0; i < j; i++)
    {
      object oSpawn = CreateObject(OBJECT_TYPE_CREATURE, sCreatureToSpawn, lPC, FALSE, "");
    }
  }
}

Thanks.
               
               

               


                     Modifié par SKIPPNUTTZ, 08 mai 2012 - 09:08 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #1 on: May 08, 2012, 11:27:18 pm »


               

//respawn the placeable object after 20 minutes
 AssignCommand(GetArea(OBJECT_SELF), DelayCommand(fDelay, RespawnObject(sTag, iType, lLoc)));

Out of curiosity, why are you passing the tag into that, instead of passing in the ResRef directly?
               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #2 on: May 09, 2012, 12:00:05 am »


               Lol. Very good point. Not that it matters in this case.
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #3 on: May 09, 2012, 12:01:16 am »


               I had a similiar issue last year myself. It was because I had both a script in the OnOpen and OnDeath Events that would recreate the placeable. I ended up adding the following to both scripts to resolve it (a do once check).

int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);


               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #4 on: May 09, 2012, 04:22:36 am »


               This script is only in the OnDeath event, that was the first thing I looked for.
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #5 on: May 10, 2012, 02:53:09 am »


               Here's a longshot. If you smash the item with a "plain" weapon (one having no damage bonuses/enchantments) does the problem not occur? If so, try the "do once" option as above anyhow. Sometimes, weapons bonuses from thing like flame weapon act wonky and it may be making the game fire that script twice.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #6 on: May 10, 2012, 03:43:02 am »


               

SKIPPNUTTZ wrote...
I have recently encountered odd behavior with this script which will respawn TWO placeables at the location instead of one, which will cause them to be undestroyable by melee or spells (only noticed with Webs so far).


Just wondering also if this might have anything to do with mixed up tags/resrefs and whether or not you are spawning in a static web rather than a usable one? Doesn't explain the doubles but would explain why you can't destroy them. Also just out of curiosity are you also using an area clean up script which might destroy these objects?
               
               

               


                     Modifié par GhostOfGod, 10 mai 2012 - 02:43 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #7 on: May 10, 2012, 03:48:46 am »


               My guess is that the BluePrint is Static, Changed to NonStatic on the instance only.   After all two webs in the same place would still be destroyable.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #8 on: May 10, 2012, 04:56:46 am »


               Try flipping AssignCommand() and DelayCommand(), so it reads DelayCommand(fDelay, AssignCommand(GetArea(OBJECT_SELF), ...));
               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #9 on: May 10, 2012, 08:17:57 pm »


               

Here's a longshot. If you smash the item with a "plain" weapon (one having no damage bonuses/enchantments) does the problem not occur? If so, try the "do once" option as above anyhow. Sometimes, weapons bonuses from thing like flame weapon act wonky and it may be making the game fire that script twice.



Object is targetable/usable, but acts like it's out of line of sight, so it just action cancels.

And it's a rather rare occurrence, which is the only thing that had me stumped.

So far the only thing I have seen be able to destroy these fluke webs is a Unique Power misc item we made for weapon masters, which does Magical dmg and decrements Ki Damage uses.
@ Flame Weapon, ours isn't an OnHit effect. But it is possible that our custom Planar Rift dmg could be cause this. I'm quite sure the doonce will resolve this.

My guess is that the BluePrint is Static, Changed to NonStatic on the instance only. After all two webs in the same place would still be destroyable.


I would have guessed this as well if it was happening on every web, each kill. But that isn't the case '<img'>

Try flipping AssignCommand() and DelayCommand(), so it reads DelayCommand(fDelay, AssignCommand(GetArea(OBJECT_SELF), ...));p


Can try this, and the DoOnce approach as well. Wouldn't hurt anything.
               
               

               


                     Modifié par SKIPPNUTTZ, 10 mai 2012 - 07:20 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #10 on: May 10, 2012, 10:39:04 pm »


               Since the script is OnDeath.   Flipping the Delay and Assign commands, will most likely stop the items from ressponing.    Since the object is no longer around after that scripts finishes to do the command.
               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Respawning Placeables Bugs
« Reply #11 on: May 10, 2012, 11:15:48 pm »


               Yep.  Exactly why you have to assigncommand to the area or other persistent object, since the corpse object has only ~5 second duration unless you use lootable corpses.

About 90% sure this was a result of OnHit: Planar Rift doing physical dmg at the exact same time as the normal melee hit.
               
               

               


                     Modifié par SKIPPNUTTZ, 10 mai 2012 - 10:21 .