• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

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''.
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
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.
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
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