Editing Distinguishing Between Physical and Magickal Hits

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{Unfinished}}
{{Discussion}}


To determine whether an attack upon a trigger or NPC is either physical or magical, the following script should be used:
== 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? -- [[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)
 
== Solution ==
 
I think I've found a more elegant solution:


<pre>
<pre>
Line 15: Line 51:
</pre>
</pre>


The [[Return]] command terminates the entire script, and not just the block that it's called from. This can be used to have one trigger override another if they are triggered at the same time.
It looks like the [[Return]] command terminates the entire ''script'', and not just the block that it's called from. This can be used to have one trigger override another if they are triggered at the same time.
-- [[User:Diablerie|Diablerie]] 23:34, 15 April 2006 (EDT)


[[Category:Useful Code]]
[[Category:Useful Code]]
[[Category:Solutions]]
[[Category:Solutions]]

Please note that all contributions to the Oblivion ConstructionSet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see CSwiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: