Vulcansurge
Ultra Cool Member
- Reaction score
- 27
I just learnt JASS D part of the 'in' crowd now) and I've spent a few minutes working out how to write some script. Here is what I have:
Code:
// Change the variables in the starry box only.
function PlayerMsg takes player p, string s returns nothing
call DisplayTextToPlayer(p,0,0,s)
endfunction
function Trig_UpgradeBasicCannonJASS_Actions takes nothing returns nothing
local integer l = 0
local unit u = GetManipulatingUnit()
local item i = GetManipulatedItem()
local player p = GetOwningPlayer(u)
local item iu
//***************************************************************************
local integer ut = 5 //Total upgrades
local string array ul
set ul[1]="I00H" //Item Rawcodes (use ctrl+D in unit editor)
set ul[2]="I00D"
set ul[3]="I00E"
set ul[4]="I00F"
set ul[5]="I00G"
//***************************************************************************
loop
set l=l+1
exitwhen l==5
if (GetItemTypeId(i)==ul[I2S(l)]) then
if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)>=600) then
call AdjustPlayerStateBJ(-600,GetOwningPlayer(GetManipulatingUnit()), PLAYER_STATE_RESOURCE_GOLD)
call PlayerMsg(p,"|cFF0000FFNote:|r Your item is being upgraded")
call UnitRemoveItemSwapped(i,u)
call RemoveItem(i)
call UnitAddItemByIdSwapped('I00C',u)
set iu = GetLastCreatedItem()
call TriggerSleepAction(10.00)
call UnitRemoveItemSwapped(iu,u)
call RemoveItem(iu)
call UnitAddItemByIdSwapped(ul[I2S(l)],u)
else
call PlayerMsg(p,"|cFF0000FFNote:|r You need more gold to upgrade this item")
endif
endif
endloop
endfunction
//===========================================================================
function InitTrig_UpgradeBasicCannonJASS takes nothing returns nothing
set gg_trg_UpgradeBasicCannonJASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UpgradeBasicCannonJASS, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddAction( gg_trg_UpgradeBasicCannonJASS, function Trig_UpgradeBasicCannonJASS_Actions )
endfunction