Author Topic: ondeath help wanted  (Read 735 times)

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
ondeath help wanted
« Reply #15 on: December 30, 2014, 06:48:45 am »


               

Glad you got it working. In general, there is a potential problem with delay command or actions in an OnDeath script, because the caller may not live long enough to do them. The resolution is to assign the task to the module or other permanent object, e.g.  AssignCommand(GetModule(), xxxx);



               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #16 on: December 30, 2014, 07:00:20 am »


               

oh thats good to know, thanks Proleric.


 


i may be back here with a few other minor things in days to come. trying to get this mod wrapped up in the next few weeks.


 


'<img'>



               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #17 on: December 30, 2014, 09:38:33 am »


               

hey again folks. i have this script which is executed oncliententer and i was told it works fine, but it's broken. it's supposed to make a check on the player inventory for my mods unique items, delete them, then create new ones on the player. what it actually does is create the items with out deleting the old ones.


void main()

{

object oPlayer = GetEnteringObject();

if (GetItemPossessedBy(oPlayer, "manager")== OBJECT_INVALID)

    {

    CreateItemOnObject("manager", oPlayer);

    }

if (GetItemPossessedBy(oPlayer, "pwmenu")== OBJECT_INVALID)

    {

    CreateItemOnObject("pwmenu", oPlayer);

    }

if (GetItemPossessedBy(oPlayer, "statchecker")== OBJECT_INVALID)

    {

    CreateItemOnObject("statchecker", oPlayer);

    }

if (GetItemPossessedBy(oPlayer, "pipe")== OBJECT_INVALID)

    {

    CreateItemOnObject("pipe", oPlayer);

    }

 


 


thanks for any suggestions.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ondeath help wanted
« Reply #18 on: December 30, 2014, 03:22:40 pm »


               

It actually does neither of the things you describe. What it does is check if the player has each item and if not creates any missing ones.  There is no deleting and there is only creating new items if the PC does not have the item. Something like this code would do what you are describing:



object oItem;

oItem = GetItemPossessedBy(oPlayer, "manager");
if (GetIsObjectValid(oItem)
        DestroyObject(oItem);
CreateItemOnObject("manager", oPlayer);

oItem = GetItemPossessedBy(oPlayer, "pwmenu");
etc.

Editted for code formatting...



               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #19 on: December 30, 2014, 03:28:59 pm »


               

that's what i'm looking for.


 


thank you!



               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #20 on: December 30, 2014, 05:41:49 pm »


               

couldn't get it to compile, however many edits i make. damn scripting is like a guessing game for me...


 


the script i posted doesn't work the way you said, it creates the items no matter what. i've had to log into this mod enough for testing to know this, i have a full inventory of these items from this script. if it worked like you say i'd be satisfied with that


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ondeath help wanted
« Reply #21 on: December 30, 2014, 08:55:04 pm »


               

If it's not doing that then the tags of those items are not what you have in the code. E.g. the tag for the "manager" item is not "manager". 


The argument in the GetItemPossessedBy call is the tag, whereas the one in CreateItemOnObject is the resref.  The resref is clearly right since you are getting items created.  So the tag is wrong.


               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #22 on: December 30, 2014, 10:00:12 pm »


               

yeah you're right, i had the resref in both calls. i didnt know that about GetItemPossessed.


 


everything works now, thanks for the help meaglyn.



               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #23 on: January 02, 2015, 06:45:26 am »


               

back again... i have this script in all my areas onexit events and while it works, it also effects familiars and summons. wondering how i can make a check for them so they dont get whacked. thanks.


 


void DestroyMonster(object oMonster)

{

    effect eDeath = EffectVisualEffect(VFX_IMP_PULSE_NEGATIVE);

    ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oMonster);

    DestroyObject(oMonster, 0.01f);

}


void main()

{

    object oMonster = GetExitingObject();


    if (GetIsEnemy (oMonster) == TRUE){


    DelayCommand(0.5f, DestroyMonster(oMonster));

}

}



               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
ondeath help wanted
« Reply #24 on: January 02, 2015, 05:52:15 pm »


               

if (GetIsEnemy (oMonster) == TRUE){


 


What are you trying to achieve with the above?  Kill any creature that follows a PC out of the area?


 


Here's the lexicon definition of GetIsEnemy.  Since you don't define anything to compare the exiting monster to for purposes of defining what is an 'enemy', it uses the object that calls the script (and since this is in the area exit slot of the module, it is the 'module' calling the script, not a creature).


 


Another approach that should skip your associates could be to replace the line above with something like:


 


If (!GetIsPC(oMonster) && GetMaster(oMonster)==OBJECT_INVALID)


 


This looks to see if the exiting object is a PC.  If the exiting object is a PC, then nothing happens.  However, If the exiting object isn't a PC AND the object does not have a master, then destroy the monster.  Your summons/associates will return the PC as the master, so they'll fail the check and won't get destroyed.  A downside of this approach is that summons/associates of NPCs wouldn't be affected (since they do have masters, even though that master is not a PC).


 


This may or may not be appropriate based on what your objective is.



               
               

               
            

Legacy_Wawmong

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +0/-0
ondeath help wanted
« Reply #25 on: January 02, 2015, 06:49:44 pm »


               

yup, that is what it's for. i didnt want monsters following the pc into town or pve areas.


 


your fix works, thanks. not too worried about this missing npc summons, i don't have henchmen in this mod.


 


i'm beginning to think creating a small action pw is gonna take longer than expected. i'm trying to make it a lot like dungeon eternal x... but i didn't anticipate making quests, and the last bit of scripting to be such an ordeal lol. my scripter went mia so i'm stuck trying to piece together scripts myself without much knowledge of coding.