Item and Unit Cost System v1.0.1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: Kazeon and IcemanBo
This system can get the gold and lumber costs of items and units. It can also get the food cost of units.

This system brings those things to users that still use GUI and / or jass.

  • Example Trigger
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Custom script: set udg_tempStr1 = I2S( RCSGetItemGoldCost( GetManipulatedItem()))
      • Custom script: set udg_tempStr2 = I2S( RCSGetItemLumberCost( GetManipulatedItem()))
      • Game - Display to (All players) the text: (The costs of the item + ((Name of (Item being manipulated)) + are ))
      • Game - Display to (All players) the text: (Gold = + tempStr1)
      • Game - Display to (All players) the text: (Lumber = + tempStr2)
  • Item and unit GAL variables
    • Events
    • Conditions
    • Actions
      • Set RCSHashtable = (Last created hashtable)
      • Set RCSItemAUnitGALFoodCapMax = 0
      • Set RCSItemAUnitGALMerchant = No unit
      • Set RCSItemAUnitGALSpawnX = 0.00
      • Set RCSItemAUnitGALSpawnY = 0.00
  • ItemAndUnitGoldAndLumberCostSetup
    • Events
    • Conditions
    • Actions
      • -------- --------
      • Custom script: endfunction
      • -------- --------
      • -------- --------
      • Custom script: function RCSItemAUnitGALRegisterRegion takes nothing returns nothing
      • -------- --------
      • -------- This variable is used to set the region that the Merchant unit will be placed. --------
      • -------- Make sure this region is the same size or bigger than the one in the test map. --------
      • -------- Also make sure it is inaccessible to other players units. --------
      • Set RCSItemAUnitGALRegionSpawn = Region 000 <gen>
      • -------- --------
      • -------- This variable is used to set the Merchant that needs to be placed. For the system to work. --------
      • -------- Make sure to add the same abilities as my modified marketplace has. --------
      • -------- Also make sure it is inaccessible to other players units. --------
      • Set RCSItemAUnitGALMerchantId = Marketplace
      • -------- --------
      • Custom script: endfunction
      • -------- --------
      • -------- --------
      • Custom script: function RCSItemAUnitGALPauseSystems takes nothing returns nothing
      • -------- --------
      • -------- Put all systems that need to be paused in here. Like the unit indexer by bribe. --------
      • Custom script: endfunction
      • -------- --------
      • -------- --------
      • Custom script: function RCSItemAUnitGALUnPauseSystems takes nothing returns nothing
      • -------- --------
      • -------- Put all systems that need to be unpaused in here. Like the unit indexer by bribe. --------
JASS:
    //      Item / Unit Gold Lumber and Food Cost 
    //      Version 1.0.1.0 by deathismyfriend

    //     Function List
    //
    //     ITEM FUNCTIONS
    //
    //
    //  This function is for getting an items gold cost by using the item itself.
    //  function RCSGetItemGoldCost takes item itm returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetItemGoldCost( udg_tempItem)
    //  
    //  
    //  This function is for getting an items lumber cost by using the item itself.
    //  function RCSGetItemLumberCost takes item itm returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetItemLumberCost( udg_tempItem)
    //  
    //  
    //  This function is for getting an items food cost by using the item itself.
    //  function RCSGetItemFoodCost takes item itm returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetItemFoodCost( udg_tempItem)
    //  
    //  
    //  This function is for getting an items food cap cost by using the item itself.
    //  function RCSGetItemFoodCap takes item itm returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetItemFoodCap( udg_tempItem)
    //  
    //  
    //  This function is for getting an items initial charges. 
    //  The initial charges are the charges it starts with when the item is created.
    //  function RCSGetItemInitialCharges takes item itm returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetItemInitialCharges( udg_tempItem)
    //
    //     UNIT FUNCTIONS
    //  
    //  
    //  This function is for getting a units gold cost by using the unit itself.
    //  function RCSGetUnitGoldCost takes unit u returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitGoldCost( udg_tempUnit)
    //
    //
    //  This function is for getting a units gold cost by using the units type id.
    //  function RCSGetUnitGoldCostById takes integer id returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitGoldCostById( udg_tempUnitType)
    //  
    //  
    //  This function is for getting a units lumber cost by using the unit itself.
    //  function RCSGetUnitLumberCost takes unit u returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitLumberCost( udg_tempUnit)
    //
    //
    //  This function is for getting a units lumber cost by using the units type id.
    //  function RCSGetUnitLumberCostById takes integer id returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitLumberCostById( udg_tempUnitType)
    //  
    //  
    //  This function is for getting a units food cost by using the unit itself.
    //  function RCSGetUnitFoodCosttakes unit u returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitFoodCost( udg_tempUnit)
    //
    //
    //  This function is for getting a units food cost by using the units type id.
    //  function RCSGetUnitFoodCostById takes integer id returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitFoodCostById( udg_tempUnitType)
    //  
    //  
    //  This function is for getting a units food cap by using the unit itself.
    //  function RCSGetUnitFoodCap takes unit u returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitFoodCap( udg_tempUnit)
    //
    //
    //  This function is for getting a units food cap by using the units type id.
    //  function RCSGetUnitFoodCapById takes integer id returns integer
    //  To use this use the custom script below. ( You can Copy and Paste it.)
    //  Custom script: RCSGetUnitFoodCapById( udg_tempUnitType)
    //  
    //  
    
    
    function RCSItemAUnitGALCleanupItems takes nothing returns nothing // This cleans up the items sold to get the prices.
        call RemoveItem( GetEnumItem())
    endfunction
        
    function RCSStoreItemCosts takes integer id returns nothing
        local player p = Player(PLAYER_NEUTRAL_PASSIVE)
        local integer playerG = GetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD)
        local integer playerL = GetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER)
        local integer playerFC = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP)
        local integer playerFU = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED)
        local integer foodCap
        local item itm = CreateItem( id, udg_RCSItemAUnitGALSpawnX, udg_RCSItemAUnitGALSpawnY)
        local integer charges = GetItemCharges(itm)
        call RemoveItem(itm)
        set itm = null
        call RCSItemAUnitGALPauseSystems()
        
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD, 1000000)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER, 1000000)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP, udg_RCSItemAUnitGALFoodCapMax)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED, 0)
        call AddItemToStock( udg_RCSItemAUnitGALMerchant, id, 1, 1)
        call IssueNeutralImmediateOrderById( p, udg_RCSItemAUnitGALMerchant, id)
        call RemoveItemFromStock( udg_RCSItemAUnitGALMerchant, id)
        
        set foodCap = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP) - udg_RCSItemAUnitGALFoodCapMax
        
        set id = id * -1
        call SaveInteger( udg_RCSHashtable, 0, id, ( 1000000 - GetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD)) / charges)
        call SaveInteger( udg_RCSHashtable, 1, id, ( 1000000 - GetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER)) / charges)
        call SaveInteger( udg_RCSHashtable, 2, id, ( GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED)) / charges)
        call SaveInteger( udg_RCSHashtable, 3, id, foodCap / charges)
        call SaveInteger( udg_RCSHashtable, 4, id, charges)
            
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD, playerG)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER, playerL)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP, playerFC + foodCap)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED, playerFU)
        
        call EnumItemsInRect( udg_RCSItemAUnitGALRegionSpawn , null, function RCSItemAUnitGALCleanupItems)
        
        call RCSItemAUnitGALUnPauseSystems()
        set p = null
    endfunction
    
    function RCSStoreUnitCosts takes integer id returns nothing
        local player p = Player(PLAYER_NEUTRAL_PASSIVE)
        local integer playerG = GetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD)
        local integer playerL = GetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER)
        local integer playerFC = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP)
        local integer playerFU = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED)
        local integer foodCap
        call RCSItemAUnitGALPauseSystems()
        
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD, 1000000)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER, 1000000)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP, udg_RCSItemAUnitGALFoodCapMax)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED, 0)
        call AddUnitToStock( udg_RCSItemAUnitGALMerchant, id, 1, 1)
        call IssueNeutralImmediateOrderById( p, udg_RCSItemAUnitGALMerchant, id)
        call RemoveUnitFromStock( udg_RCSItemAUnitGALMerchant, id)
        
        set foodCap = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP) - udg_RCSItemAUnitGALFoodCapMax
        set id = id * -1
        call SaveInteger( udg_RCSHashtable, 0, id, 1000000 - GetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD))
        call SaveInteger( udg_RCSHashtable, 1, id, 1000000 - GetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER))
        call SaveInteger( udg_RCSHashtable, 2, id, GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED))
        call SaveInteger( udg_RCSHashtable, 3, id, foodCap)
        
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_GOLD, playerG)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER, playerL)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_CAP, playerFC + foodCap)
        call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED, playerFU)
        
        call RCSItemAUnitGALUnPauseSystems()
        set p = null
    endfunction

    function RCSGetItemGoldCostById takes item itm, integer id returns integer
        local integer charges = GetItemCharges(itm)
        if not HaveSavedInteger( udg_RCSHashtable, 0, id * -1) then
            call RCSStoreItemCosts( id)
        endif
        if charges > 0 then
            return LoadInteger( udg_RCSHashtable, 0, id * -1) * charges
        endif
        return LoadInteger( udg_RCSHashtable, 0, id * -1)
    endfunction

    function RCSGetItemLumberCostById takes item itm, integer id returns integer
        local integer charges = GetItemCharges(itm)
        if not HaveSavedInteger( udg_RCSHashtable, 1, id * -1) then
            call RCSStoreItemCosts( id)
        endif
        if charges > 0 then
            return LoadInteger( udg_RCSHashtable, 1, id * -1) * charges
        endif
        return LoadInteger( udg_RCSHashtable, 1, id * -1)
    endfunction

    function RCSGetItemFoodCostById takes item itm, integer id returns integer
        local integer charges = GetItemCharges(itm)
        if not HaveSavedInteger( udg_RCSHashtable, 2, id * -1) then
            call RCSStoreItemCosts( id)
        endif
        if charges > 0 then
            return LoadInteger( udg_RCSHashtable, 2, id * -1) * charges
        endif
        return LoadInteger( udg_RCSHashtable, 2, id * -1)
    endfunction

    function RCSGetItemFoodCapById takes item itm, integer id returns integer
        local integer charges = GetItemCharges(itm)
        if not HaveSavedInteger( udg_RCSHashtable, 3, id * -1) then
            call RCSStoreItemCosts( id)
        endif
        if charges > 0 then
            return LoadInteger( udg_RCSHashtable, 3, id * -1) * charges
        endif
        return LoadInteger( udg_RCSHashtable, 3, id * -1)
    endfunction

    function RCSGetItemInitialChargesById takes item itm, integer id returns integer
        local integer charges = GetItemCharges(itm)
        if not HaveSavedInteger( udg_RCSHashtable, 4, id * -1) then
            call RCSStoreItemCosts( id)
        endif
        if charges > 0 then
            return LoadInteger( udg_RCSHashtable, 4, id * -1) * charges
        endif
        return LoadInteger( udg_RCSHashtable, 4, id * -1)
    endfunction

    function RCSGetItemGoldCost takes item itm returns integer
        return RCSGetItemGoldCostById( itm, GetItemTypeId( itm))
    endfunction

    function RCSGetItemLumberCost takes item itm returns integer
        return RCSGetItemLumberCostById( itm, GetItemTypeId( itm))
    endfunction

    function RCSGetItemFoodCost takes item itm returns integer
        return RCSGetItemFoodCostById( itm, GetItemTypeId( itm))
    endfunction

    function RCSGetItemFoodCap takes item itm returns integer
        return RCSGetItemFoodCapById( itm, GetItemTypeId( itm))
    endfunction

    function RCSGetItemInitialCharges takes item itm returns integer
        return RCSGetItemInitialChargesById( itm, GetItemTypeId( itm))
    endfunction

    function RCSGetUnitGoldCostById takes integer id returns integer
        if not HaveSavedInteger( udg_RCSHashtable, 0, id * -1) then
            call RCSStoreUnitCosts(id)
        endif
        return LoadInteger( udg_RCSHashtable, 0, id * -1)
    endfunction

    function RCSGetUnitLumberCostById takes integer id returns integer
        if not HaveSavedInteger( udg_RCSHashtable, 1, id * -1) then
            call RCSStoreUnitCosts(id)
        endif
        return LoadInteger( udg_RCSHashtable, 1, id * -1)
    endfunction

    function RCSGetUnitFoodCostById takes integer id returns integer
        if not HaveSavedInteger( udg_RCSHashtable, 2, id * -1) then
            call RCSStoreUnitCosts(id)
        endif
        return LoadInteger( udg_RCSHashtable, 2, id * -1)
    endfunction

    function RCSGetUnitFoodCapById takes integer id returns integer
        if not HaveSavedInteger( udg_RCSHashtable, 3, id * -1) then
            call RCSStoreUnitCosts(id)
        endif
        return LoadInteger( udg_RCSHashtable, 3, id * -1)
    endfunction

    function RCSGetUnitGoldCost takes unit u returns integer
        return RCSGetUnitGoldCostById( GetUnitTypeId( u))
    endfunction

    function RCSGetUnitLumberCost takes unit u returns integer
        return RCSGetUnitLumberCostById( GetUnitTypeId( u))
    endfunction

    function RCSGetUnitFoodCost takes unit u returns integer
        return RCSGetUnitFoodCostById( GetUnitTypeId( u))
    endfunction

    function RCSGetUnitFoodCap takes unit u returns integer
        return RCSGetUnitFoodCapById( GetUnitTypeId( u))
    endfunction
    
    function RCSCheckForUnitPrice takes integer id returns boolean // This stops the system from registering the same units.
        // This also stops the system from infinite looping.
        if not HaveSavedInteger( udg_RCSHashtable, 0, id * -1) and GetTriggerUnit() != udg_RCSItemAUnitGALMerchant then
            call RCSStoreUnitCosts( id)
        endif
        return false
    endfunction
    
    function RCSGetTrainedUnitType takes nothing returns boolean // This gets the unit being trained.
        return RCSCheckForUnitPrice( GetTrainedUnitType())
    endfunction
    
    function RCSGetSoldUnitType takes nothing returns boolean // This is for the sold unit.
        return RCSCheckForUnitPrice( GetUnitTypeId( GetSoldUnit()))
    endfunction
    
    function RCSGetConstructUnitType takes nothing returns boolean // This is for getting the constructing structure.
        return RCSCheckForUnitPrice( GetUnitTypeId( GetConstructingStructure()))
    endfunction
    
    function RCSGetUpgradeUnitType takes nothing returns boolean // This is for upgrading unit.
        return RCSCheckForUnitPrice( GetUnitTypeId( GetTriggerUnit()))
    endfunction
    
    function RCSCheckForItemPrice takes item itm, integer id returns boolean // This stops the system from registering the same items.
        if not HaveSavedInteger( udg_RCSHashtable, 3, id * -1) and GetTriggerUnit() != udg_RCSItemAUnitGALMerchant then
            call RCSStoreItemCosts( id)
        endif
        return false
    endfunction
    
    function RCSItemAUnitGALCleanupUnits takes nothing returns boolean // This cleans up the units sold to get the prices.
        call RemoveUnit( GetSoldUnit())
        return false
    endfunction
    
    function RCSGetPickedUpItemType takes nothing returns boolean
        return RCSCheckForItemPrice( GetManipulatedItem(), GetItemTypeId( GetManipulatedItem()))
    endfunction

    function RCSItemAUnitGALRegisterSetup takes nothing returns nothing
        call RCSItemAUnitGALRegisterRegion()
        if udg_RCSHashtable == null then
            set udg_RCSHashtable = InitHashtable()
        endif
        set udg_RCSItemAUnitGALSpawnX = GetRectCenterX( udg_RCSItemAUnitGALRegionSpawn)
        set udg_RCSItemAUnitGALSpawnY = GetRectCenterY( udg_RCSItemAUnitGALRegionSpawn)
        set udg_RCSItemAUnitGALFoodCapMax = GetPlayerState( Player(0), PLAYER_STATE_FOOD_CAP_CEILING)
        set udg_RCSItemAUnitGALMerchant = CreateUnit( Player(0), udg_RCSItemAUnitGALMerchantId, udg_RCSItemAUnitGALSpawnX, udg_RCSItemAUnitGALSpawnY, 270)
        call ShowUnit( udg_RCSItemAUnitGALMerchant, false)
    endfunction

    //===========================================================================
    function InitTrig_ItemAndUnitGoldAndLumberCost takes nothing returns nothing
        local integer L = 0
        local player p
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local trigger t3 = CreateTrigger()
        local trigger t4 = CreateTrigger()
        local trigger t5 = CreateTrigger()
        local trigger t6 = CreateTrigger()
        call RCSItemAUnitGALRegisterSetup()
        call TriggerRegisterUnitEvent( t1, udg_RCSItemAUnitGALMerchant, EVENT_UNIT_SELL)
        call TriggerAddCondition( t1, Condition( function RCSItemAUnitGALCleanupUnits))
        
        loop
            set p = Player( L)
            call TriggerRegisterPlayerUnitEvent( t2, p, EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
            call TriggerRegisterPlayerUnitEvent( t3, p, EVENT_PLAYER_UNIT_TRAIN_START, null)
            call TriggerRegisterPlayerUnitEvent( t4, p, EVENT_PLAYER_UNIT_SELL, null)
            call TriggerRegisterPlayerUnitEvent( t5, p, EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
            call TriggerRegisterPlayerUnitEvent( t6, p, EVENT_PLAYER_UNIT_UPGRADE_START, null)
            set L = L + 1
            exitwhen L > 15
        endloop
        
        call TriggerAddCondition( t2, Condition( function RCSGetPickedUpItemType))
        call TriggerAddCondition( t3, Condition( function RCSGetTrainedUnitType))
        call TriggerAddCondition( t4, Condition( function RCSGetSoldUnitType))
        call TriggerAddCondition( t5, Condition( function RCSGetConstructUnitType))
        call TriggerAddCondition( t6, Condition( function RCSGetUpgradeUnitType))
        set t1 = null
        set t2 = null
        set t3 = null
        set t4 = null
        set t5 = null
        set t6 = null
        set p = null
    endfunction


version 1.0.1.0
Fixed a bug with charged items returning wrong value.
Added A get initial charge function which gets the initial charges an item has when it is spawned.
Fixed the API.​
version 1.0.0.5
Fixed a few bugs as mentioned above.
Changed to allow for items to cost food and food cap.
Records how much food cost and food cap increase / decrease per building.​
version 1.0.0.3
Fixed a bug with non stacked items returning wrong value.​
version 1.0.0.2
Stacked items now work correctly.​
version 1.0.0.1
Fixed a bug with items and units that wer not in system giving wrong values.​
version 1.0.0.0
first version released.​


Keywords:
Cost, item gold, item gold cost, item lumber, item lumber cost, unit gold, unit gold cost, unit lumber, unit lumber cost, unit food, unit food cost, s
Contents

Just another Warcraft III map (Map)

Reviews
18th Apr 2016 Your resource has been reviewed by BPower. In case of any questions or for reconfirming the moderator's rating, please make use of the Quick Reply function of this thread. Review: In theory a useful piece of code. In fact it...

Moderator

M

Moderator

18th Apr 2016

General Info

Your resource has been reviewed by BPower.
In case of any questions or for reconfirming the moderator's rating,
please make use of the Quick Reply function of this thread.
Review:

In theory a useful piece of code.
In fact it was coded many times on TheHelper and also here on TheHiveWorkshop.
There are versions without the issues listed below, therefore I altered my previous
moderator review and set this resource back to Need Fix.
I was a greenhorn 2 years before...

Using a pre-defined area to detect bought items is acceptable as long
as no other actions take part in this rect. Don't forget that items have a pathing size aswell.

I don't see the need to track all these player unit events.
Object cost should be calculated and cached on demand, not by default.

Items neither influence the food amount nor the food cap. What the heck are you doing there?

Troubleshooting:

  • The function arguments don't make sense at all.
    It should be either the item handle or the item type id and not both.
    For example: function RCSGetItemGoldCostById takes item itm, integer id returns integer
    ---
  • The merchant should preferably belong to a neutral player and not player 0.
    ---
  • As naming convention I would prefer RSC_DoThis over RSCDoThis.
    ---
  • JASS:
        function RCSGetItemInitialChargesById takes item itm, integer id returns integer
            local integer charges = GetItemCharges(itm)
            if not HaveSavedInteger( udg_RCSHashtable, 4, id * -1) then
                call RCSStoreItemCosts( id)
            endif
            if charges > 0 then
                return LoadInteger( udg_RCSHashtable, 4, id * -1) * charges
            endif
            return LoadInteger( udg_RCSHashtable, 4, id * -1)
        endfunction
    ^This doesn't look correct to me.

Review changelog:
  1. -
 
Level 19
Joined
Mar 18, 2012
Messages
1,717
What's wrong with native GetUnitGoldGost(unitid) and GetUnitWoodCost(unitid) ?
JASS:
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer

Edit: Nice system, I could be useful if you want to substitute for instance gold with wood, wood with gold , gold with a custom resource, sort units by costs or food, ....

And it doesn't have to run on top speed, so forget about what I've posted above.
 
Last edited:
Level 29
Joined
Oct 24, 2012
Messages
6,545
  • Set RCSHashtable = (Last created hashtable)
when did you create the hashtable?

I create the hashtable in the jass code. I use one hashtable for all my RCS systems. I have this one and the kills counter. I am coming up with one maybe two more. Since i don't want to create it over and over it is easier to manage in jass i use an ITE and check if it is null if it is null then i create it. That way it won't be created twice or more if both systems are used. It also allows my systems to only use one hashtable.

I create the hashtable here.
JASS:
if udg_RCSHashtable == null then
            set udg_RCSHashtable = InitHashtable()
        endif
Also the variables trigger is to simply make it easier to import into a map. It is meant to be deleted or disabled like in my map.
 
Level 29
Joined
Oct 24, 2012
Messages
6,545
I'll take a look at stacked items i knew i forgot something.

I tested this a bit, and generally it worked fine for me.

Onle one note I would make.. stacked items wont be registered with higher costs. They still seem to cost as only 1 of it's type.

But anyway, this might be useful for some special maps.

Edit: Updated and fixed.
 
Level 19
Joined
Mar 18, 2012
Messages
1,717
- Training a not registered unit doesn't increase used food.
- Constructing the first farm does decrease the food cap, by the amount the farm should provide.
- Once you reach low or high costs, you get the Blizzard message, if you create a not registered unit :/ ( because you set the food to 0 and back to current)
- In did CnP the API for each function and didn't change it for each individually. It's always written Get....ById
- For items it seems to work well.
- In my opinion you should change function names to: RCSGetItemGoldCostById --> GetItemGoldCostById.
- You may explain in your demo, why any UnitIndexer could be paused.

Just run the system with Player(PLAYER_NEUTRAL_PASSIVE) instead Player(0) and all mentioned problems vanish.
 
Level 19
Joined
Mar 18, 2012
Messages
1,717
The ouput of LoadInteger( udg_RCSHashtable, 0, id * -1) * charges is charges times too high.
In Example a stack of sentry wards costs 150 gold, but the system will return
an item gold cost fee of 450. Obviously wrong because 1 sentry wards actually only costs 50 gold.
Once you store an item price, you have to devide the value with the number of charges, if that item has charges.
 
Level 9
Joined
May 21, 2014
Messages
580
Ack! Let me re-set the system as how I have set it up, then I will send it to you WHEN I am on my computer as well. Many thanks.

Let me add how I set it up though:

I have set the Marketplace Unit Type with the proper abilities to set up the system.
I have placed a region in the game where it is unreachable by the player.

I pasted (including all variables) the trigger folder system to mine.
 
Top