Author Topic: RE: Help with Time Functions in Multiplayer  (Read 432 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
RE: Help with Time Functions in Multiplayer
« Reply #15 on: August 12, 2011, 07:19:19 pm »


               henesua: It doesnt have to be totally per pnp etc. just need some easy script that could merge with my heavy dying script with special check for pvp (I created Gothic game solution of uncousciosness) and one custom feat that allows fight untill -11. Those I have seen on vault were too much global and too much complicated. So drop me a pm please '<img'>
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
RE: Help with Time Functions in Multiplayer
« Reply #16 on: August 12, 2011, 10:08:17 pm »


               Another safe and efficient way to go is to use user-defined events and have them delay a SignalEvent call to repeat themselves. They are easy to centralize and manage from a single script or two so you can limit the number of additional scripts you have to add to your module like you will eventually get by using delayed ExecuteScript calls all the time...plus Events evoke a context switch too so you won't end up with a memory leak after lots and lots of repetitions like a delayed function can cause. They allow for some added flexibility in implementing your pseudo-hbs as well. For example, if you have a group of phbs that are related and can all be running at the same time, you can create a specific object like a creature or placeable to receive the events and thus operate them. Then, should you ever want to shut them all down at once, all you have to do is destroy the object. The only drawbacks really are that PCs can't be used to run them (a biggie sometimes), and that you have to use local variables to pass data to them...but, of course, you have to do that with executed scripts also. Only delayed functions make it easy to pass data along. If you need to pass something that cannot be stored in a local variable (e.g. an effect), you're stuck with functions. You just can't allow them to run too many times between shutdowns is all..."too many times" being largely dependent on how much data you pass along.

In this instance however, I wouldn't concern myself too much with efficiency or memory leaks building up since whatever method you go with it isn't very likely to ever repeat more than 10 times. For that problem to manifest here, the implementation you use for OnDying would have to allow for bleeding to potentially go on for hundreds of rounds without the guy ever dying or healing...probably not a system most people would use.
               
               

               


                     Modifié par Axe_Murderer, 12 août 2011 - 09:51 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
RE: Help with Time Functions in Multiplayer
« Reply #17 on: August 12, 2011, 11:35:31 pm »


               Thanks for the info, Axe.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Help with Time Functions in Multiplayer
« Reply #18 on: August 13, 2011, 10:46:26 am »


               

Axe_Murderer wrote...

Pstemarie wrote...

Here you go ShaDoOoW. I just put the visual in there for a sort of "ticking" timer.
...

Except it won't tick. The OnPlayerDying event only happens once. When you go below 1HP the engine fires either an OnDeath or an OnDying event depending on whether you made it all the way down to -10 or not . Only one event is generated. The effect your using is like a wounding effect. It automatically applies itself once per round and automatically removes itself when the player gets back above 0 or down to -10 (then the engine fires OnDeath).
If you were to use a regular damage effect there instead, the player would only get one application of it and then be forever incapacitated unless it was enough to kill him, or somebody comes along and heals him, or the module somehow decides he should be healed or killed and does so. That's why the WhenDying effect exists and why you apply it using a permanent duration and why you can't use it as a wounding effect on living creatures.

So your visual effect will only occur once at the start of bleeding.

To make a pulse effect to go along with it:

[nwscript]void PulseBlood()
{ if( GetIsDead( OBJECT_SELF ) || (GetCurrentHitPoints() > 0) ) return;
   ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectVisualEffect( VFX_COM_BLOOD_SPARK_SMALL  ), OBJECT_SELF );
   DelayCommand( RoundsToSeconds( 1 ), PulseBlood() );
}

void main()
{ object oPC = GetLastPlayerDying();
   ApplyEffectToObject( DURATION_TYPE_PERMANENT, EffectHitPointChangeWhenDying( 1.0 ), oPC );
   AssignCommand( oPC, PulseBlood() );
}[/nwscript]


Actually the "ticker" does work just as I've said - I've watched it numerous time over. Each round after the character "dies" the first time they take one damage and the VFX is applied. I don't know why it works - cause as you point out it shouldn't, but the VFX is definitely being applied each time that the WhenDying effect is applied. I wonder if the VFX is already part of the WhenDying effect?

As far as pnp goes, this function works exactly as it should - at least as far as the HP loss is concerned. All that needs to be added is something to cover stabilization.

EDIT - Just removed the VFX from my script and the pulse still fires, so its obviously built into the function.
               
               

               


                     Modifié par Pstemarie, 13 août 2011 - 10:15 .