- Joined
- May 25, 2009
- Messages
- 100
have Problem with one of my functions: When my Hero gets attacked, a timer starts and checks if there is an obstruction between the Hero and the Attacker.
I figured out the problem so far, that there is a Problem with the return from "global_collisioncheck" to the Trigger "UnitAttack".
I get the BJDebugMsg(GetUnitName(stunit)) but not the BJDebugMsg(I2S(collisionbool))...not even "0" or "Null"
But when i call "global_collisioncheck" with "SkipCinematic" everything is fine
The Triggers are not checked for leaks and stuff and thats schouldn't be the topic. I just want to know what's the problem and how to fix it (global Vars are not an option, 'cause the function schould run vor more than one unit at the time.)
Thanks for your help!
Cataract92
JASS:
function ordercollisioncheck takes nothing returns nothing
local timer t= GetExpiredTimer()
local unit stunit = LoadUnitHandle(udg_hashtable,GetHandleId(t),0)
local location heropos = GetUnitLoc(LoadUnitHandle(udg_hashtable,GetHandleId(udg_Hero),4))
local integer collisionbool =0
//call BJDebugMsg(GetUnitName(stunit))
set collisionbool = global_collisioncheck(stunit)
//call BJDebugMsg(I2S(collisionbool))
if collisionbool == 2 then
call IssuePointOrderLoc( LoadUnitHandle(udg_hashtable,GetHandleId(stunit),4), "move", heropos )
endif
endfunction
function Trig_UnitAttack_Conditions takes nothing returns boolean
return GetTriggerUnit()== LoadUnitHandle(udg_hashtable,GetHandleId(udg_Hero),4)
endfunction
function Trig_UnitAttack_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit stunit = LoadUnitHandle(udg_hashtable,GetHandleId(GetAttacker()),4)
call SaveUnitHandle(udg_hashtable,GetHandleId(t),0,stunit)
call TimerStart(t,0.5,true,function ordercollisioncheck)
endfunction
//===========================================================================
function InitTrig_UnitAttack takes nothing returns nothing
set gg_trg_UnitAttack = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_UnitAttack, Player(0), EVENT_PLAYER_UNIT_ATTACKED )
//call TriggerAddCondition( gg_trg_UnitAttack, Condition( function Trig_UnitAttack_Conditions ) )
call TriggerAddAction( gg_trg_UnitAttack, function Trig_UnitAttack_Actions )
endfunction
JASS:
function global_collisionchecktimer takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit stunit = LoadUnitHandle(udg_hashtable, GetHandleId(t), 0)
local unit dummy = LoadUnitHandle(udg_hashtable, GetHandleId(t), 1)
local real range = LoadReal(udg_hashtable, GetHandleId(t), 2)
local location heropos = GetUnitLoc(udg_Hero)
local location stunitpos = GetUnitLoc(stunit)
local location dummypos = GetUnitLoc(dummy)
call SaveReal(udg_hashtable, GetHandleId(t),2,range+30)
set range = LoadReal(udg_hashtable, GetHandleId(t), 2)
call SetUnitPositionLoc( dummy, PolarProjectionBJ(stunitpos, range, AngleBetweenPoints(stunitpos, heropos)) )
set dummypos = GetUnitLoc(dummy)
set stunituebergabe = stunit
call EnumDestructablesInCircleBJ( 60.00, dummypos, function lis_crouchcheck )
if (DistanceBetweenPoints(stunitpos, dummypos) > ( range + 1.00 ) or (DistanceBetweenPoints(stunitpos, dummypos)) < ( range - 1.00 )) and not LoadBoolean(udg_hashtable,GetHandleId(stunit),7) then
call SaveReal(udg_hashtable,GetHandleId(stunit),2,0.00)
call RemoveUnit(dummy)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hashtable,GetHandleId(t))
call SaveInteger(udg_hashtable,GetHandleId(t),2,2)
else
if DistanceBetweenPoints(heropos, dummypos) <= 20 then
if LoadBoolean(udg_hashtable,GetHandleId(stunit),7) and LoadBoolean(udg_hashtable,GetHandleId(udg_Hero),0) then
call SaveReal(udg_hashtable,GetHandleId(stunit),2,0.00)
call RemoveUnit(dummy)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hashtable,GetHandleId(t))
call SaveInteger(udg_hashtable,GetHandleId(t),2,2)
else
if IsUnitAliveBJ(stunit) then
call SaveReal(udg_hashtable,GetHandleId(stunit),2,0.00)
call RemoveUnit(dummy)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hashtable,GetHandleId(t))
call SaveInteger(udg_hashtable,GetHandleId(t),2,1)
else
call RemoveUnit(dummy)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hashtable,GetHandleId(t))
call SaveInteger(udg_hashtable,GetHandleId(t),2,2)
endif
endif
endif
endif
if range>721 then
//call BJDebugMsg("range reset")
call RemoveUnit(dummy)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hashtable,GetHandleId(t))
call SaveInteger(udg_hashtable,GetHandleId(t),2,2)
endif
//call BJDebugMsg(I2S(LoadInteger(udg_hashtable,GetHandleId(t),2)))
call RemoveLocation(heropos)
call RemoveLocation(stunitpos)
call RemoveLocation(dummypos)
endfunction
function global_collisioncheck takes unit stunit returns integer
local timer t= CreateTimer()
local location stunitpos = GetUnitLoc(stunit)
local unit dummy = CreateUnitAtLoc( Player(PLAYER_NEUTRAL_PASSIVE), 'e000', PolarProjectionBJ(stunitpos, 0, GetUnitFacing(stunit)), bj_UNIT_FACING )
local real range=0
call SaveInteger(udg_hashtable,GetHandleId(t),2,0)
call SaveBoolean(udg_hashtable,GetHandleId(stunit),7,false)
call SaveUnitHandle(udg_hashtable, GetHandleId(t), 0, stunit)
call SaveUnitHandle(udg_hashtable, GetHandleId(t), 1, dummy)
call SaveReal(udg_hashtable, GetHandleId(t),2,range)
call TimerStart(t, 0.01, true, function global_collisionchecktimer)
loop
call PolledWait(0.01)
exitwhen LoadInteger(udg_hashtable,GetHandleId(t),2) !=0
endloop
//call BJDebugMsg(I2S(LoadInteger(udg_hashtable,GetHandleId(t),2)))
return LoadInteger(udg_hashtable,GetHandleId(t),2)
endfunction
I figured out the problem so far, that there is a Problem with the return from "global_collisioncheck" to the Trigger "UnitAttack".
I get the BJDebugMsg(GetUnitName(stunit)) but not the BJDebugMsg(I2S(collisionbool))...not even "0" or "Null"
But when i call "global_collisioncheck" with "SkipCinematic" everything is fine
JASS:
function walkietalkie_Actions takes nothing returns nothing
call BJDebugMsg(I2S(global_collisioncheck(gg_unit_h002_0004)))
endfunction
//===========================================================================
function walkietalkie_Actions takes nothing returns nothing
call BJDebugMsg(I2S(global_collisioncheck(gg_unit_h002_0004)))
endfunction
//===========================================================================
function InitTrig_EscTest takes nothing returns nothing
set gg_trg_EscTest = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_EscTest, Player(0) )
call TriggerAddAction( gg_trg_EscTest, function walkietalkie_Actions )
endfunction
The Triggers are not checked for leaks and stuff and thats schouldn't be the topic. I just want to know what's the problem and how to fix it (global Vars are not an option, 'cause the function schould run vor more than one unit at the time.)
Thanks for your help!
Cataract92
Last edited: