Difference between revisions of "Distinguishing Between Physical and Magickal Hits"
imported>Diablerie |
imported>Diablerie (Potential solution) |
||
Line 1: | Line 1: | ||
== Question == | |||
I'd like to script behaviour that occurs when an actor is hit by a weapon, but not by a spell. | I'd like to script behaviour that occurs when an actor is hit by a weapon, but not by a spell. | ||
I have noticed that "Begin OnHit" triggers if an actor is hit by a melee weapon, projectile weapon, or a spell. Is there any way of determining what the actor was hit by? -- [[User:Diablerie|Diablerie]] 12:28, 15 April 2006 (EDT) | I have noticed that "Begin OnHit" triggers if an actor is hit by a melee weapon, projectile weapon, or a spell. Is there any way of determining what the actor was hit by? -- [[User:Diablerie|Diablerie]] 12:28, 15 April 2006 (EDT) | ||
== Discussion == | |||
--[[User:Mrflippy|Mrflippy]] 12:45, 15 April 2006 (EDT): You might be able to work something up using [[OnMagicEffectHit]]. | |||
:Not a bad idea. I managed to get something working: | |||
<pre> | |||
scriptname WeaponHitScript | |||
short bMagicEffect | |||
begin OnMagicEffectHit | |||
set bMagicEffect to 1 | |||
end | |||
begin OnHit Player | |||
if (bMagicEffect == 0) | |||
<do stuff...> | |||
endif | |||
end | |||
begin GameMode | |||
set bMagicEffect to 0 | |||
end | |||
</pre> | |||
From what I saw, if the actor is hit by a spell, it will trigger both [[OnMagicEffectHit]] and [[OnHit]]. I'm not sure if the block ordering in the script makes any difference, but in my experiments, the ''OnHit'' block always saw the ''bMagicEffect'' variable set in the ''OnMagicEffectHit'' block. Hopefully, the ''GameMode'' block won't cause a performance hit. -- [[User:Diablerie|Diablerie]] 22:11, 15 April 2006 (EDT) | |||
[[Category:Questions]] | [[Category:Questions]] |
Revision as of 21:11, 15 April 2006
Question
I'd like to script behaviour that occurs when an actor is hit by a weapon, but not by a spell.
I have noticed that "Begin OnHit" triggers if an actor is hit by a melee weapon, projectile weapon, or a spell. Is there any way of determining what the actor was hit by? -- Diablerie 12:28, 15 April 2006 (EDT)
Discussion
--Mrflippy 12:45, 15 April 2006 (EDT): You might be able to work something up using OnMagicEffectHit.
- Not a bad idea. I managed to get something working:
scriptname WeaponHitScript short bMagicEffect begin OnMagicEffectHit set bMagicEffect to 1 end begin OnHit Player if (bMagicEffect == 0) <do stuff...> endif end begin GameMode set bMagicEffect to 0 end
From what I saw, if the actor is hit by a spell, it will trigger both OnMagicEffectHit and OnHit. I'm not sure if the block ordering in the script makes any difference, but in my experiments, the OnHit block always saw the bMagicEffect variable set in the OnMagicEffectHit block. Hopefully, the GameMode block won't cause a performance hit. -- Diablerie 22:11, 15 April 2006 (EDT)