• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Attribute Purchase system

Status
Not open for further replies.
Here are the scripts that I made, for each Attribute, with a comment on how to modify them.

JASS:
function Trig_Buy_Strength_Actions takes nothing returns nothing
local integer gold //This is for subtracting and keeping track of the user's gold
local integer str // This is for modifying the attribute.
loop
exitwhen GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) < 250 //You can change 250 to whatever you want each charge to cost.
set gold = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) //Leave this line alone. Sets gold to their gold
call SetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, (gold - 250)) //Change the 250 to what you changed the other 250 to. This will subtract the gold
set str = (GetHeroStr(udg_Hero[GetPlayerId(GetTriggerPlayer())], false) + 10) // This line needs some editing. Change "udg_Hero" hero to whatever your hero variable in your map is (You need one). Change + 10 to whatever increment you want each purchase to be.
call SetHeroStr(udg_Hero[GetPlayerId(GetTriggerPlayer())], str, true) // Leave this line alone. It sets their attribute to what it should be after purchase.
endloop
endfunction

//===========================================================================
function InitTrig_Buy_Strength takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent( t, Player(0), "-bs", true)
    call TriggerAddAction( t, function Trig_Buy_Strength_Actions )
    set t = null
endfunction
JASS:
function Trig_Buy_Agility_Actions takes nothing returns nothing
local integer gold //This is for subtracting and keeping track of the user's gold
local integer agi // This is for modifying the attribute.
loop
exitwhen GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) < 250 //You can change 250 to whatever you want each charge to cost.
set gold = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) //Leave this line alone. Sets gold to their gold
call SetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, (gold - 250)) //Change the 250 to what you changed the other 250 to. This will subtract the gold
set agi = (GetHeroAgi(udg_Hero[GetPlayerId(GetTriggerPlayer())], false) + 10) // This line needs some editing. Change "udg_Hero" hero to whatever your hero variable in your map is (You need one). Change + 10 to whatever increment you want each purchase to be.
call SetHeroAgi(udg_Hero[GetPlayerId(GetTriggerPlayer())], agi, true) // Leave this line alone. It sets their attribute to what it should be after purchase.
endloop
endfunction

//===========================================================================
function InitTrig_Buy_Agility takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent( t, Player(0), "-ba", true)
    call TriggerAddAction( t, function Trig_Buy_Agility_Actions )
    set t = null
endfunction
JASS:
function Trig_Buy_Intellect_Actions takes nothing returns nothing
local integer gold //This is for subtracting and keeping track of the user's gold
local integer int // This is for modifying the attribute.
loop
exitwhen GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) < 250 //You can change 250 to whatever you want each charge to cost.
set gold = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) //Leave this line alone. Sets gold to their gold
call SetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, (gold - 250)) //Change the 250 to what you changed the other 250 to. This will subtract the gold
set int = (GetHeroInt(udg_Hero[GetPlayerId(GetTriggerPlayer())], false) + 10) // This line needs some editing. Change "udg_Hero" hero to whatever your hero variable in your map is (You need one). Change + 10 to whatever increment you want each purchase to be.
call SetHeroInt(udg_Hero[GetPlayerId(GetTriggerPlayer())], int, true) // Leave this line alone. It sets their attribute to what it should be after purchase. 
endloop
endfunction

//===========================================================================
function InitTrig_Buy_Intellect takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent( t, Player(0), "-bi", true)
    call TriggerAddAction( t, function Trig_Buy_Intellect_Actions )
    set t = null
endfunction
 
Status
Not open for further replies.
Back
Top