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

[Trigger] Variable/array problem

Status
Not open for further replies.
Level 8
Joined
Sep 24, 2007
Messages
300
I want to make a unit ranking system, similar to that one in Red Alert 2.

More enemies the unit kills, more stars it gets (in this case items).


I need to store the number of kills of EACH unit into arrayed variables. The problem is, how to set up the arrays? It should be a uniq number of the unit and so far I don't have idea how to set this up.



Thanks for help in advance.
 
one unit array, one integer array, one integer variable. Each time a unit kills something, if looping through the array in search of the unit comes out negative, store it in the unit array at [your integer variable]. Store 1 star in your integer array at [your integer variable]. Increase integer variable by 1. If the unit already has stars, increase the value of your integer array at your unit's index by 1.

Either all of that, or use custom values.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
I think PUI does exactly what you want.

I think the idea behind this system is something like this:

You have a stack with unused indexes and an integer variable storing the heighest index.
When a unit enters the game it is assigned a new index. When the stack is not empty a index from the stack is used, when the stack is empty a new index is created (heighest index + 1).
When a unit dies its index is put back on the stack.
 
  • Indexing System
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer TempInt) from 0 to Total, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Killing unit) Equal to Unitz[TempInt]
            • Then - Actions
              • Custom script: exitwhen
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInt Not equal to Total
        • Then - Actions
          • Set Starz[TempInt] = (Starz[TempInt] + 1)
        • Else - Actions
          • Set Starz[Total] = 1
          • Set Unitz[Total] = (Killing unit)
          • Set Total = (Total + 1)
This trigger makes it so when any unit kills another unit he gains a star. If you don't just want any unit to be able to gain stars, you can add a condition to the trigger (like Killing Unit is in group StarzUnitz)
 
Status
Not open for further replies.
Top