function PlayerMsg takes player p, string s returns nothing
call DisplayTextToPlayer(p,0,0,s)
endfunction
Name | Type | is_array | initial_value |
==============================================================================
ITEM UPGRADING SYSTEM - Vulcansurge
==============================================================================
INTRODUCTION:
This system is used to upgrade items in your inventory, which was inspired by
Battle Tanks. Since my last version of this was completely GUI, and utterly
useless, I've decided to throw it out the window and start again, and here is
the result.
Basically, I'm now using all local variables, so no variables have to be
transferred to your map, which can often be annoying and confusing. Local
variables have also allowed my script to be fully MUI, and it executes faster
too.
IMPLEMENTATION:
To implement this into your map, follow the instructions below.
1. Save your project. If this code is implemented wrongly it will cause your
work to be lost when it comes to saving it.
2. Copy all the code in the custom script section (at the top of the list of
triggers) into your custom script section. This code is used to send the
player manipulating item, and your code wont work without this.
3. Copy one of the "UpgradeBasicXXXXXJASS" codes, it wont matter which one
you copy. Paste it into your map.
4. Scroll down in the newly copied trigger, and locate the description of the
UT, UL, and UC variables and change them according to the instructions.
5. Save your map. If an error message appears, you have implemented
incorrectly. You could try deleting all the code and doing it again or
reading the last two paragraphs in the section below.
6. If you have no errors, your code should now be working fine. Thanks for
using Vulcansurge's Item Upgrading System, please remember to give me
credit for using the system!
OTHER:
It is very easy to increase the amount of upgrades and the cost of each
upgrade, but always remember to paste more variables, otherwise you may find
that the system doesnt work.
A common problem that arises is that when you click the item, it isnt actively
used and the code wont run. To fix this, copy my spell "Dummy Active Ability"
and put it on each level of the item except the last level, to stop the last
level from upgrading (it shouldn't upgrade anyway, but as an extra measure).
You also need to make sure the "Stats - Actively Used" setting is set to true
when editing your items, again not on the last level.
Another common problem occurs when you change the name of the trigger. This is
easily fixable, just scroll down to the second bottom line and change the code
"Trig_<NAME OF TRIGGER>_Actions", then scroll to the line forth from the top,
and set the line "function Trig_<NAME OF TRIGGER>_Actions takes......"
If you have further problems, email me your map and I will TRY to fix it:
[email protected]
//============================================================================
// BASIC LASER
//============================================================================
function Trig_UpgradeBasicLaserJASS_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 //UT = TOTAL UPGRADES:
local integer array uc // - make sure to copy more rawcodes when
local integer array ul // adding more or less upgrades.
set ul[1]='I00H' //
set ul[2]='I00D' //UL = ITEM RAWCODES:
set ul[3]='I00E' // - use ctrl + d in item editor to find these.
set ul[4]='I00F' // - must use "I00X" format.
set ul[5]='I00G' //
set uc[1]=700 //UC = UPGRADE COSTS:
set uc[2]=800 // - there should be one less than the total
set uc[3]=900 // number of levels, because the last level
set uc[4]=1000 // is not upgradeable.
loop
set l=l+1
exitwhen l==ut
if (GetItemTypeId(i)==ul[l]) then
if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)>=uc[l]) then
call AdjustPlayerStateBJ(-uc[l],p, 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[(l+1)],u)
else
call PlayerMsg(p,"|cFF0000FFNote:|r You need more gold to upgrade this item")
endif
endif
endloop
endfunction
//===========================================================================
function InitTrig_UpgradeBasicLaserJASS takes nothing returns nothing
set gg_trg_UpgradeBasicLaserJASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UpgradeBasicLaserJASS, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddAction( gg_trg_UpgradeBasicLaserJASS, function Trig_UpgradeBasicLaserJASS_Actions )
endfunction
//============================================================================
// BASIC CANNON
//============================================================================
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 array uc //UT = TOTAL UPGRADES:
local integer array ul // - make sure to copy more rawcodes when
local integer ut = 5 // adding more or less upgrades.
set ul[1]='I004' //
set ul[2]='I009' //UL = ITEM RAWCODES:
set ul[3]='I00A' // - use ctrl + d in item editor to find these.
set ul[4]='I00B' // - must use "I00X" format.
set ul[5]='I003' //
set uc[1]=600 //UC = UPGRADE COSTS:
set uc[2]=700 // - there should be one less than the total
set uc[3]=800 // number of levels, because the last level
set uc[4]=900 // is not upgradeable.
loop
set l=l+1
exitwhen l==ut
if (GetItemTypeId(i)==ul[l]) then
if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)>=uc[l]) then
call AdjustPlayerStateBJ(-uc[l],p, 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[(l+1)],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
//============================================================================
// BASIC CANNON
//============================================================================
function Trig_UpgradeBasicPlasmaJASS_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 array uc //UT = TOTAL UPGRADES:
local integer array ul // - make sure to copy more rawcodes when
local integer ut = 5 // adding more or less upgrades.
set ul[1]='I00I' //
set ul[2]='I00J' //UL = ITEM RAWCODES:
set ul[3]='I00K' // - use ctrl + d in item editor to find these.
set ul[4]='I00L' // - must use "I00X" format.
set ul[5]='I00M' //
set uc[1]=800 //UC = UPGRADE COSTS:
set uc[2]=900 // - there should be one less than the total
set uc[3]=1000 // number of levels, because the last level
set uc[4]=1100 // is not upgradeable, in this case 4.
loop
set l=l+1
exitwhen l==ut
if (GetItemTypeId(i)==ul[l]) then
if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)>=uc[l]) then
call AdjustPlayerStateBJ(-uc[l],p, 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[(l+1)],u)
else
call PlayerMsg(p,"|cFF0000FFNote:|r You need more gold to upgrade this item")
endif
endif
endloop
endfunction
//===========================================================================
function InitTrig_UpgradeBasicPlasmaJASS takes nothing returns nothing
set gg_trg_UpgradeBasicPlasmaJASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UpgradeBasicPlasmaJASS, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddAction( gg_trg_UpgradeBasicPlasmaJASS, function Trig_UpgradeBasicPlasmaJASS_Actions )
endfunction