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

making 3 currencies

Status
Not open for further replies.
Level 2
Joined
Aug 26, 2004
Messages
29
You can't make one that appears in the top bar like gold and wood do, but you CAN make it exist. You have to come up with your own way of displaying it though.

To make the actual currency, use an array.

Click the Variables button (Looks like a yellow X) in the trigger editor. Click the green +X button to add a variable. Title it whatever you want, I'll use "iPlayerCurrency" as an example. Set the type to Integer, check the Array box, and make it size 12. If you're gonna use the neutral players too, set it to 16. If you're making a Frozen Throne map then it doesn't really matter because the game will resize it automatically. Leave the default at 0.

To get a player's currency, just select iPlayerCurrency from the Variable pulldown menu in anything that needs an integer value, and it'll automatically make a part that looks like "[ Index ]"

Click Index and set it to:
Function: Player - Player Number
Then, set the player part to whichever player you need.

To ADD currency, use:
Set Variable
_ iPlayerCurrency
_ _ [ Player - Player Number (PLAYER) ]
_ Arithmetic
_ _ iPlayerCurrency
_ _ _ [ Player - Player Number (PLAYER) ]
_ _ +
_ _ AMOUNT TO ADD


To SET currency, use:
Set Variable
_ iPlayerCurrency
_ _ [ Player - Player Number (PLAYER) ]
_ NEW AMOUNT
 
Level 6
Joined
Jul 23, 2004
Messages
162
Wow_WhatANoob said:
To get a player's currency, just select iPlayerCurrency from the Variable pulldown menu in anything that needs an integer value, and it'll automatically make a part that looks like "[ Index ]"
sorry im not really good with variables but i have had experience with them but anwyways what is the variable pulldown menu? is that the same as clicking on the yellow x?
 
Level 2
Joined
Aug 26, 2004
Messages
29
Well, I just realized, you'd need to do more stuff to make your new currency required for unit creation.


You're going to need several triggers and a bunch of things set by hand to do it.

But anyway, first things first....

what is the variable pulldown menu?
When you're making a trigger, some things take integers (a.k.a. non-fractional numbers), like for example, if you create an action with "Player - Set Property", then the last number in it (the value to set the property to) is an integer. If you click that, then you get 3 options:

Variable, Function, or Value.

Next to the Variable option is the pulldown menu that lets you select one of your variables to use it.




Now then, to actually make your currency factor in, you will NEED the expansion, because RoC doesn't support variable-sized arrays or multi-function Fors/Conditionals, which are needed for this.


The most tedious part of all this is you need to enter each unit type and cost by hand, and keep it up-to-date so the currency is handled accurately.


Create 5 new variables:
utRestrictedUnitTypes : Unit-Type, Array, size 1
iRestrictedUnitCosts : Integer, Array, size 1
iRestrictedUnitCostsGold : Integer, Array, size 1
iRestrictedUnitCostsLumber : Integer, Array, size 1
iRestrictedUnitCount : Integer, default 0

Create a new trigger like this:

(Events)
| . Map Initialization

(Conditions)

(Actions)
Set Variable
| . iRestrictedUnitCount
| . Arithmetic
| . | . iRestrictedUnitCount
| . | . +
| . | . 1
Set Variable
| . utRestrictedUnitTypes
| . | . [ iRestrictedUnitCount ]
| . UNIT TYPE GOES HERE
Set Variable
| . iRestrictedUnitCostsGold
| . | . [ iRestrictedUnitCount ]
| . UNIT TYPE'S COST IN GOLD GOES HERE
Set Variable
| . iRestrictedUnitCostsLumber
| . | . [ iRestrictedUnitCount ]
| . UNIT TYPE'S COST IN LUMBER GOES HERE
Set Variable
| . iRestrictedUnitCosts
| . | . [ iRestrictedUnitCount ]
| . UNIT TYPE'S COST IN THE NEW CURRENCY GOES HERE


Copy/Paste those actions and change the unit type and cost for each unit. If a unit does NOT have a value under the new currency, don't include it.

Now you've got a lookup table for the costs of various units.



You still need to restrict building/training using that currency though.

Make 5 new variables:

utUnitBeingCheckedType : Unit-Type
bUnitCheckSucceeded : Boolean
iUnitCheckIndex : Integer
iUnitCheckOwner : Integer
iUnitCancelRatio : Integer



Now, create a new one:

NAME: Check Unit Affordability
(Events)

(Conditions)

(Actions)
Set Variable
| . bUnitCheckSucceeded
| . False
Set Variable
| . iUnitCheckIndex
| . 0
For Each Integer A, Do Action
| . 1
| . iRestrictedUnitCount
| . If / Then / Else
| . | . Unit-Type Comparison
| . | . | . utUnitBeingCheckedType
| . | . | . Equal to
| . | . | . | . utRestrictedUnitTypes
| . | . | . | . | . [ For Loop Integer A ]
| . | . Set Variable
| . | . | . iUnitCheckIndex
| . | . | . For Loop Integer A
| . | . No Action
If / Then / Else
| . Integer Comparison
| . | . iUnitCheckIndex
| . | . Equal To
| . | . 0
| . Set Variable
| . | . bUnitCheckSucceeded
| . | . True
| . If / Then / Else
| . | . Integer Comparison
| . | . | . iPlayerCurrency
| . | . | . | . [ iUnitCheckOwner ]
| . | . | . Greater than or equal to
| . | . | . | . iRestrictedUnitCosts
| . | . | . | . | . [ iUnitCheckIndex ]
| . Set Variable
| . | . bUnitCheckSucceeded
| . | . True
| . No Action


You also need a method to refund stuff that can't build, so here's another:

NAME: Fail Unit Creation
(Events)

(Conditions)

(Actions)
Player - Add Property
| . iRestrictedUnitCostsGold
| . | . [ iUnitCheckIndex ]
| . Conversion - Convert Player Index To Player
| . | . iUnitCheckOwner
| . Current gold
Player - Add Property
| . iRestrictedUnitCostsLumber
| . | . [ iUnitCheckIndex ]
| . Conversion - Convert Player Index To Player
| . | . iUnitCheckOwner
| . Current lumber


Also need one to refund cancelled stuff...


NAME: Cancellation Refund
(Events)

(Conditions)

(Actions)
Trigger - Run (Ignoring Conditions)
| . Check Unit Affordability <gen>
If / Then / Else
| . Integer Comparison
| . | . iUnitCheckIndex
| . | . Equal to
| . | . 0
| . Skip remaining actions
| . No Action
Set Variable
| . iPlayerCurrency
| . | . [ iUnitCheckOwner ]
| . Arithmetic
| . | . iPlayerCurrency
| . | . | . [ iUnitCheckOwner ]
| . | . +
| . | . Arithmetic
| . | . | . Arithmetic
| . | . | . | . iUnitCancelRatio
| . | . | . | . x
| . | . | . | . iRestrictedUnitCosts
| . | . | . | . | . [ iUnitCheckIndex ]
| . | . | . /
| . | . | . 100



Those are just recyclable triggers though, you need 4 more to control item production.

Unfortunately, the only way I can think of to effectively cancel unit training is to kill the unit after it spawns. I'm not sure if they can be cancelled in training, but if they could, then you'd still lose money just by TRYING to build it.



New trigger:

(Events)
Unit - Generic Unit Event
| . Finished training a unit

(Conditions)

(Actions)
Set Variable
| . utUnitBeingCheckedType
| . Event Response - Trained Unit-Type
Set Variable
| . iUnitCheckOwner
| . Player - Player Number
| . | . Owner of Unit
| . | . | . Event Response - Triggering Unit
Trigger - Run (Ignoring Conditions)
| . Check Unit Affordability <gen>
If / Then / Else, Multiple Functions
| . (If - Conditions)
| . Boolean Comparison
| . | . bUnitCheckSucceeded
| . | . Equal to
| . | . True
| . (Then - Actions)
| . | . Set Variable
| . | . | . iPlayerCurrency
| . | . | . | . [ iUnitCheckOwner ]
| . | . | . Arithmetic
| . | . | . | . iPlayerCurrency
| . | . | . | . | . [ iUnitCheckOwner ]
| . | . | . | . -
| . | . | . | . iUnitCheckCost
| . (Else - Actions)
| . | . Game - Text Message (Auto-Timed)
| . | . | . Convert Player to Player Group
| . | . | . | . Event Response - Triggering Player
| . | . | . TEXT FOR FAILING UNIT TRAINING GOES HERE
| . | . Unit - Kill
| . | . | . Event Response - Trained Unit
| . | . Trigger - Run (Ignoring Conditions)
| . | . | . Fail Unit Creation <gen>


Another trigger for when buildings start getting made:


(Events)
Unit - Generic Unit Event
| . Begins construction

(Conditions)

(Actions)
Set Variable
| . utUnitBeingCheckedType
| . Unit-Type of Unit
| . | . Event Response - Constructing Structure
Set Variable
| . iUnitCheckOwner
| . Player - Player Number
| . | . Owner of Unit
| . | . | . Event Response - Constructing Structure
Trigger - Run (Ignoring Conditions)
| . Check Unit Affordability <gen>
If / Then / Else, Multiple Functions
| . (If - Conditions)
| . Boolean Comparison
| . | . bUnitCheckSucceeded
| . | . Equal to
| . | . True
| . (Then - Actions)
| . | . Set Variable
| . | . | . iPlayerCurrency
| . | . | . | . [ iUnitCheckOwner ]
| . | . | . Arithmetic
| . | . | . | . iPlayerCurrency
| . | . | . | . | . [ iUnitCheckOwner ]
| . | . | . | . -
| . | . | . | . iUnitCheckCost
| . (Else - Actions)
| . | . Game - Text Message (Auto-Timed)
| . | . | . Convert Player to Player Group
| . | . | . | . Event Response - Triggering Player
| . | . | . TEXT FOR FAILING CONSTRUCTION GOES HERE
| . | . Unit - Remove
| . | . | . Event Response - Constructing Structure
| . | . Trigger - Run (Ignoring Conditions)
| . | . | . Fail Unit Creation <gen>



Not done yet, need to refund if the player cancels units

(Events)
Unit - Generic Unit Event
| . Cancels training a unit

(Conditions)

(Actions)
Set Variable
| . utUnitBeingCheckedType
| . Event Response - Trained Unit-Type
Set Variable
| . iUnitCheckOwner
| . Player - Player Number
| . | . Event Response - Triggering Player
Set Variable
| . iUnitCancelRatio
| . PERCENTAGE OF VALUE TO REFUND ON UNITS GOES HERE
Trigger - Run (Ignoring Conditions)
| . Cancellation Refund <gen>



And another if they cancel a building...

(Events)
Unit - Generic Unit Event
| . Cancels construction

(Conditions)

(Actions)
Set Variable
| . utUnitBeingCheckedType
| . Unit-Type of Unit
| . | . Event Response - Cancelled Structure
Set Variable
| . iUnitCheckOwner
| . Player - Player Number
| . | . Owner of Unit
| . | . | . Event Response - Cancelled Structure
Set Variable
| . iUnitCancelRatio
| . PERCENTAGE OF VALUE TO REFUND ON BUILDINGS GOES HERE
Trigger - Run (Ignoring Conditions)
| . Cancellation Refund <gen>




..... Enjoy.
 
Status
Not open for further replies.
Top