- Joined
- Sep 9, 2007
- Messages
- 6,759
I've made a creep deny system but it does not work right..
I use JNGP.
When I load my map with this trigger I come back to the wc3 mainscreen on maptest.
I use JNGP.
When I load my map with this trigger I come back to the wc3 mainscreen on maptest.
JASS:
globals
real G_MISC_CDS_Health
real G_MISC_CDS_Exp
integer G_MISC_CDS_Gold
endglobals
function CDS_Death_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit a = GetKillingUnit()
local player p = GetOwningPlayer(a)
call DisplayTextToPlayer(p,0,0,"Deny!")
endfunction
function CDS_Att_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit a = GetAttacker()
local real l = GetUnitState(u, UNIT_STATE_LIFE)
local real ml = GetUnitState(u, UNIT_STATE_MAX_LIFE)
local real p = 0.00
if (u == null) or (ml == 0) then
set p = 0.0
else
set p = l / ml * 100.0
endif
if (p > G_MISC_CDS_Health) then
call IssueImmediateOrder(a,"stop")
endif
set u = null
set a = null
endfunction
function CDS_Death_Conditions takes nothing returns boolean
return IsPlayerAlly(GetOwningPlayer(GetKillingUnit()),GetOwningPlayer(GetTriggerUnit())) == true
endfunction
function CDS_Att_Conditions takes nothing returns boolean
return IsPlayerAlly(GetOwningPlayer(GetKillingUnit()),GetOwningPlayer(GetTriggerUnit())) == true
endfunction
function Init_CDS_Actions takes nothing returns nothing
local trigger t
local trigger d
set G_MISC_CDS_Health = 15
set G_MISC_CDS_Exp = 5
set G_MISC_CDS_Gold = 0
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition(t, Condition(function CDS_Att_Conditions))
call TriggerAddAction( t, function CDS_Att_Actions )
set d = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition(d, Condition(function CDS_Death_Conditions))
call TriggerAddAction( d, function CDS_Death_Actions )
endfunction
//===========================================================================
function InitTrig_CDS takes nothing returns nothing
local trigger gg_trg_CDS = CreateTrigger( )
call TriggerAddAction( gg_trg_CDS, function Init_CDS_Actions )
endfunction