im making a trigger that lets a player gamble.
the idea would be that when a player says gamble, one of his units is removed from the game, and he has a wins one of 5 types of units, 4 being heroes, and 1 being a footman. to gamble requires 500 gold, and u must have more than 1 unit.
the main problem is that the programs (JassCraft, and the actual Warcraft 3 editor) don't seem to read any variables. it keeps saying that variables are undefined. its not entirely done( i havent added in the part where it costs 500) because i like to take things one at a time...
any suggestions would be apreciated
Here is the actual thing:
the idea would be that when a player says gamble, one of his units is removed from the game, and he has a wins one of 5 types of units, 4 being heroes, and 1 being a footman. to gamble requires 500 gold, and u must have more than 1 unit.
the main problem is that the programs (JassCraft, and the actual Warcraft 3 editor) don't seem to read any variables. it keeps saying that variables are undefined. its not entirely done( i havent added in the part where it costs 500) because i like to take things one at a time...
any suggestions would be apreciated
Here is the actual thing:
JASS:
function gamble_Cond takes nothing returns boolean
if GetPlayerUnitCount(GetTriggerPlayer(), false) > 1 then
if GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) > 499 then
return true
else
call BJDebugMsg("sorry, not enough money kid")
return false
endif
else
call BJDebugMsg("sorry kid, you need more units")
return false
endif
endfunction
function gamble_actions takes nothing returns nothing
local unitpool randomUnit = CreateUnitPool()
call UnitPoolAddUnitType(randomUnit, 'H001', 1.00)
call UnitPoolAddUnitType(randomUnit, 'H000', 1.00)
call UnitPoolAddUnitType(randomUnit, 'H002', 1.00)
call UnitPoolAddUnitType(randomUnit, 'H003', 1.00)
call UnitPoolAddUnitType(randomUnit, 'hfoo', 4.00)
local player gambler = GetTriggerPlayer()
local unit removed = GroupPickRandomUnit(GetUnitsOfPlayerAll(u))
local location spwn = GetUnitLoc(removed)
call RemoveUnit(removed)
call PlaceRandomUnit(randomUnit, gambler, GetLocationX(spwn),GetLocationY(spwn), 0.00)
set gambler = null
set removed = null
call RemoveLocation(spwn)
call DestroyUnitPool(randomUnit)
endfunction
//=====================================================================
function InitTrig_Gamble takes nothing returns nothing
local trigger gamble_trig = CreateTrigger()
call TriggerRegisterPlayerChatEvent(gamble_trig, Player(0), "-gamble", true)
call TriggerRegisterPlayerChatEvent(gamble_trig, Player(1), "-gamble", true)
call TriggerRegisterPlayerChatEvent(gamble_trig, Player(2), "-gamble", true)
call TriggerRegisterPlayerChatEvent(gamble_trig, Player(3), "-gamble", true)
call TriggerAddCondition(gamble_trig, Condition(function gamble_Cond))
call TriggerAddAction(gamble_trig, function gamble_actions)
set gamble_trig = null
endfunction
Last edited: