- Joined
- Jul 10, 2007
- Messages
- 6,306
All credits go to looking_for_help (gj man) for the idea of using spell damage reduction to determine whether damage was from a spell or not (http://www.hiveworkshop.com/forums/submissions-414/system-detection-physical-damage-228456/)
You may not use the Spell Damage Reduction ability when using this extension. Instead of using it, code spell resistance via a DDS.
Must invert Damage Return Factor for Locust Swarm based abilities.
Must invert healing portion of Life Drain based abilities.
Map contains the ability.
Demonstration
You may not use the Spell Damage Reduction ability when using this extension. Instead of using it, code spell resistance via a DDS.
Must invert Damage Return Factor for Locust Swarm based abilities.
Must invert healing portion of Life Drain based abilities.
Map contains the ability.
JASS:
library DamageSourceType /* v1.0.0.1
*************************************************************************************
*
* Able to retrieve
*
* Spell damage
* Physical Damage
* Code Damage (from allocateAttack in DamageEvent)
*
*************************************************************************************
*
* Credits
*
* looking_for_help
* -----------------------
*
* For idea of using spell damage reduction ability
*
*************************************************************************************
*
* */uses/*
*
* */ DamageEvent /* hiveworkshop.com/forums/jass-resources-412/snippet-damageevent-186829/
* */ AdvDamageEvent /* hiveworkshop.com/forums/jass-resources-412/extension-advanced-damage-event-213572/
*
************************************************************************************
*
* SETTINGS
*/
globals
constant integer ABILITIES_DAMAGE_SOURCE_TYPE_SPELL_REDUCTION = 'A002'
endglobals
/*
*************************************************************************************
*
* struct DamageSourceType extends array
*
* static constant integer PHYSICAL
* static constant integer SPELL
* static constant integer CODE
*
* DamageEvent (extends)
*
* readonly static DamageSourceType damageSourceType
*
*************************************************************************************/
struct DamageSourceType extends array
static constant integer PHYSICAL = 0
static constant integer SPELL = 1
static constant integer CODE = 2
endstruct
private module Init
private static method onInit takes nothing returns nothing
call init()
endmethod
endmodule
private struct AddAbility extends array
private static method onIndex takes nothing returns boolean
call UnitAddAbility(GetIndexedUnit(), ABILITIES_DAMAGE_SOURCE_TYPE_SPELL_REDUCTION)
call UnitMakeAbilityPermanent(GetIndexedUnit(), true, ABILITIES_DAMAGE_SOURCE_TYPE_SPELL_REDUCTION)
return false
endmethod
private static method init takes nothing returns nothing
local integer playerId
set playerId = 15
loop
call SetPlayerAbilityAvailable(Player(playerId), ABILITIES_DAMAGE_SOURCE_TYPE_SPELL_REDUCTION, false)
exitwhen 0 == playerId
set playerId = playerId - 1
endloop
call RegisterUnitIndexEvent(Condition(function thistype.onIndex), UnitIndexer.INDEX)
endmethod
implement Init
endstruct
//! textmacro DAMAGE_TYPE_EXT_FIELDS
readonly static DamageSourceType damageSourceType = 0
//! endtextmacro
//! textmacro DAMAGE_TYPE_EXT_LOCALS
local integer prevDamageSourceType = damageSourceType
//! endtextmacro
//! textmacro DAMAGE_TYPE_EXT
if (amount < 0) then
if (0 == damageType_p[runAttackCount_p]) then
set damageSourceType = DamageSourceType.SPELL
else
set damageSourceType = DamageSourceType.CODE
endif
set amount = -amount
elseif (0 == damageType_p[runAttackCount_p]) then
set damageSourceType = DamageSourceType.PHYSICAL
else
set damageSourceType = DamageSourceType.CODE
endif
//! endtextmacro
//! textmacro DAMAGE_TYPE_EXT_RESET
set damageSourceType = prevDamageSourceType
//! endtextmacro
endlibrary
Demonstration
JASS:
struct Test extends array
private static method onDamage takes nothing returns nothing
if (damageSourceType == DamageSourceType.SPELL) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,"Spell")
elseif (damageSourceType == DamageSourceType.PHYSICAL) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,"Physical")
else
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,"Code")
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,R2S(amount))
if (damageSourceType == DamageSourceType.SPELL) then
call allocateAttack(1, 0, 0)
call UnitDamageTarget(source, target, 50, true, false, null, DAMAGE_TYPE_UNIVERSAL, null)
endif
endmethod
implement DamageEvent
endstruct
Attachments
Last edited: