Author Topic: Avoid effect remove on death  (Read 461 times)

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Avoid effect remove on death
« on: January 03, 2016, 04:28:40 am »


               

Hi all!


 


I added an option in my module wich transforms the pcinto a skeleton permanently, and with that, a bunch of permanent supernatural effects as for example positive vulnerability, damage reduction etc. 


 


I have my custom module script onplayerdeath and in the whole script theres no reference to the effect removal. But when my player dies and all supernatural permanent effects are gone! and the appearance remains, and its not nice since the skeleton lose all his features, its just an appearance. 


 


 


How can i avoid the removal of such effects? 


 


Some of the effects i added to the skin of the pc as permanents itemprops, those items props are removed as well?


 


 


thanks!



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Avoid effect remove on death
« Reply #1 on: January 03, 2016, 04:59:10 am »


               

Well solved xD


 


I reescripted the structure of the ondying and ondeath events. In ondying kept the pc inmortal for a few seconds till he auto-respawns (with no death gui) to his home and got healed. This way the pc will never actually "die" just "dying" and so never lose his effects, wich its enough for me and my module concept. 


 


 


So, another wild question appears!


 


As i said, in my module there are a lot of heartbeats, long delaycommands, supernatural effects and such long term things that i would like to keep them working as they are now. 


 


But i sensed something isnt totally right when i loaded a game, saving/loading a game affects any of this things, as delaycommands etc? 


a way to avoid it? 


 


Example, a tree was planted and should grow in 20 minutes using DelayCommand.. if i save/load in the meantime, the delayed command will be interrupted? 



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Avoid effect remove on death
« Reply #2 on: January 06, 2016, 10:10:54 am »


               

For placeables that need to use delays, you might want to consider pseudo hb's or a global pseudo hb.


 


Eg:


For a tree grow:


 


- onHeartbeat for the tree would basically start a global recurring method call on the module.


It would also set an int value on the module to ensure only one copy of itself is running.


 
void TreeLoop()
{
   
   int i = 1;
   object oTree = GetObjectByTag("tree_tag",i);
   while(oTree != OBJECT_INVALID)
    {
         //Do something to tree
 
        //get next tree
         oTree= GetObjectByTag("tree_tag",i);
         i++;
    }
   DelayCommand(300.00, TreeLoop());
}
void main()
{
   object module = GetModule();
   int iDone = GetLocalInt(module,"TREE_LOOP");
   if(iDone){ return;}
   SetLocalInt(module,"TREE_LOOP",1);
   DelayCommand(1.00,TreeLoop());
}

 


 


I would actually recommend doing smaller intervals between the loops, for more granularity.


And increment a local variable on the tree to indicate the growth phase.


 


Eg: When the integer gets to 10, then grow the tree.


When the tree is harvested or cut down, reset it to 0, and let the loop continue to increment it again, until it gets to 10.


 


This way you avoid long 1 hour delayed commands, and get more accurate command execution.


 


 


Depending on how many trees you have, you may want to manage the delayed commands.


Doing 5000 trees in a single method call could end up freezing your module etc


 


If you however, migrate this to the trees 'actual' hb event, then the server will manage the heartbeats itself, allowing it to lower priority of areas which are empty.


This can however mean that some areas the trees do not grow back as fast.



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Avoid effect remove on death
« Reply #3 on: January 08, 2016, 12:17:08 am »


               

Thanks! im sure that global pseudo hb will save me a lot of memory, will try it! (:



               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Avoid effect remove on death
« Reply #4 on: January 08, 2016, 03:30:54 am »


               

Efficiency wise you'd be better off having a counter in the modules main HB script, and running the script every so many iterations, rather than using pseudo HBs for that at all, especially given that the placeable itself would still be running its own HB script every 6-9 seconds in addition to the pseudo HB.