• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Triggers for Income Lagg

Status
Not open for further replies.
Level 4
Joined
Jul 22, 2012
Messages
72
Ok I have a trigger that works fine and dosn't leak but every minute when u get you income It laggs, is there anyway I can fix this? (I have about 60 points that give u gold per min, and I need them all in my map)
 
Level 4
Joined
Jul 22, 2012
Messages
72
ok here ya go I have 3 triggers for each point.

Events-Map Intialization
Conditions
actions
Custom Script: set bj_wantsDestroyGroup=true
Units Group-Pick Every Unit in (Playable Map Area) Matching ((Unit Type of (Matching Unit))Equal to(Unit type ____))) And Do Actions)
Loop Actions
Trigger-Add to ____ The Event(Unit -(Picked Unit) Takes Damage)
 
Level 4
Joined
Jul 22, 2012
Messages
72
Next Trigger is

Events
Unit- _______ Life becomes less then 0.00
Conditions
(Life of _______) Less Then 50.00
Actions
Units Change ownership of _____ To (Owner of damage sorce)) and Change Color
Unit-Set life of _____ to 100.00%
 
Level 4
Joined
Jul 22, 2012
Messages
72
And last but not least
Event
Time=Every 60.00 seconds of game time.
Conditions
Actions
Player group- Pick player in (All player) and do (actions)
Loos Action
Custom Script: set bj_wantDestroyGroup=true
unit Group-Pick every unit in (Units in((Playable map area) Matching ((Unit type of(Matchign unit)) Equal to _____)) and do (Actions)
Loop actions
Player add 30 to (Owner of ____) Current gold
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Post them in [TRIGGER][/TRIGGER] tags to look like this:

  • WHATEVER NAME THIS TRIGGER IS
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantsDestroyGroup=true
      • Unit Group - Pick Every Unit in (Playable Map Area) Matching ((Unit Type of (Matching Unit))Equal to(Unit type ____))) And Do Actions)
        • Loop - Actions
          • Trigger - Add to ____ The Event(Unit -(Picked Unit) Takes Damage)
  • YOUR NEXT TRIIGER
    • Events
      • Unit - _______ Life becomes less then 0.00
    • Conditions
      • (Life of _______) Less than 50.00
    • Actions
      • Unit - Change ownership of _____ To (Owner of damage sorce)) and Change Color
      • Unit - Set life of _____ to 100.00%
Right Click the name of the trigger in the right panel in the trigger editor then select 'Copy As Text' from the dropdown menu then CTRL+V between [TRIGGER][/TRIGGER] tags.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Reduce the complexity of the income system. Many people foolishly make them O(n) as they iterate through lots of units possibly even multiple times. If you keep track of the number of a unit type in a variable then you can perform an income operation with a complexity of O(1) by deferring counting to events such as unit creating and death. The counting also becomes more simple as you already know how many units existed before the event occurred.
 
Level 4
Joined
Jul 22, 2012
Messages
72
Gilnease Trigger
Events
Map initialization
Conditions
Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to (Unit-type of Gilneas/30g a min 1157 <gen>))) and do (Actions)
Loop - Actions
Trigger - Add to Gilnease <gen> the event (Unit - (Picked unit) Takes damage)



Gilnease
Events
Unit - Gilneas/30g a min 1157 <gen>'s life becomes Less than 0.00
Conditions
(Life of Gilneas/30g a min 1157 <gen>) Less than 50.00
Actions
Unit - Change ownership of Gilneas/30g a min 1157 <gen> to (Owner of (Damage source)) and Change color
Unit - Set life of Gilneas/30g a min 1157 <gen> to 100.00%



Ilnease
Events
Time - Every 60.00 seconds of game time
Conditions
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Gilneas/30g a min)) and do (Actions)
Loop - Actions
Player - Add 30 to (Owner of Gilneas/30g a min 1157 <gen>) Current gold
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
You keep track of the number of units in an integer variable. If it is per player then use an array where the index represents the player slot number. When a unit of the appropriate type enters the world you increment the variable. When a unit of the appropriate type dies you decrement the variable. You can then periodically use the variable to calculate the income from.
 
Level 4
Joined
Jul 22, 2012
Messages
72
I still Don't get it, The Trigger is just for A place like, a control point, and when u take it, it gives you (Gold) per min dosn't matter about units. So If u took stormwind u get 50g a min no matter what unless a differnt team (or Player) takes it from you. So do I need to delete one of the triggers or what?
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Except you are iterating through every unit on the map for every player using JASS which is a very slow scripting language.

If you have 500 units on the map that is a total of 8000 iterations through units performed. Computers are fast but not that fast.

You need to use an income system which is more efficient.
 
Level 4
Joined
Jul 22, 2012
Messages
72
Any chance u could help me with one? I am using normal world editor, and Just want A basic income system, where u get 25g a min from that place unless taken from you, and Gets full health when u take it and becomes ur's. Guess Someone told me wrong trigger then = (
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Use a global integer array to map strategy points owned to player slot number (index into array is player slot number). Every time a player gains a strategy point you increment the variable for the player by 1. Every time a player loses a strategy point you decrement the variable for the player by 1. Every 60 seconds you iterate through all players and add 25 times the number stored in the array to gold for that player.
 
Status
Not open for further replies.
Top