Troll-Brain
You can change this now in User CP.
- Reaction score
- 85
Oh so it's a personal system, not a public one
// It also provides a means to detect what type
// of damage was dealt, so long as all damage in your map is dealt using
// this system's deal damage functions (except for basic attacks).
scope RemoveItemDamageBuff initializer OnInit
globals
private constant integer BONUS_ABIL=039;A00X039;
endglobals
private function OnDamage takes nothing returns boolean
if Damage_IsAttack() then
call UnitRemoveAbility(GetEventDamageSource(),ABIL)
endif
return false
endfunction
private function OnInit takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerAddCondition(t,Filter(function OnDamage))
call Damage_RegisterEvent(t)
endfunction
endscope
Physycal(hero,target,200.00,ATTACK_TYPE_NORMAL,true,false)
//pay attention to the last 2 parameters
// function Damage_IsAttack takes nothing returns boolean
// - Checks if the damage is from a physical attack (so you can deal
// physical damage without it being registered as an actual attack).
// function Damage_Physical takes unit source, unit target, real amount,
// attacktype whichType, boolean attack, boolean ranged returns boolean
// - A clean wrapper for physical damage.
// - 'attack' determines if this is to be treated as a real physical
// attack or just physical type damage.
// - 'ranged' determines if this is to be treated as a ranged or melee
// attack.
Two things.Could you make a function or two that allows different types of damage to deal different damage to different types of armor?
While I can't really say because I'm not using Damage, I'm confused because I thought that 0 damage spells were the entire foundation of how to use Damage in a map to discern between attacks and spells.Does anyone have problem with my removing it? I'd always intended to take it out...
That's like saying Magic Numbers are a better solution than labelled constants.Anyways, I still think you should add priority events to Event. This thing that guy is asking is perfectly possible with Rising_Dusks damage detection system, just because of priority events, and it would be shame if this could not do that stuff too.
library ArmorTypes
globals
private hashtable Store=InitHashtable()
private constant key ARMOR_TYPE
private constant key DAMAGE_TYPE
endglobals
function SetUnitTypeArmor takes integer unitType, integer armorType returns nothing
call SaveInteger(Store,unitType,ARMOR_TYPE,armorType)
endfunction
function SetUnitTypeDamage takes integer unitType, integer damageType returns nothing
call SaveInteger(Store,unitType,DAMAGE_TYPE,damageType)
endfunction
function SetDamageArmorFactor takes integer damageType, integer armorType, real factor returns nothing
call SaveReal(Store,damageType,armorType,factor)
endfunction
private function GetUnitArmor takes unit u returns integer
return LoadInteger(Store,GetUnitTypeId(u),ARMOR_TYPE)
endfunction
private function GetUnitDamage takes unit u returns integer
return LoadInteger(Store,GetUnitTypeId(u),DAMAGE_TYPE)
endfunction
private function GetDamageArmorFactor takes integer damageType, integer armorType returns real
return LoadReal(Store,damageType,armorType)
endfunction
private function GetUnitToUnitFactor takes unit source, unit target returns real
return GetDamageArmorFactor(GetUnitDamage(source),GetUnitArmor(target))
endfunction
//globals
// boolean Damage_IsSpecial=false
//endglobals
function DealDamage takes unit source, unit target, real amount returns nothing
//set Damage_IsSpecial=true // so you could lifesteal on special damage being dealt.
call Damage_Pure(source,target,amount*GetUnitToUnitFactor(source,target))
//set Damage_IsSpecial=false
endfunction
private function OnDamage takes nothing returns boolean
if Damage_IsAttack() then
call Damage_BlockAll()
call DealDamage(GetEventDamageSource(),GetTriggerUnit(),GetEventDamage())
endif
return false
endfunction
private struct Init extends array
private static method onInit takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerAddCondition(t,Filter(function OnDamage))
call Damage_RegisterEvent(t)
endmethod
endstruct
endlibrary
library Logic
globals
Event EvasionCheck // Event priorities without magic numbers.
Event ResistanceCheck
Event BlockCheck
Event LifestealCheck
endglobals
globals
private real CurrentDamage
endglobals
function CancelDamage takes nothing returns nothing
set CurrentDamage=0
endfunction
function ReduceDamage takes real amount returns nothing
set CurrentDamage=CurrentDamage-amount
endfunction
function GetCurrentDamage takes nothing returns real
return CurrentDamage
endfunction
private function OnDamage takes nothing returns boolean
if Damage_IsAttack() then
set CurrentDamage=GetEventDamage()
call Damage_BlockAll()
if CurrentDamage>0 then
call EvasionCheck.fire()
if CurrentDamage>0 then
call ResistanceCheck.fire()
if CurrentDamage>0 then
call BlockCheck.fire()
if CurrentDamage>0 then
call LifestealCheck.fire()
call Damage_Pure(GetEventDamageSource(),GetTriggerUnit(),CurrentDamage)
endif
endif
endif
endif
endif
return false
endfunction
private struct Init extends array
private static method onInit takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerAddCondition(t,Filter(function OnDamage))
call Damage_RegisterEvent(t)
set EvasionCheck=Event.create()
set ResistanceCheck=Event.create()
set BlockCheck=Event.create()
set LifestealCheck=Event.create()
endmethod
endstruct
endlibrary
Well, detecting 0 damage is only needed on projectile spells, and isn't a guarantee of which spell actually hit the unit. I'm willing to revert this if I'm denying people functionality, though. It's just there's no way to stop faerie fire from counting as a physical attack dealing 0 damage...While I can't really say because I'm not using Damage, I'm confused because I thought that 0 damage spells were the entire foundation of how to use Damage in a map to discern between attacks and spells.