- Joined
- Dec 2, 2016
- Messages
- 733
So the following checks if the triggering unit 'Attacked unit' is Player 2(Teal)
Checks if the attacker is not equal to the triggering unit.
It then checks if the unit type of the attacker is not equal to the listed unit types.
Now all this works and runs, but the issue I'm having is the 'preventAttack' function.
What I want this code to do is that if any of the 3 regions contain a 'Flag' unit or the 'TriggeringUnit' then prevent the attacking units attack.
What happens right now is it only prevents the 'AttackingUnit's attack if the region the 'TriggeringUnit' is in also contains the 'Flag' unit. I need to prevent the attack if like said above ^ any of the 3 regions contain both the triggering unit and the flag. Doesn't need to be in the same region only that at least 1 of the regions contains the flag, and one of the regions contains the triggering unit. I'm not sure how to fix this, if you could help would be much appreciated. Thanks.
Entire code below:
Checks if the attacker is not equal to the triggering unit.
It then checks if the unit type of the attacker is not equal to the listed unit types.
Now all this works and runs, but the issue I'm having is the 'preventAttack' function.
What I want this code to do is that if any of the 3 regions contain a 'Flag' unit or the 'TriggeringUnit' then prevent the attacking units attack.
What happens right now is it only prevents the 'AttackingUnit's attack if the region the 'TriggeringUnit' is in also contains the 'Flag' unit. I need to prevent the attack if like said above ^ any of the 3 regions contain both the triggering unit and the flag. Doesn't need to be in the same region only that at least 1 of the regions contains the flag, and one of the regions contains the triggering unit. I'm not sure how to fix this, if you could help would be much appreciated. Thanks.
JASS:
function preventAttack takes nothing returns nothing
if (( RectContainsUnit(gg_rct_Base01a, GetTriggerUnit()) == true and RectContainsUnit(gg_rct_Base01a, GetEnumUnit()) == true) or (RectContainsUnit(gg_rct_Base02a, GetTriggerUnit()) == true and RectContainsUnit(gg_rct_Base02a, GetEnumUnit()) == true) or (RectContainsUnit(gg_rct_Base03a, GetTriggerUnit()) == true and RectContainsUnit(gg_rct_Base03a, GetEnumUnit()) == true))then
call DisplayTextToForce( GetPlayersAll(), "Stop" )
call PauseUnitBJ( true, GetAttacker() )
call IssueImmediateOrderBJ( GetAttacker(), "stop" )
call PauseUnitBJ( false, GetAttacker() )
else
endif
endfunction
Entire code below:
JASS:
scope fixTeal initializer registerFix
globals
endglobals
function preventAttack takes nothing returns nothing
if (( RectContainsUnit(gg_rct_Base01a, GetTriggerUnit()) == true and RectContainsUnit(gg_rct_Base01a, GetEnumUnit()) == true) or (RectContainsUnit(gg_rct_Base02a, GetTriggerUnit()) == true and RectContainsUnit(gg_rct_Base02a, GetEnumUnit()) == true) or (RectContainsUnit(gg_rct_Base03a, GetTriggerUnit()) == true and RectContainsUnit(gg_rct_Base03a, GetEnumUnit()) == true))then
call DisplayTextToForce( GetPlayersAll(), "Stop" )
call PauseUnitBJ( true, GetAttacker() )
call IssueImmediateOrderBJ( GetAttacker(), "stop" )
call PauseUnitBJ( false, GetAttacker() )
else
endif
endfunction
function mainMain takes nothing returns nothing
if (GetOwningPlayer(GetTriggerUnit()) == Player(2) and GetOwningPlayer(GetAttacker()) != GetOwningPlayer(GetTriggerUnit()) ) then
if (GetUnitTypeId(GetAttacker()) != 'U007' and GetUnitTypeId(GetAttacker()) != 'U008' and GetUnitTypeId(GetAttacker()) != 'E002' and GetUnitTypeId(GetAttacker()) != 'E001' and GetUnitTypeId(GetAttacker()) != 'AVFV') then
call ForGroupBJ( GetUnitsOfPlayerAndTypeId(GetOwningPlayer(GetTriggerUnit()), 'hFlg'), function preventAttack )
endif
endif
endfunction
function registerFix takes nothing returns nothing
local trigger TealFix = CreateListedTrigger()
set TealFix = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( TealFix, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( TealFix, function mainMain)
endfunction
endscope