• 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.

sell item with an ability

Status
Not open for further replies.
Level 9
Joined
Jul 10, 2011
Messages
562
hey all :D

i wanna add a spell to my heroes so they can sell items they own directly and without running to shops but i have no idea how to get the gold costs without setting every items gold costs in a hash and calling them from there.

anyone has a way to get the gold costs directly?


thanks in advance

greetz clapto
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I just checked out Nestharus' system and based on that idea, created this (does not require JNGP):

JASS:
function GetItemCost takes item i, string s returns integer
    local integer itemId = GetItemTypeId(i)
    
    call SetPlayerState( Player(14), PLAYER_STATE_RESOURCE_GOLD, 1000000 )
    call SetPlayerState( Player(14), PLAYER_STATE_RESOURCE_LUMBER, 1000000 )
    
    call AddItemToStock( udg_dummyItemCost, itemId, 1, 1 )
    call IssueNeutralImmediateOrderById( Player(14), udg_dummyItemCost, itemId )
    call RemoveItemFromStock( udg_dummyItemCost, itemId )
    
    if s == "gold" then
        return 1000000 - GetPlayerState( Player(14), PLAYER_STATE_RESOURCE_GOLD )
    elseif s == "lumber" or s == "wood" then
        return 1000000 - GetPlayerState( Player(14), PLAYER_STATE_RESOURCE_LUMBER )
    else
        call BJDebugMsg( "Invalid input: GetItemCost( item, " + s + " )" )
        return 0
    endif
endfunction

It gets the cost of all items you want with the use of a singly dummy.
You can call it like this:
JASS:
set GoldCost = GetItemCost( item, "gold" )
set WoodCost = GetItemCost( item, "lumber" ) // or set i = GetItemCost( item, "wood" )

Add the script to the header, copy/paste the dummy and you're all set (I hope :D).
Test-map attached
 

Attachments

  • GetItemCost.w3x
    13.9 KB · Views: 31
Status
Not open for further replies.
Top