- Joined
- Jul 14, 2011
- Messages
- 3,213
The idea is that bombers can't have more bombs than intelligence placed at the same time. When Bombs > Intelligence the ability to place the bombs ('Absk') is disabled. This works perfectly when the bomber places a bomb, the ability is disabled, and when the bomb explodes, the ability is enabled again.
When a bomb is placed I do this
When a bomb dies, I do this.
If the bomber places a bomb in a forbidden place, the bomb is removed and the bomb count is reduced by 1, and, if the count is lower or equal than the intelligence, the BombPlace ability ('Absk') is enabled again for that player.
THE PROBLEM is that the ability isn't enabled if the bomber places the a bomb in a forbidden place, tough the bomb count is lower than the intelligence. I've tested with BJDebugMsg and Bomb = 0, and Int = 1, but ability isn't enabled
When a bomb is placed I do this
JASS:
// pi is the player number of the player
// u is the Bomber[pi]
set udg_PlayerBombs[pi] = udg_PlayerBombs[pi] + 1
if udg_PlayerBombs[pi] >= GetHeroInt(u, true) then
call SetPlayerAbilityAvailable(p, 'Absk', false)
endif
When a bomb dies, I do this.
JASS:
set udg_PlayerBombs[pi] = udg_PlayerBombs[pi] - 1
if udg_PlayerBombs[pi] <= GetHeroInt(udg_Bomber[pi], true) then
call SetPlayerAbilityAvailable(GetTriggerPlayer(), 'Absk', true)
endif
If the bomber places a bomb in a forbidden place, the bomb is removed and the bomb count is reduced by 1, and, if the count is lower or equal than the intelligence, the BombPlace ability ('Absk') is enabled again for that player.
THE PROBLEM is that the ability isn't enabled if the bomber places the a bomb in a forbidden place, tough the bomb count is lower than the intelligence. I've tested with BJDebugMsg and Bomb = 0, and Int = 1, but ability isn't enabled
JASS:
function Trig_Free_Center_Actions takes nothing returns nothing
local unit u = GetTriggerUnit() // The Bomb
local player p = GetOwningPlayer(u)
local integer pi = GetPlayerId(p) + 1
// udg_PlayerBombs[pi] is the player Bomber
call RemoveUnit(u)
call DisplayTimedTextToPlayer(p, 0, 0, 6, "|cffff0000Bombs can't be placed on this spot|r")
set udg_PlayerBombs[pi] = udg_PlayerBombs[pi] - 1
if udg_PlayerBombs[pi] <= GetHeroInt(udg_Bomber[pi], true) then
call SetPlayerAbilityAvailable(GetTriggerPlayer(), 'Absk', true)
endif
set u = null
set p = null
endfunction