SphereCommunity
Damage to self... - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Damage to self... (/Thread-Damage-to-self)



Damage to self... - RanXerox - 11-01-2012 08:02 AM

I am having difficulty working this out:

When a player or npc steps into a fire (for example, an item of type=t_fire), the "source" of the damage in the @GetHit trigger is themselves...

Similarly, when a fire elemental drops a fire on the ground and then walks into it, the "source" of the damage is themselves...

Does anyone have suggestions on how to prevent a fire elemental from taking damage when they walk into their own droppings, but still allow players or npc's to take fire damage when they step on something dangerous?


RE: Damage to self... - Shaklaban - 11-01-2012 09:27 AM

linking fire field to fire elemental do the trick for that situation.


RE: Damage to self... - RanXerox - 11-01-2012 10:22 AM

I presume you do this in @NPCSpecialAction... but how do you reference the item in that trigger?

... on second thought, this trigger occurs before the fire is dropped. What trigger fires AFTER (that has a reference to the fire object)?


RE: Damage to self... - Barnabus - 11-01-2012 10:05 PM

Hi RanXerox
I was wondering what you did here.... I was thinking something like

On the ITEMDEFS for FireFields

ON=@Step
IF <SRC.ISPLAYER>
SRC.TAG.StoodOnUIDSFireField=<LINK.UID>
ENDIF
RETURN 0

Then in PLAYERS GETHIT Doing something like..

ON=@GetHit
IF <REF2.TAG.StoodOnUIDSFireField>
REF2.TAG.StoodOnUIDSFireField=
ARGN2=dam_fire
ELSE
ARGN2=dam_god
ENDIF

And in the NPCS get hit
IF <REF2.TAG.StoodOnUIDSFireField> && <REF2.BASEID>==c_fire_elemental
REF2.TAG.StoodOnUIDSFireField=
RETURN 1
ELSE
ARGN2=dam_fire
ENDIF

What did you end up doing ?


RE: Damage to self... - Shaklaban - 11-01-2012 11:20 PM

(11-01-2012 10:22 AM)RanXerox Wrote:  I presume you do this in @NPCSpecialAction... but how do you reference the item in that trigger?

... on second thought, this trigger occurs before the fire is dropped. What trigger fires AFTER (that has a reference to the fire object)?

mayve @step works since elemental drop the fire field @step must fire for it for first time.

or if NPCSpecialAction fires for dropping fire field, maybe you can try act or foritems.


RE: Damage to self... - RanXerox - 11-02-2012 01:04 AM

The thing is, I don't want to stop all monsters from taking damage by stepping on things... players cast wall of fire, players can lay traps, monsters can fight each other when provoked or after being tamed, etc. I just want certain cases fixed. I like the idea of linking an item to its owner and detecting that to avoid the damage. The case of the fire field is just one example.


RE: Damage to self... - Barnabus - 11-02-2012 01:41 AM

Ive Decided on something similiar just reading your post and Ive just did something basic, I like skulls idea about defining the NPCSpecial Triggers etc.. I did on the ITEMDEF for the field

PHP Code:
ON=@Step
    REF1
=<SERV.UID.<SRC.UID>>
    
REF2=<SERV.UID.<LINK.UID>>
    
REF2.TAG.StoodOnUIDSFireField=<REF1.UID>
    
SERV.LOG @ITEMDEF <REF2.NAMEuid <REF2.UIDhas stepped on a fire field created by <LINK.NAMEuid <LINK.UID>
    RETURN 


and then in GETHIT I just did this....

PHP Code:
    IF <REF2.TAG.StoodOnUIDSFireField> == <REF2.UID>
        
REF2.TAG.StoodOnUIDSFireField=
        
SERV.LOG @GETHIT <REF2.NAMEstood on own fire field.
    ENDIF 

i havnt set no damage or effect yet but at least I know who did it and who got it now

@NPCFireField

Would rock Ive had difficuty with the dragon breath too.. Just to add another but similiar annoyance.
PHP Code:
ON=@NPCSpecialAction
    
IF <BASEID>== c_dragon
        serv
.log @NPCSpecialAction (<NAME>) does action <ACTION> <SERV.SKILL.<ACTION>.KEY>
    ENDIF

ON=@NPCAction
    
IF <BASEID>== c_dragon
        
IF <ACTION>==06e
            serv
.log @NPCAction (<NAME>) does action <ACTION> <SERV.SKILL.<ACTION>.KEY>
        ENDIF
    ENDIF

ON=@NPCActFight
    REF1
=<SERV.UID.<UID>>
    
REF2=<SERV.UID.<SRC.UID>>
    IF (
STRMATCH(*dragon*,<REF1.TAG.NPCGroup>>)
        IF <
ARGN1> > 2
                
IF <SERV.SKILL.<ACTION>.KEY> == Wrestling
                    
// This must be a Dragon Breath
                    
SERV.LOG @NPCActFight <NAMEBreathes Fire on <REF2.NAME>
                    
REF2.TAG.DragonFireDamage=<EVAL <REF1.INT> + <REF1.DAM>>
                ENDIF
            ENDIF
        ENDIF
    ENDIF
    RETURN 




RE: Damage to self... - Barnabus - 11-04-2012 03:11 AM

Sorry I got that Wrong. Ill Repost that @Step and @GetHIt Bit again for the benefit of noobs who may be reading this post.

PHP Code:
ON=@Step
    REF1
=<SERV.UID.<SRC.UID>> // Stepper
    
REF2=<SERV.UID.<LINK.UID>> // Doer
    
REF3=<SERV.UID.<UID>> // Item
    
REF1.TAG.StoodOnUIDSFireField=<REF2.UID>
    IF <
REF1.ISPLAYER>
        
SERV.LOG @ITEMDEF <REF1.NAMEuid <REF1.UIDhas stepped on a <REF3.NAMEcreated by <REF2.NAMEuid <REF2.UID>
    ENDIF
    RETURN 


The GETHIT trigger and just to note who is who in my GETHIT trigger.
Code:
ON=@GetHit
    REF1=<SERV.UID.<SRC.UID>>    // The one that served the HIT
    REF2=<SERV.UID.<UID>>        // One getting HIT

ANd Below is the code that was added to my get hit trigger.
PHP Code:
    IF <REF2.TAG0.StoodOnUIDSFireField> == <REF2.UID>
        
REF2.TAG.StoodOnUIDSFireField=
        
SERV.LOG @GETHIT <REF2.NAMEstood on own fire field.
        
ARGN1=0
        ARGN2
=0
        ARGN3
=0
        
RETURN 0
    
ELSE
        IF <
REF2.TAG0.StoodOnUIDSFireField>
            
REF1=<SERV.UID.<REF2.TAG.StoodOnUIDSFireField>>
            
SERV.LOG @GETHIT <REF2.NAMEstood on a firefield created by <REF1.NAME>[<REF1.UID>]
            
ARGN2=dam_fire
            REF2
.TAG.StoodOnUIDSFireField=
        ENDIF
    ENDIF 



RE: Damage to self... - Skul - 11-14-2012 02:51 AM

Barnabus, use @spelleffect and @gethit, here's an example:
Code:
on=@spelleffect
if ( <serv.spell.<argn1>.flags> & spellflag_damage ) //spell does damage?
  tag.spell_argn=<argn1> //store the spell number on effected player
endif

on=@gethit
if ( <argn2> & 04 ) //magic damage?
  if (<serv.spell.<tag0.spell_argn>.defname>==s_fire_field) //fire field?
    argn2 |= dam_fire //add fire damage flag
  endif
endif
tag.spell_argn= //erase tag in case of other hit type actions



RE: Damage to self... - RanXerox - 11-14-2012 04:27 AM

This technique will work for "instant" spells... but it won't work for things like firefield etc. So be careful hehe.