I have a record called Unit Data, this record is an array and contains
- Unit Name
- Unit Type
- Unit Picture
So Unit data is an array, Unit Data[10]. My game has a shop function where when you buy a unit it adds it to Unit Data. So if I brought 2 Marines and a Hellion
Unit Data[0] .unitType = Marine
Unit Data[1] .unitType = Marine
Unit Data[2] .unitType = Hellion
These units will have other properties that will be essential to the game eg
Unit Data[1] .unitType = Marine
Unit Data[1] .strengh = 4
Unit Data[1] .defence = 4
Unit Data[1] .intelligence= 4
When a player selects unit 1 Marine, how can I make it so the game knows im accessing the properties of Unit Data[1]. One way I can think of doing this is writing the ID number before the unit name and when the player selects the unit it will read the number from the unit name and identify the correct array element that way. This may not even be possible though.
There must be an easier and more plausible method to achieve this.
Each unit can save up to 64 custom numbers. Just save the unit's "Unit Data" index to its first custom number by calling the action "Set Unit Custom Value" on creation. Then, you can retrieve the index by using the function "Custom Value Of Unit".
I have a record called Unit Data, this record is an array and contains
- Unit Name - Unit Type - Unit Picture
So Unit data is an array, Unit Data[10]. My game has a shop function where when you buy a unit it adds it to Unit Data. So if I brought 2 Marines and a Hellion
Unit Data[0] .unitType = Marine Unit Data[1] .unitType = Marine Unit Data[2] .unitType = Hellion
These units will have other properties that will be essential to the game eg
Unit Data[1] .unitType = Marine Unit Data[1] .strengh = 4 Unit Data[1] .defence = 4 Unit Data[1] .intelligence= 4
When a player selects unit 1 Marine, how can I make it so the game knows im accessing the properties of Unit Data[1]. One way I can think of doing this is writing the ID number before the unit name and when the player selects the unit it will read the number from the unit name and identify the correct array element that way. This may not even be possible though.
There must be an easier and more plausible method to achieve this.
Thanks for any help.
any unit is selected, if unit data[1].unit then set properties accessed to unit data[1].
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
Each unit can save up to 64 custom numbers. Just save the unit's "Unit Data" index to its first custom number by calling the action "Set Unit Custom Value" on creation. Then, you can retrieve the index by using the function "Custom Value Of Unit".
Yeah there's probably a better way to store unit stats than in a record. Like using custom values like Sanktoras said or simply Attributes.