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

When X unit is build/trained increase income for player trigger system

Status
Not open for further replies.
Level 4
Joined
Nov 19, 2010
Messages
54
Hello,

I'm currently creating a trigger when a marine is trained the income will increase + 10 minerals and after x sec the player will receive his income

  • Test
    • Events
      • Unit - Any Unit training progress is Completed
    • Local Variables
      • IncomeVar = 0 <Integer[6]>
    • Conditions
      • (Unit type of (Triggering unit)) == Marine
    • Actions
      • Variable - Modify IncomeVar[(Triggering player)]: + 10
This is my trigger when i buy a marine and his training is completed and it should add + 10 minerals to his income

  • Test 2
    • Events
      • Timer - Every 10.0 seconds of Real Time
    • Local Variables
      • IncomeVar = 0 <Integer[6]>
    • Conditions
    • Actions
      • Player Group - Pick each player in (All players) and do (Actions)
        • Actions
          • Player - Modify player (Picked player) Minerals: Add IncomeVar[(Picked player)]
This is my trigger that gives the income every 10 sec in real time to each player

But when i'm training a marine now i still don't get the + 10 minerals income for each marine i train at the income round every 10 seconds maybe i'm missing something here or did i do a mistake in this trigger?

PS i have a variable named incomevar and i checked array and size 6 because i have 6 players.

I hope some one can help me with this one!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
You do know what a local variable is right? Like how they exist only for the duration of the call of the function they were defined in.

I think you are meaning to use a global varible and not a local variable.

In Galaxy Script globals are defined by placing a variable decleration anywhere outside a function. In GUI they can be defined as a seperate element (similar to triggers, function, etc).
 
Level 4
Joined
Nov 19, 2010
Messages
54
You do know what a local variable is right? Like how they exist only for the duration of the call of the function they were defined in.

I think you are meaning to use a global varible and not a local variable.

In Galaxy Script globals are defined by placing a variable decleration anywhere outside a function. In GUI they can be defined as a seperate element (similar to triggers, function, etc).

Yeah i know what a local variable is :p i was indeed meaning a global variable not a local one... i changed the local variable to a global variable one.

  • Income round for each player
    • Events
      • Timer - Every 10.0 seconds of Real Time
    • Local Variables
    • Conditions
    • Actions
      • Player Group - Pick each player in (All players) and do (Actions)
        • Actions
          • Player - Modify player (Picked player) Minerals: Add IncomeVar[0]
          • UI - Display "Next Mineral round is here!" for (Player group((Picked player))) to Directive area
I have no idea what function i need to get at this trigger
  • Player - Modify player (Picked player) Minerals: Add IncomeVar[0]
at Add IncomeVar[0] at the [0] i have checked a few but they didn't give me any results it just says there is a error at the end of the array and i can't seem to find the right function.

  • Marine Trained
    • Events
      • Unit - Any Unit training progress is Completed
    • Local Variables
    • Conditions
      • (Unit type of (Triggering unit)) == Marine
    • Actions
      • Variable - Modify IncomeVar[(Triggering player)]: + 10
 
How about this?

If you want it to work so that the "Every 10 seconds income" permanently increases by 10 when a unit X is trained, then here's what you do.

One global variable:
Integer with array size of (max players)

  • Modify Income
    • Events
      • Unit - Any Unit training progress is Completed
    • Local Variables
      • player = (Owner of (Triggering unit)) <Integer>
    • Conditions
      • (Unit type of (Triggering unit)) == Marine
    • Actions
      • Variable - Set Income[player] = (Income[player] + 10)
  • Give Income
    • Events
      • Timer - Every 10.0 seconds of Game Time
    • Local Variables
      • integerA = 0 <Integer>
    • Conditions
    • Actions
      • General - For each integer integerA from 1 to 12 with increment 1, do (Actions)
        • Actions
          • Player - Modify player integerA Minerals: Add Income[integerA]
 
Status
Not open for further replies.
Top