SphereCommunity
Stop damage/ARGN1 if... - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Stop damage/ARGN1 if... (/Thread-Stop-damage-ARGN1-if)



Stop damage/ARGN1 if... - Lano - 08-17-2018 08:00 AM

Hello, maybe its getting late or I am just plain stupid.
Below a part of a system i am working on, where willpower and toughness act as a magic- and physical-shield on NPC's. Toughness is decreased/destroyd with physical damage, and Willpower with magical damage.

Willpower and Toughness gets assigned when the NPC is created (on=@create) based on their skills (magery, swordsmanship, etc.), stats and armor values..

Once created , players have to bring either the NPCS willpower or Toughness to 0% before they can start giving direct damage to the hitpoints (and on the hitpoints elemental-resistances still play in)

So its basically just another layer of fun and tactics for PVE.
However, I sliced up my "ON=@GETHIT" script to get some help... see below.

I need to blockout the damage to hitpoints, untill either willpower or toughness is at zero .. and truely, i could not figure out where to place the "Return 1"
Either they took no dmg at all, or all the time...


ON=@GETHIT
IF (<ARGN2> & dam_magic)&&(<eval <tag.magicalshield>> >= 0)
sfx 952
EFFECT 3 i_fx_sparkle_2, 16, 16
tag.magicalshield=<eval <tag.magicalshield>> -<ARGN1>
resendtooltip=1
--> Return 1 here does nothing... NPC still takes hitpoint dmg.

ELSEIF (<ARGN2> & dam_physical)&&(<eval <tag.defenseshield>> >= 0)
EFFECT 3 i_fx_curse, 16, 16
tag.defenseshield=<eval <tag.defenseshield>> -<ARGN1>
resendtooltip=1
dorand = 3
sfx 952
sfx 953
sfx 954

IF (<eval <tag.defenseshield>> <= 1)
tag.lifeleft <eval <muldiv <hits>,100,<maxhits>>>
tag.defenseshield <eval <tag.defenseshield>>
tag.magicalshield <eval <tag.magicalshield>>
UPDATE 1
resendtooltip=1

ELSEIF (<eval <tag.magicalshield>> <= 1)
tag.lifeleft <eval <muldiv <hits>,100,<maxhits>>>
tag.defenseshield <eval <tag.defenseshield>>
tag.magicalshield <eval <tag.magicalshield>>
UPDATE 1
resendtooltip=1
ENDIF
--> Return 1 here blocks hitpoint damage totally...

Oh and if you tell me, that script is old, and slow and heavy on the server, please feel free to show me how to make it better (been away from sphere for some years)


RE: Stop damage/ARGN1 if... - Artyk - 08-17-2018 09:28 AM

I would do something like this, I hope it's well written, i'm a bit asleep Big Grin

PHP Code:
ON=@GETHIT
IF (<ARGN2> & dam_magic)    // splitted if so you can put serv.log to catch errors
    
IF (<tag0.magicalshield> > 0)    // tag0 instead of tag, so if it is not set, it becomes 0
        // local variable to calculate the amount absorbed
        
local.ms_absorb = <qval <argn1> >= <tag0.magicalshield> ? <tag0.magicalshield> : <argn1>>
        
argn1 -= <local.ms_absorb>
        
tag.magicalshield -= <local.ms_absorb>
        
        
sfx 952
        EFFECT 3 i_fx_sparkle_2
1616
        resendtooltip
=1
        
// only return 1 if all the damage was mitigated, otherwise go on
        
IF (<argn1> <= 0)
            return 
1
        
ENDIF
    ENDIF
ENDIF

// repeat the same as magic shield for physical
IF (<ARGN2> & dam_physical)
    IF (<
tag0.defenseshield> > 0)
        
local.ds_absorb = <qval <argn1> >= <tag0.defenseshield> ? <tag0.defenseshield> : <argn1>>
        
argn1 -= <local.ds_absorb>
        
tag.defenseshield -= <local.ds_absorb>
        
        
EFFECT 3 i_fx_curse1616
        resendtooltip
=1
        dorand 
3
        sfx 952
        sfx 953
        sfx 954
        
        
IF (<argn1> <= 0)
            return 
1
        
ENDIF
    ENDIF
ENDIF

// ------------------------------------------------- Didn't understand the part below
IF (<eval <tag.defenseshield>> <= 1)
tag.lifeleft <eval <muldiv <hits>,100,<maxhits>>>
tag.defenseshield <eval <tag.defenseshield>>
tag.magicalshield <eval <tag.magicalshield>>
UPDATE 1
resendtooltip
=1

ELSEIF (<eval <tag.magicalshield>> <= 1)
tag.lifeleft <eval <muldiv <hits>,100,<maxhits>>>
tag.defenseshield <eval <tag.defenseshield>>
tag.magicalshield <eval <tag.magicalshield>>
UPDATE 1
resendtooltip
=1
ENDIF 



RE: Stop damage/ARGN1 if... - Coruja - 08-17-2018 02:14 PM

the trigger seems to be working fine, but probably you're getting some logic error on your code

Code:
ON=@GetHit
IF (<ARGN2> & dam_magic) && (<eval <tag.magicalshield>> >= 0)
  //this code is not being reached because <ARGN2> doesn't have dam_magic or <TAG.MagicalShield> is not >= 0
ELSE
  //...
ENDIF
//return 1 works here because this code is being reached



RE: Stop damage/ARGN1 if... - Lano - 08-17-2018 04:23 PM

Thanks to the both of you!

Artyk I will try out your take on it when I get home. Thanks again.

And Coruja I think you are right, thanks for the input as well!

- Good to know that there still is plenty of life in here to start a whole new Sphereserver project and get teh help one needs Wink Thank you again gentlemen.