- Joined
- Aug 17, 2007
- Messages
- 36
I've been looking forever for a damage detection system for a generic unit and found a guide here at:
http://www.hiveworkshop.com/forums/showthread.php?t=33123
My problem is, I've never really tried jass before. It's one of those things that I just never had enough time to learn. So I need help converting the final code he displayed in the tutorial to my own trigger. I would like it to do the following functions, as well as make it so only units who attack Player 12 will be effected by this trigger.
The GetEventDamage would be however much damage is taken away. I'm guessing my trigger would look something like this, but I'm not sure. Anyone with jass experience, please help as I'm at a loss when it comes to this stuff.
Any help would be appreciated.
Thanks for taking the time to read my problem!
[EDIT: I updated the trigger. The old trigger is in the spoiler box and the new trigger is shown.
http://www.hiveworkshop.com/forums/showthread.php?t=33123
My problem is, I've never really tried jass before. It's one of those things that I just never had enough time to learn. So I need help converting the final code he displayed in the tutorial to my own trigger. I would like it to do the following functions, as well as make it so only units who attack Player 12 will be effected by this trigger.
JASS:
call AdjustPlayerStateBJ( ( R2I([B]GetEventDamage[/B]()) / 5 ), GetOwningPlayer(GetAttacker()), PLAYER_STATE_RESOURCE_GOLD )
call CreateTextTagUnitBJ( ( "+" + I2S(( R2I([B]GetEventDamage[/B]()) / 5 )) ), GetAttacker(), 0, 10, 100, 100, 0.00, 0 )
call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), GetPlayersAll() )
call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), GetPlayersMatching(Condition(function Trig_Bounty_Func005003001)) )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 0.50 )
The GetEventDamage would be however much damage is taken away. I'm guessing my trigger would look something like this, but I'm not sure. Anyone with jass experience, please help as I'm at a loss when it comes to this stuff.
JASS:
function AttackTrigger_Conditions takes nothing returns boolean
if ( not ( GetOwningPlayer(GetAttackedUnitBJ()) == Player(11) ) ) then
return false
endif
return true
endfunction
function Trig_AttackTrigger_Func005003001 takes nothing returns boolean
return ( GetOwningPlayer(GetAttacker()) == GetFilterPlayer() )
endfunction
function AttackTrigger_Conditions takes nothing returns boolean
return GetHandleTrigger(GetAttacker(), "DamageTrig") == null and GetUnitAbilityLevel(GetAttacker(), 'A000') > 0
endfunction
function DamageTrigger_Conditions takes nothing returns boolean
return GetEventDamageSource() == GetHandleUnit(GetTriggeringTrigger(), "Attacker")
endfunction
function DamageTrigger_Actions takes nothing returns nothing
local unit AttackedUnit = GetTriggerUnit()
local unit AttackingUnit = GetEventDamageSource()
local trigger DamageTrigger = GetTriggeringTrigger()
call FlushHandleLocals(DamageTrigger)
call DestroyTrigger(DamageTrigger)
call SetHandleHandle(AttackingUnit, "DamageTrig", null)
//Here come the actions you want originally with the attacked/attacking unit.
call AdjustPlayerStateBJ( ( R2I(GetEventDamage()) / 5 ), GetOwningPlayer(GetAttacker()), PLAYER_STATE_RESOURCE_GOLD )
call CreateTextTagUnitBJ( ( "+" + I2S(( R2I(GetEventDamage()) / 5 )) ), GetAttacker(), 0, 10, 100, 100, 0.00, 0 )
call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), GetPlayersAll() )
call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), GetPlayersMatching(Condition(function Trig_AttackTrigger005003001)) )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 0.50 )
set DamageTrigger = null
set AttackingUnit = null
set AttackedUnit = null
endfunction
function AttackTrigger_Actions takes nothing returns nothing
local unit AttackingUnit = GetAttacker() //We store the attacking unit
local unit AttackedUnit = GetTriggerUnit() //We store the attacked unit - this one will take the damage
local trigger DamageTrigger = CreateTrigger() //We create the damage trigger
call SetHandleHandle(AttackingUnit, "DamageTrig", DamageTrigger)
call SetHandleHandle(DamageTrigger, "Attacker", AttackingUnit)
call TriggerRegisterUnitEvent(DamageTrigger, AttackedUnit, EVENT_UNIT_DAMAGED)
call TriggerAddCondition(DamageTrigger, Condition(function DamageTrigger_Conditions))
call TriggerAddAction(DamageTrigger, function DamageTrigger_Actions)
call TriggerSleepAction( ( ( ( ( 0.50 - 0.10 ) / ( 10.00 - 70.00 ) ) * I2R(GetHeroStatBJ(bj_HEROSTAT_AGI, GetAttacker(), true)) ) + ( 0.50 - ( ( ( 0.50 - 0.10 ) / ( 10.00 - 70.00 ) ) * 10.00 ) ) ) )
call FlushHandleLocals(DamageTrigger)
call DestroyTrigger(DamageTrigger)
call SetHandleHandle(AttackingUnit, "DamageTrig", null)
set DamageTrigger = null
set AttackingUnit = null
set AttackingUnit = null
endfunction
function InitTrig_AttackDamageDetection takes nothing returns nothing
local trigger AttackTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(AttackTrigger, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(AttackTrigger, Condition( function AttackTrigger_Conditions))
call TriggerAddAction(AttackTrigger, function AttackTrigger_Actions)
set AttackTrigger = null
endfunction
JASS:
function AttackTrigger_Conditions takes nothing returns boolean
if ( not ( GetOwningPlayer(GetAttackedUnitBJ()) == Player(11) ) ) then
return false
endif
return true
endfunction
function AttackTrigger_Conditions takes nothing returns boolean
return GetHandleTrigger(GetAttacker(), "DamageTrig") == null and GetUnitAbilityLevel(GetAttacker(), 'A000') > 0
endfunction
function DamageTrigger_Conditions takes nothing returns boolean
return GetEventDamageSource() == GetHandleUnit(GetTriggeringTrigger(), "Attacker")
endfunction
function DamageTrigger_Actions takes nothing returns nothing
local unit AttackedUnit = GetTriggerUnit()
local unit AttackingUnit = GetEventDamageSource()
local trigger DamageTrigger = GetTriggeringTrigger()
call FlushHandleLocals(DamageTrigger)
call DestroyTrigger(DamageTrigger)
call SetHandleHandle(AttackingUnit, "DamageTrig", null)
//Here come the actions you want originally with the attacked/attacking unit.
call UnitDamageTarget(AttackingUnit, AttackedUnit, GetEventDamage(), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
set DamageTrigger = null
set AttackingUnit = null
set AttackedUnit = null
endfunction
function AttackTrigger_Actions takes nothing returns nothing
local unit AttackingUnit = GetAttacker() //We store the attacking unit
local unit AttackedUnit = GetTriggerUnit() //We store the attacked unit - this one will take the damage
local trigger DamageTrigger = CreateTrigger() //We create the damage trigger
call SetHandleHandle(AttackingUnit, "DamageTrig", DamageTrigger)
call SetHandleHandle(DamageTrigger, "Attacker", AttackingUnit)
call TriggerRegisterUnitEvent(DamageTrigger, AttackedUnit, EVENT_UNIT_DAMAGED)
call TriggerAddCondition(DamageTrigger, Condition(function DamageTrigger_Conditions))
call TriggerAddAction(DamageTrigger, function DamageTrigger_Actions)
call AdjustPlayerStateBJ( ( R2I(GetEventDamage()) / 5 ), GetOwningPlayer(GetAttacker()), PLAYER_STATE_RESOURCE_GOLD )
call CreateTextTagUnitBJ( ( "+" + I2S(( R2I(GetEventDamage()) / 5 )) ), GetAttacker(), 0, 10, 100, 100, 0.00, 0 )
call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), GetPlayersAll() )
call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), GetPlayersMatching(Condition(function Trig_AttackTrigger005003001)) )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 0.50 )
call TriggerSleepAction( ( ( ( ( 0.50 - 0.10 ) / ( 10.00 - 70.00 ) ) * I2R(GetHeroStatBJ(bj_HEROSTAT_AGI, GetAttacker(), true)) ) + ( 0.50 - ( ( ( 0.50 - 0.10 ) / ( 10.00 - 70.00 ) ) * 10.00 ) ) ) )
call FlushHandleLocals(DamageTrigger)
call DestroyTrigger(DamageTrigger)
call SetHandleHandle(AttackingUnit, "DamageTrig", null)
set DamageTrigger = null
set AttackingUnit = null
set AttackingUnit = null
endfunction
function InitTrig_AttackDamageDetection takes nothing returns nothing
local trigger AttackTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(AttackTrigger, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(AttackTrigger, Condition( function AttackTrigger_Conditions))
call TriggerAddAction(AttackTrigger, function AttackTrigger_Actions)
set AttackTrigger = null
endfunction
Any help would be appreciated.
Thanks for taking the time to read my problem!
[EDIT: I updated the trigger. The old trigger is in the spoiler box and the new trigger is shown.
Last edited: