SphereCommunity
Spells on @gethit - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Spells on @gethit (/Thread-Spells-on-gethit)

Pages: 1 2


Spells on @gethit - Lano - 10-16-2012 06:41 AM

I there, i need a little help with this:

ON=@GETHIT
IF (this is a fire spell, lets say s_explosion)
local.magicfire = <muldiv <argn1>,100,100>
local.magicfire -= <muldiv <resfire>,100,100>
src.say Fire dmg
argn1 = <eval <local.magicfire> + <local.magiccold> + <local.magicpoison> + <local.magicenergy>>
endif

I just cant seem to get the dmg output of the spell argn1..
I know that under @spelleffect argn1 is the spell type and argn2 the effect, but i am interestet in the dmg output, so my custom resistance system can work against the spell dmg output.

I just cant seem to check for the spell, nor find the dmg output.

Hope you understand it, its quite confusing to explain Smile


RE: Spells on @gethit - Barnabus - 10-16-2012 07:08 AM

Combat can be tricky. GETHIT happens when the player actually gets hit with a damage.
It is not the trigger used to calculate the damage...

MAGE DAMAGE - do all your calculations inside the SpellEffect Trigger.
PHP Code:
ON=@SpellEffect
    REF1
=<SERV.UID.<SRC.UID>> // Caster 
    
REF2=<SERV.UID.<UID>>      // Target
// also here in this trigger <ARGN1> is the spell no.
// Here we know the caster the target and the spellno
// do your calculations here get a total, local.DamageTotal
// then carry the damage value across to the GetHit Trigger, for example as a CTAG
REF2.CTAG.A_Mage_Damaged_Me_For=<EVAL <LOCAL.damageTotal>> 
MELEE DAMAGE - do all your calculations inside the HIT Trigger.
PHP Code:
ON=@HIT
    REF1
=<SERV.UID.<UID>>        // Attacker
    
REF2=<SERV.UID.<SRC.UID>>    // Victim
    
REF3=<SERV.UID.<ARGO.UID>>    // Weapon 0 if Fists
// here in this trigger <ARGO> is the weapon
// Here we know the attacker target and weapon
// do your calculations here get a total, local.DamageTotal
// then carry the damage value across to the GetHit Trigger, for example :
REF2.CTAG.A_Melee_Damaged_Me_For=<EVAL <LOCAL.damageTotal>> 

Then now you have the damage tagged to the person whom is getting Hit !!

PHP Code:
ON=@GETHIT
REF1
=<SERV.UID.<UID>>        // Person getting HIT
IF <REF1.CTAG0.A_Melee_Damaged_Me_For>
    
ARGN1=<EVAL <REF1.CTAG.A_Melee_Damaged_Me_For>>
    
ARGN2=dam_god // This is the damage type you can have dam_fire etc also look into it
    
ARGN3=I cant remeber what this is )
ELIF <REF1.CTAG0.A_Mage_Damaged_Me_For>
    
ARGN1=<EVAL <REF1.CTAG.A_Mage_Damaged_Me_For>>
    
ARGN2=dam_god // This is the damage type you can have dam_fire etc also look into it
    
ARGN3=I cant remeber what this is )
ELSE
    
// This should never happen.
ENDIF 

Ok so briefly now :

1. Do all your damage calculations in HIT and SPELLEFECT
2. Transfer these damages one way or another to the GETHIT Trigger
3. In the GETHIT Trigger set ARGN1 asthe damage
4. ARGN2 as the damage type
5. Set ARGN3 as 0 (I dont remeber why i did this but i have a feeling it was parry or resist)
6. NOTE:dam_fire, or dam_cold, will get resisted by resfire rescold etc but dam_god wont get resisted.


Ooops I forgot to say and its important... Remeber to remove the tags after you pass the damage !!
PHP Code:
ARGN1=<EVAL <REF1.CTAG.A_Mage_Damaged_Me_For>>
    
REF1.CTAG.A_Mage_Damaged_Me_For



RE: Spells on @gethit - Lano - 10-16-2012 05:29 PM

Okay, i had a long bumby ride ahead of me before i had figured that one out myself Big Grin so thanks so much


RE: Spells on @gethit - Barnabus - 10-17-2012 12:13 AM

The sphere community pack has an exellent example of this..

http://code.google.com/p/sphere-community-pack/source/browse/trunk/scripts/add-on/combat/sphere_combat_events.scp


RE: Spells on @gethit - Lano - 10-17-2012 03:40 AM

Okay call me stupid, but i still dont get it, you say:

ON=@SpellEffect
REF1=<SERV.UID.<SRC.UID>> // Caster
REF2=<SERV.UID.<UID>> // Target
// also here in this trigger <ARGN1> is the spell no.
// Here we know the caster the target and the spellno
// do your calculations here get a total, local.DamageTotal
// then carry the damage value across to the GetHit Trigger, for example as a CTAG
REF2.CTAG.A_Mage_Damaged_Me_For=<EVAL <LOCAL.damageTotal>>

Okay, but: ""// do your calculations here get a total, local.DamageTotal"" that still gives me the same problem, where is the dmg from the spell stored? ARGN1 is the spell number, ARGN2 is the spelltype/effect where is the damage stored? how do i calculate that? i have no trouble appliying the dmg to my resist system and making it..well resist it, but i have trouble locating where the dmg a spell gives is stored....

I mean...

ON=@SpellEffect
REF1=<SERV.UID.<SRC.UID>> // Caster
REF2=<SERV.UID.<UID>> // Target
IF (<argn1> == some stupid spell number i wish to add % to resist)
local.damagetotal = <eval <what? not argn1 or argn2? so what?> + <whatever i would like to add or take from that number>
REF2.CTAG.A_Mage_Damaged_Me_For=<EVAL <LOCAL.damageTotal>>


RE: Spells on @gethit - Barnabus - 10-17-2012 05:57 AM

If we just look at a Spell for example spell number 51 shown below

PHP Code:
[Spell 51]
DEFNAME=s_flamestrike
NAME
=Flame Strike
SOUND
=snd_SPELL_FLAMESTRIKE
RUNES
=KVF
CAST_TIME
=3.5
RESOURCES
=i_reag_spider_silk,i_reag_sulfur_ash
RUNE_ITEM
=i_rune_FLAMESTRIKE
SCROLL_ITEM
=i_scroll_FLAMESTRIKE
FLAGS
=SPELLFLAG_TARG_OBJ|SPELLFLAG_HARMSPELLFLAG_FX_TARGSPELLFLAG_RESIST
EFFECT_ID
=03709
EFFECT
=59
DURATION
=0.0
MANAUSE
=40
SKILLREQ
=MAGERY 80.0
INTERRUPT
=100.0,100.0 

We can see this spell has the flag SPELLFLAG_HARM
This means it will do damage.
The Damage on the spell is the EFFECT.

How do we access this damage from code ? <SERV.SPELL.51.EFFECT>

PHP Code:
ON=@SpellEffect
REF1
=<SERV.UID.<SRC.UID>> // Caster 
REF2=<SERV.UID.<UID>> // Target

// Check if the spell is a harmfull spell
If (<SERV.SPELL.<ARGN1>.FLAGS>&SPELLFLAG_HARM)
    
LOCAL.DAMAGE=<EVAL <SERV.SPELL.<ARGN1>.EFFECT>>
    
SERV.LOG @GETHIT <REF1.NAMEcasts <SERV.SPELL.<ARGN1>.NAMEon <REF2.NAMEdoing <EVAL <LOCAL.DAMAGE>> damage
ELSE
    
SERV.LOG @GETHIT <REF1.NAMEcasts non harmfull spell <SERV.SPELL.<ARGN1>.NAMEon <REF2.NAME>
ENDIF 

Hopefully that should make sense now, if your still confused let me know


RE: Spells on @gethit - Lano - 10-17-2012 05:11 PM

<SERV.SPELL.<ARGN1>.EFFECT>> <----That was my mystery component.

Thanks for your patience, now i will be able to get it done.
Thanks again, always nice to have the forums to fall back to when you cant find the answer on sphere wiki Smile


RE: Spells on @gethit - Lano - 10-18-2012 03:09 AM

But!

Will this not only take the excact value from the EFFECT= line?

i mean wont it always use EFFECT=59 the effect may be 59, but a low lvl mage would do less dmg with that spell, and a über monster with 300.0+ magery would do way more dmg, but we would always only be getting 59 as the output value/dmg? or am i wrong?


RE: Spells on @gethit - Barnabus - 10-18-2012 05:56 AM

Yes but thats were you put your calulations in

It starts as 59,

then after you calculate EvalInt Magery Int and - Resist

Depending on your calculations it will not be 59

If you just do

@GETHIT

ARGN1=59
ARGN2=Dam_God
ARGN3=0

It will just be 59....


RE: Spells on @gethit - Skul - 10-18-2012 07:03 AM

You'll need to set a tag in @spelleffect and read it through @gethit, that's the only way to really store what 'spell' was sent through, here's a quick example:
Code:
on=@spelleffect
if ( <serv.spell.<argn1>.flags> & spellflag_damage )
  tag.spell_argn=<argn1> //store the spell number
endif

on=@gethit
if ( <argn2> & 04 ) //magic damage?
  if (<serv.spell.<tag0.spell_argn>.defname>==s_fireball) //fireball?
    argn1 += <eval <eval <src.magery> *25> /100> //add damage?
  endif
endif