Hello y'all, I've done my hero-pick system: You 'buy' a hero from a 'tavern'. The problem is: the repick system. It's basically simple: you remove your current hero from the game and create another unit to buy another hero. This may sound stupid: I can't re-buy a hero I just picked. For example, I bought an 'Archer' and typed '-repick'. The code creates another unit on the area (so I can buy another hero) and I can chose any hero except the one I repicked. It's not a big deal, and I hope I can fix it, if anybody can help me
EDIT: all globals are declared. some in other triggers (thats the reason i dont paste them)
EDIT EDIT: the code works properly. I just can't pick the hero I've already picked.
JASS:
private function Repick takes nothing returns nothing
local real x = GetRectCenterX(gg_rct_heropickarea)
local real y = GetRectCenterY(gg_rct_heropickarea)
local player p = GetTriggerPlayer()
local integer i = GetPlayerId(p)
local integer ih = 0
local unit u = CreateUnit(p, 'e000', x, y, 0)
call RemoveUnit(Hero[i])
set FOG[i] = CreateFogModifierRect(p, FOG_OF_WAR_VISIBLE, gg_rct_heropickarea, false, true)
call FogModifierStart(FOG[i])
call SetUnitAnimation(u, "birth")
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(u, true)
call Refresh()
endif
loop
call SetPlayerTechMaxAllowed(p, Code[ih], 1)
exitwhen ih >= Count - 1
set ih = ih + 1
endloop
set u = null
set p = null
endfunction
private function onInit takes nothing returns nothing
local player p
local integer i = 0
local trigger rp = CreateTrigger()
call TriggerAddAction(rp, function Repick)
loop
set p = Player(i)
call TriggerRegisterPlayerChatEvent(rp, p, "-repick", true)
call TriggerRegisterPlayerUnitEvent(tr, p, EVENT_PLAYER_HERO_LEVEL, null)
exitwhen i >= 9
set i = i + 1
endloop
endfunction
EDIT: all globals are declared. some in other triggers (thats the reason i dont paste them)
EDIT EDIT: the code works properly. I just can't pick the hero I've already picked.
Last edited: