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

Control Points that give Income?

Status
Not open for further replies.
Level 4
Joined
Jul 12, 2011
Messages
67
If youve played maps such as DAOW or AW:LR, you'll know that income is recieved every minute, depending on how many control points you have.

How can I make a capturable building (with triggers?) that grants income every minute? And im new to triggers, so please try to keep it simplish.

Ok thank you!
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
Try this:

  • Trigger
    • Events
      • Time - Every 60 seconds of game time
    • Conditions
    • Actions
      • Player - Add (X x (Number of units in (Units owned by Player X of type X))) to Player X Current gold
The event is a ''Time - Periodic Event'' and the action is a ''Player - Add Property''.
 
Try this:

  • Trigger
    • Events
      • Time - Every 60 seconds of game time
    • Conditions
    • Actions
      • Player - Add (X x (Number of units in (Units owned by Player X of type X))) to Player X Current gold
The event is a ''Time - Periodic Event'' and the action is a ''Player - Add Property''.

Your trigger leaks, and will make game unplayble if used for many players long enough or if the interval will be lower.
Additionaly you use GroupEnumUnitsOfType() function, which should be omited in case GroupEnumUnitsInRange() mixed with boolexpr that checks unit-type can replace it. If you want to stick with it however, to have to declare group parameter and destroy it afterwards manually.

Although, I recommend to stick with standard function and use the bj.

  • Trigger
    • Events
      • Time - Every 60 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Player - Add (X x (Number of units in (Units in (Playable map area) matchin (((Owner of (Matching unit)) Equal to Player X) And ((Unit type of (Matching unit)) Eqaul to <type X>)) to Player X Current gold
Things tha leak is your next lecture.
 
Yeah, fair enough. I never really deal with leaks (except for spells).
Your Player acton seems a bit cumbersome though, and it does the exact same thing as the one I used.
I guess you quite don't understant the Unit-type grouping functions. To prevent leaks in such case you have to:

  • Set tempg = (Units owned by Player X of type X)
  • Player - Add (X x (Number of units in tempg)) to Player X Current gold
  • Custom script: call DestroyGroup(udg_tempg)
If you use GroupEnumUnitsInRange() you can just insert bj_wantDestroyGroup and group is destryed automaticaly.
 
Status
Not open for further replies.
Top