Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is there an @gethit for spells?
Author Message
bmanny
Apprentice
*

Posts: 25
Likes Given: 1
Likes Received: 0 in 0 posts
Joined: May 2017
Reputation: 0



Post: #1
is there an @gethit for spells?
Is there an @gethit for spells?

I want to do custom damage calculation when a creature is hit.

I also want an if statement to differentiate between a player and an npc, because I don't want to apply increased damage to players.

Basically,

@gethit
damage = <damage> * src.MagicDamageBonusMod

I also want to override magic resist to only be applied in pve. What should I add to remove it from pvp, but in pve override it with my own custom code?

resistMod = <magicresist * mathNumbers>
damage = <damage * resistMod>
05-11-2017 07:11 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: is there an @gethit for spells?
@gethit is always fired, no matter the source of damage.

However, Spells instead of firing the @hit trigger will fires the @SpellEffect (in a character events) trigger and the @Effect ( in a spell event), both are called before @Gethit and the order is this:

@SpellEffect -> @Effect -> @Gethit (if the spell cause damage)

Remember that the @Effect must be placed in a spell block (check sphere_spell.scp)
(This post was last modified: 05-11-2017 08:30 AM by darksun84.)
05-11-2017 08:30 AM
Find all posts by this user Like Post Quote this message in a reply
bmanny
Apprentice
*

Posts: 25
Likes Given: 1
Likes Received: 0 in 0 posts
Joined: May 2017
Reputation: 0



Post: #3
RE: is there an @gethit for spells?
How does @gethit know if it is being hit by a sword, fencing weapon, or spell?
05-11-2017 09:15 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #4
RE: is there an @gethit for spells?
src.action in the @gethit will give you the action used by the attacker (skill_swordsmanship, skill_wrestling, skil_magery and so on...).

Pay attention if the damage is not caused by a "direct damage" spell (example: poison), in this case src.action will return -1
05-11-2017 08:23 PM
Find all posts by this user Like Post Quote this message in a reply
bmanny
Apprentice
*

Posts: 25
Likes Given: 1
Likes Received: 0 in 0 posts
Joined: May 2017
Reputation: 0



Post: #5
RE: is there an @gethit for spells?
(05-11-2017 08:23 PM)darksun84 Wrote:  Pay attention if the damage is not caused by a "direct damage" spell (example: poison), in this case src.action will return -1

How do I tell with poison?
05-16-2017 11:25 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #6
RE: is there an @gethit for spells?
all damages have at least 2 sub-values: the damage value itself and the damage type value (eg: DAMAGE 15 dam_fire -> cause 15 of fire damage)

most damage spells will include dam_magic flag on the damage value so you can check if damage type have dam_magic on @GetHit. Something like
Code:
ON=@GetHit
IF (<ARGN2> & dam_magic)
  //some code here
ENDIF

but @GetHit is called for every hit you take, and also any items/chars/scripts/etc can also use dam_magic, so there's no guarantee that the code will work only to damages caused by spells. If any other thing cause an damage using dam_magic the code will also consider it an damage caused by spell

so maybe the best solution is change the EFFECT value directly on spells (sphere_spells.scp) or use LOCAL.Effect on @Effect [spells] / @SpellEffect [chars] triggers
05-17-2017 02:07 PM
Find all posts by this user Like Post Quote this message in a reply
bmanny
Apprentice
*

Posts: 25
Likes Given: 1
Likes Received: 0 in 0 posts
Joined: May 2017
Reputation: 0



Post: #7
RE: is there an @gethit for spells?
I'm having some problems.

I did this to test the local effect and it works:

ON=@Effect
LOCAL.DAMAGETYPE=(<DEF.dam_physical>|<DEF.dam_magic>)
SRC.SAY <eval <LOCAL.EFFECT>>



Inside the @GetHit I can't get the local.effect though.

I've tried a ton of different things:

say <argn2> is effect
say <SRC.LOCAL.EFFECT> is effect (and all the variations I could think of)


I need to get the incoming EFFECT in order to run my custom combat math on it. Any idea how? If I could just see how to make a mob Say how much the Effect was I could handle it from there.
05-22-2017 04:23 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #8
RE: is there an @gethit for spells?
argn1 in @gethit should be the damage you put in local.effect (local variables aren't shared between triggers)
05-22-2017 04:41 AM
Find all posts by this user Like Post Quote this message in a reply
bmanny
Apprentice
*

Posts: 25
Likes Given: 1
Likes Received: 0 in 0 posts
Joined: May 2017
Reputation: 0



Post: #9
RE: is there an @gethit for spells?
I'm getting closer, but there is still odd stuff happening.

say argn1 doesn't return the EFFECT I have set in the spell.

In @Effect on the spell I
say local.effect.

This works and shows me the proper number.

on my @GetHit I have...
say <arng1> which returns odd numbers.

With an effect of 30,30 I'm getting a huge variation. 25-35 almost. How do I simply get the base Effect. How do I stop sphere from running whatever math is running? I want to entirely write my own magery damage system.


I tried putting @SpellEffect on my player to simply Say I casted a spell hoping I could work backwards from there. This did nothing. Am I missing something?
05-22-2017 09:40 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #10
RE: is there an @gethit for spells?
to use EFFECT and LOCAL.Effect values on spells you must make sure that MAGICF_OSIFORMULAS is disabled on sphere.ini, otherwise MAGICF_OSIFORMULAS will replace these values with the result of internal OSI formulas
05-22-2017 03:50 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)