Changing unit cost in-game?

UberNoober

New Member
Reaction score
1
I'm currently working on a map in which I have a building that can train 'Minions'. I want to make it so that for each minion you already have, it increases the gold cost to train minions by 50 per minion you own.

I looked up an old post here in which someone wanted to change the gold cost of buildings in-game, but someone replied saying that it wasn't possible. So I figured the only choice I had was to make different versions of the minion unit with varying costs, but the problem I have now is that I don't know how I could change what units the building can build in-game.

One way to get around that issue would be to replace the building whenever the number of minions changes, however this would screw up other functions the building has. For example if it was training a unit of a different type, or had units queued up, if replaced it would lose all that stuff.

So! Does anyone have any ideas of how I could get around this? This function is pretty crucial to the balance and gameplay of my map and it would really suck if I can't scale the cost of these units somehow.

Sorry for the wall of text and thankyou in advance for your help and suggestions!
 

n[u]ll

You can change this now in User CP.
Reaction score
93
You could have the players type "-buyminion" or something like that then have a dialogue pop up saying, "Are you sure you want to buy a minion for X gold?".

Where X is a variable that increases every time the player buys one. If they don't have enough, then pop up saying that they do not have enough gold.

Edit:
Just ignore me. :D
 

UberNoober

New Member
Reaction score
1
Ran into a slight issue. I want the minion to cost 1 food, but there is no barrier to training them if I use the upgrade, because I can't attach a food cost to that.
 

Azylaminaz

Vox Populi
Reaction score
91
You could have a trigger that checks when the upgrade has begain research to check if the triggering player has max food, if so, cancel upgrade and display an error message.
 

Azlier

Old World Ghost
Reaction score
461
Uh...if you use an upgrade, of course the cost will increase naturally, but... If a minion dies, then the cost should go down 50, correct? I don;t think an upgrade can do that. Also, it can't be triggered back down because I heard an upgrade can never be "unlearned." I have no idea how to fix this so that its simple to make a minion, yet works perfectly...
 

Blackveiled

Formerly, Ban-Lord
Reaction score
157
You could make the unit free in the barracks, and say it costs 50 gold more for each one you own.

So, create a trigger that checks how many you own on the field and then if you own around a certain number of them, multiply that number by 50 and then add 50 gold to the variable to make that the cost of the unit.

20 units on the field

20 x 50 = 1,000 + 50 = 1,050 gold
 

UberNoober

New Member
Reaction score
1
Yeah I'm having the 'can't unlearn' issue now. Also another issue where if the unit is bound to the upgrade and spawned by the trigger it won't go to the rally point, which is sort of a big thing for this unit seeing as it is a worker.

As for the trigger to change the cost of the unit, I don't think that you can change the cost by triggers, which is the reason I posted all of this in the first place.

In an ideal world I would like a way to train this normally, have it go to it's rally point, display the increasing gold cost and display the food cost on the icon, and have it display as a unit being trained instead of an upgrade. Oh, and it needs to decrease in cost if the unit type dies.

Any other ways in which I could do these things? Or at least get the more important ones in, display being not so much an issue.
 

UberNoober

New Member
Reaction score
1
Sorry to bump this again but this is a really big issue for my map. Any way at all to change the cost of a unit, or to change the units a building can build, or does anyone have any other suggestions of how this could work? Also if this is impossible, confirmation would be good on that too.

Thankyou for any help.
 

demotry241

Don't Ever Categorize Yourself.
Reaction score
105
just use the "upgrade" to replace the units in the barracks

(e.g.) Steam Engine when buying Barrage Upgrade
 

Advena

Just casually observing atm ;)
Reaction score
42
You could make twelve instances of this same unit, but with diffrent costs.
Then you make a trigger something like this:
(handwritten, hope you don't mind)

Code:
Untitled Trigger 001
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        Set (peons_count_integer_variable) = (Number of units in (Units owned by PlayerX matching ((Unit-type of (Matching unit)) Equal to Peon)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (peons_count_integer_variable) [Less than or equal to] (1)
            Then - Actions
                Player - Make Peon Unavailable for training for PlayerX
                Player - Make Peon Available for training for PlayerX
            Else - Actions
                Do nothing
And then you have these twelve diffrent unit-types (all essentially the same worker, but with diffrent costs) available in the same building. But at all time there's only one type available, controlled by an extention of this trigger above.
You'll always have the cost based on number of workers alive (tho if you want to be able to have more than twelve.. or eleven even, to fit the red cancel button, then you'll want to be able to have more than one peon for each "cost level" so to speak).
Probably not perfect, but it get's you closer to what you want I think. :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


EDIT:
Eureka!
I realised there's a better way of my idea above. Instead of using multiple unit types and changing availability inbetween them you use multiple abilities, given and taken from the building to match number of workers to the cost for another one. You'll probably need a gazillion abilities all doing nothing with slightly diffrent tooltips, but it should work :thup:
 

UberNoober

New Member
Reaction score
1
OMG Thankyou so much! That Player trigger was what I couldn't find. I don't quite understand your second method but the first one would do me just fine, and I'd even be able to put a cap on the amount of units trained which I think would be a good addition to my map.
 

Advena

Just casually observing atm ;)
Reaction score
42
Great! I'm glad I could help :)

But I think it could be even better with the abilities-idea, but I'm not sure exactly how to explain.
And I'd have to do a whole small map to show you I guess hehe.

Anyways, great that you could use it :thup:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top