• 🏆 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!

How to create a trigger which function if the player has the highest lumber and the

Status
Not open for further replies.
Level 6
Joined
Mar 9, 2009
Messages
175
How to create a trigger which function if the player has the highest lumber and the player has won ???


Guys help me ooo :grin::grin::grin:

thanks!! man!:goblin_boom:
 
  • Melee Initialization
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set Lumber = (Player 1 (Red) Current lumber)
      • Set X = 1
      • For each (Integer i) from 2 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(i)) controller) Equal to User
              • ((Player(i)) slot status) Equal to Is playing
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Lumber Greater than ((Player(i)) Current lumber)
                • Then - Actions
                  • Set X = i
                  • Set Lumber = ((Player(i)) Current lumber)
                • Else - Actions
            • Else - Actions
      • Game - Victory (Player(X)) (Show dialogs, Show scores)
This should work if only 1 player can win!
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
A test map is attached
To test this map:
1. Press ESC as many times as you want and the current lumber is displayed on screen
2. When you've satisfied with the shown values, type -check to check who has the highest lumber and will show who has win the current round and all player's lumber will be reset to 0 (for repetitive testing purposes)
 

Attachments

  • Simple Calculate Resource System.w3x
    14.2 KB · Views: 46

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Ok you have 3 different activation events that you need to filter.

The first is simple. Whenever a player wins which can be referenced by binding a trigger with TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_VICTORY) or the BJ (for use in GUI) which references it. When a player wins you add them to a force (player group in GUI) and then run the intersection evaluator.

The second just runs the intersection evaluator when a player does anything to reduce lumber.

The other is more complex. If you harvest lumber then you need a perodic event but if lumber is given by triggers you can simply get the triggers which give lumber to run the intersection evaluator (or make your own lumber function which runs it as well for better coding). Remember to only run it when a lumber change is detected.

The intersection evaluator runs through the force of all the players who won. For each one of them it runs it through the standard maximum algorthim. What this means is that it firstly sets an innitial player in a variable (usually local) to a value of null who has a lumber of -1 (negative lumber is not possible as far as I know) stored in another local for efficiency. It then goes through all the players in the force and if that player has a lumber greater than the current player it then updates the current player to him and the max lumber to the lumber he has. Repeat for all players and you will know for sure who has won and has the most lumber. All that is left to do is check if the maximum player is not null (it will be null if no one has won yet) and then run the handler code you want or evaluate the triggers you want to run.

Something tells me you are not describing your problem specification clearly as I doubt the above is what you are after.
 
Status
Not open for further replies.
Top