- Joined
- Mar 20, 2014
- Messages
- 67
Hey, I start an attack timer for 180 seconds, and at the end it's supposed to fire a trigger but it does nothing. Literally it's like the trigger isn't firing. Any help?
Here's the related two triggers.
Here's the related two triggers.
JASS:
function TrigAttackSubstr takes nothing returns nothing
local string subs = SubString(GetEventPlayerChatString(), 8, StringLength(GetEventPlayerChatString()))
local string array color
local integer i = 0
local integer stop = GetPlayers()
local integer p = GetPlayerId(GetTriggerPlayer())
local rect array areas
local texttag t
local timerdialog tim
local unit u
set areas[0] = gg_rct_Player_1_Area
set areas[1] = gg_rct_Player_2_Area
set areas[2] = gg_rct_Player_3_Area
set areas[3] = gg_rct_Player_4_Area
set areas[4] = gg_rct_Player_5_Area
set areas[5] = gg_rct_Player_6_Area
set color[0] = "red"
set color[1] = "blue"
set color[2] = "teal"
set color[3] = "purple"
set color[4] = "yellow"
set color[5] = "orange"
if (stop == 1 ) then
call DisplayTextToForce(bj_FORCE_PLAYER, "You don't have any enemies silly. Try the singleplayer attackers.")
else
loop
exitwhen i > stop
if (StringCase(subs, false) == StringCase(color[i], false)) and (IsAttacking == false) and (p != i) and (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) then
set IsAttacking = true
call SetCameraBoundsToRect(areas[i])
call SetCameraPosition(GetRectCenterX(areas[i]), GetRectCenterY(areas[i]))
set u = CreateUnit(GetTriggerPlayer(), 'h00E', GetRectCenterX(areas[i]), GetRectCenterY(areas[i]), GetRandomDirectionDeg())
call GroupAddUnit(AttackUnits, u)
call SelectUnitForPlayerSingle(u, Player(p))
set AttackTimer = CreateTimer()
set timdia = CreateTimerDialog(AttackTimer)
set timdia = CreateTimerDialogBJ( AttackTimer, "Time Remaining to Attack: " )
call TimerDialogDisplayForPlayerBJ( true, timdia, GetTriggerPlayer() )
set GoldAvail[i] = R2I((GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) * .2))
set LumbAvail[i] = R2I((GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_LUMBER) * .2))
call TimerStart(AttackTimer, 20, false, null)
call SavePlayerHandle(MUAC, 22, GetHandleId(AttackTimer), GetTriggerPlayer())
call SavePlayerHandle(MUAC, 23, GetHandleId(AttackTimer), Player(i))
call BJDebugMsg(I2S(p))
call BJDebugMsg(I2S(i))
set PlayerCurBuildDestroyed[i] = 0
set i = stop + 1
endif
set i = i + 1
endloop
endif
endfunction
//===========================================================================
function InitTrig_Attack takes nothing returns nothing
local integer i = 0
local integer stop = GetPlayers()
set gg_trg_Attack = CreateTrigger( )
loop
call TriggerRegisterPlayerChatEvent( gg_trg_Attack, Player(i), "-attack ", false )
set i = i + 1
exitwhen i == stop
endloop
call TriggerAddAction( gg_trg_Attack, function TrigAttackSubstr)
endfunction
JASS:
function killall takes nothing returns nothing
local unit u = GetEnumUnit()
call KillUnit(u)
call GroupRemoveUnit(AttackUnits[GetPlayerId(GetOwningPlayer(u))], u)
call GroupRemoveUnit(ArmyUnits[GetPlayerId(GetOwningPlayer(u))], u)
set u = null
endfunction
function ResetAnimation takes nothing returns nothing
local unit u
if (IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE)) then
set u = GetEnumUnit()
call SetUnitAnimation(u, "stand work")
call UnitRemoveAbility(u, 'Abun')
call SetUnitPathing( GetEnumUnit(), true)
call SetUnitInvulnerable(u, false)
call SetWidgetLife(u, GetUnitState(u, UNIT_STATE_MAX_LIFE))
call GroupRemoveUnit(AttackedUnits[GetPlayerId(GetOwningPlayer(u))], u)
set u = null
endif
endfunction
function TimerExpire takes nothing returns nothing
local player d = LoadPlayerHandle(MUAC, 22, GetHandleId(GetExpiredTimer()))
local integer z = GetPlayerId(d)
local integer p = GetPlayerId(LoadPlayerHandle(MUAC, 23, GetHandleId(GetExpiredTimer())))
local integer bhealer = 'h00X'
local rect array areas
set areas[0] = gg_rct_Player_1_Area
set areas[1] = gg_rct_Player_2_Area
set areas[2] = gg_rct_Player_3_Area
set areas[3] = gg_rct_Player_4_Area
set areas[4] = gg_rct_Player_5_Area
set areas[5] = gg_rct_Player_6_Area
call DisplayTextToForce(bj_FORCE_PLAYER[z], "Congratulations you've pillaged lumber and gold from your enemy!")
call SetCameraBoundsToRectForPlayerBJ(Player(z), areas[z])
call SetCameraPositionForPlayer(Player(z), GetRectCenterX(areas[z]), GetRectCenterY(areas[z]))
call ForGroup(AttackedUnits, function ResetAnimation)
call DestroyTimerDialog(timdia[z])
set IsAttacking[z] = false
call DestroyTimer(AttackTimer[z])
call ForGroup(AttackUnits[z], function killall)
endfunction
//===========================================================================
function InitTrig_Timer_Expires takes nothing returns nothing
set gg_trg_Timer_Expires = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Timer_Expires, AttackTimer[0] )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Timer_Expires, AttackTimer[1] )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Timer_Expires, AttackTimer[2] )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Timer_Expires, AttackTimer[3] )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Timer_Expires, AttackTimer[4] )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Timer_Expires, AttackTimer[5] )
call TriggerAddAction( gg_trg_Timer_Expires, function TimerExpire )
endfunction
Last edited by a moderator: