SphereCommunity
Stats (hits) change trigger - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Stats (hits) change trigger (/Thread-Stats-hits-change-trigger)

Pages: 1 2


Stats (hits) change trigger - tleilax - 01-24-2013 06:45 AM

Hello,

quick question - is there a trigger which fires every time hits/stam/mana of character is changed?

Even if it's by health regen.

@statchange works only if STR (etc) is changed, but not current health


Thanks


RE: Stats (hits) change trigger - Skul - 01-25-2013 01:45 AM

No, no such trigger... sorry.


RE: Stats (hits) change trigger - tleilax - 01-25-2013 01:56 AM

How bad idea would it be to make some memory on every player, which would check every second, if HP (of the player) changed?

Could this lag the server? Cause instability? I'm talking about 50 players online at max.

Also, how would you use script profiler to check this?


RE: Stats (hits) change trigger - Skul - 01-25-2013 03:38 AM

Not really, as long as the timer is triggered only if the player is logged in. Here's a little example I thought up of for you:
Code:
[function checkstat]
if (<isempty <tag.statchange_hits>>) || (<isempty <tag.statchange_mana>>) || (<isempty <tag.statchange_stam>>)
  tag.statchange_hits=<hits>
  tag.statchange_mana=<mana>
  tag.statchange_stam=<stam>
else
  if !(<dtag0.statchange_hits>==<hits>)
    trigger @statchange_hits
  endif
  if !(<dtag0.statchange_mana>==<mana>)
    trigger @statchange_mana
  endif
  if !(<dtag0.statchange_stam>==<stam>)
    trigger @statchange_stam
  endif
endif
if (<isonline>)
  timerf 1, checkstat
else
  tag.statchange_hits=
  tag.statchange_mana=
  tag.statchange_stam=
endif
Pass 'checkstat' upon every player that logs in to start the function, use @statchange_hits, @statchange_mana, and @statchange_stam as triggers in player events to code the things you need to.


RE: Stats (hits) change trigger - tleilax - 01-25-2013 04:31 AM

Works like a charm, thanks a lot.


RE: Stats (hits) change trigger - RanXerox - 01-25-2013 05:38 AM

I use something similar (mine is a 10 second timer object in every player's memory) for the focus skill:

Code:
[ITEMDEF i_focus_timer]
ID=i_candle_thin_lit
TYPE=t_eq_script
LAYER=layer_special
WEIGHT=0
ON=@Create
   ATTR=attr_decay|attr_can_decay
   TIMER=10
ON=@Timer
   IF (<CONT.STAM> < <CONT.MAXSTAM>) || (<CONT.HITS> < <CONT.MAXHITS>) || (<CONT.MANA> < <CONT.MAXMANA>)
      LOCAL.Difficulty=<EVAL <CONT.Focus> / 10>
      IF (<LOCAL.Difficulty> > 90)
         LOCAL.Difficulty=90
      ENDIF
      IF (<LOCAL.Difficulty> < 10)
         LOCAL.Difficulty=10
      ENDIF
      CONT.SKILLGAIN focus <LOCAL.Difficulty>
   ENDIF
   TIMER=10
   RETURN 1



RE: Stats (hits) change trigger - Ben - 01-25-2013 11:36 AM

No one thought of the @userStats trigger? It's not well documented in the wiki, but in the revisions, it says that it is triggered at every status update, and if ARGN3=1 then it's the user that opened the status window.
Maybe this could help?


RE: Stats (hits) change trigger - RanXerox - 01-25-2013 02:07 PM

The wiki says "Fires when the player opens the status window" and it says "This trigger fires when a status update is sent to a player"... so which is it?


RE: Stats (hits) change trigger - Skul - 01-25-2013 04:05 PM

(01-25-2013 02:07 PM)RanXerox Wrote:  The wiki says "Fires when the player opens the status window" and it says "This trigger fires when a status update is sent to a player"... so which is it?

Both?


RE: Stats (hits) change trigger - tleilax - 01-25-2013 06:59 PM

(01-25-2013 02:07 PM)RanXerox Wrote:  The wiki says "Fires when the player opens the status window" and it says "This trigger fires when a status update is sent to a player"... so which is it?

It only updates when status window is opened or when stats (STR, DEX, INT, not health or mana) is changed. I've already tried it...