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

Command Orders and Leaders

Status
Not open for further replies.
Level 18
Joined
Oct 25, 2006
Messages
1,171
Hi everyone.
I'm working on a system which allow players to control LOTS of units without selecting them all. I based my system on custom value, each time a unit is created I give it a custom value (which increases each time) and I create X units with it (who are the rest of the regiment). I add this unit to a unit-group with array Custom Value of trained unit.

So the problem is that I added a trigger to change the leader of the group, if he dies. The trigger works but when I give an order to the new leader, war3 crashes.

Here are the triggers:
  • Training Ended
    • Evénements
      • Unité - A unit ends training of a unit
    • Conditions
    • Actions
      • Unité - Add Leader (ability) to (Trained unit)
      • Unité - Change color of (Trained unit) to Orange
      • Set Temp_Integer = (Temp_Integer + 1)
      • Partie - Display to (All players) the text: (Groupe: + (String(Temp_Integer)))
      • Unité - Set the custom value of (Trained unit) to Temp_Integer
      • Unité - Create (Point-value of (Trained unit)) [here point value of units means number of units in the squad) (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at (Position of (Trained unit)) facing Orientation bâtiment par défaut degrees
      • Groupe unité - Order (Last created unit group) to Attaquer-Avancer vers (Rally-Point of (Triggering unit) as a point)
      • Groupe unité - Add all units of (Last created unit group) to UnitGroup[(Custom value of (Trained unit))]

  • New Leader
    • Evénements
      • Unité - A unit Dies
    • Conditions
      • (Custom value of (Dying unit)) bigger than 0
      • (UnitGroup[(Custom value of (Dying unit))] is empty) Egal Ã* FALSE
    • Actions
      • Set NewLeader = (Random unit from UnitGroup[(Custom value of (Dying unit))])
      • Unité - Set the custom value of NewLeader to (Custom value of (Dying unit))
      • Unité - Add Leader to NewLeader
      • Unité - Change color of NewLeader to Orange

  • Empty Group (To reduce the number of groups)
    • Evénements
      • Unité - A unit Dies
    • Conditions
      • (Custom value of (Dying unit)) bigger than 0
      • (UnitGroup[(Custom value of (Dying unit))] is empty) Egal Ã* TRUE
    • Actions
      • Unité - Set the custom value of (Random unit from (Units in (Playable map area) matching ((Custom value of (Matching unit)) Egal Ã* Temp_Integer))) to (Custom value of (Dying unit))
      • Set Temp_Integer = (Temp_Integer - 1)
      • Partie - Display to (All players) the text: (Groupe: + (String(Temp_Integer)))

  • Attack Avancer
    • Evénements
      • Unité - A unit received an order with a point as target
    • Conditions
      • (Custom value of (Triggering unit)) bigger than 0
      • (Issued order) Egal Ã* (Order(attack))
    • Actions
      • Groupe unité - Order UnitGroup[(Custom value of (Triggering unit))] to Attaquer-Avancer vers (Target point of issued order)

I dont know how to put them in a little box you can minimize and maximize, sorry :)

And if some of you can check memory leaks in the same time, I can thanks them :D

Sorry for french world editor >.<

Bye :)
 
Last edited:
Level 11
Joined
Feb 14, 2009
Messages
884
I suggest that you use trigger and hidden tags. It's really hard to read your triggers now...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Okay, here is my trigger-tutorial:

  1. Open your map and go to the trigger you want
  2. Above "Events", you see the name of the trigger, right-click it and select "Copy as Text"
  3. Now go to the hive and write: "[ hidden=Trigger][ trigger]" (without the space/quotation marks)
  4. after that press CTRL + V (or right-click, paste), now the code will appear
  5. When that's done, write "[/trigger][/hidden]" (without the quotation marks) and you are done
  6. If you wish to make some trigger adjustments (change some names, delete a few useless things, ...), you can do it within the pasted code.

It's about time people learn this...

It will look like this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Create starting units (for all players)
      • Melee Game - Run melee AI scripts (for computer players)
      • Melee Game - Enforce victory/defeat conditions (for all players)
(With another trigger, I hope)
If not, you've done something wrong.

1 more thing:

Triggers & Scripts: for triggers, or anything that is trigger-related
WE Help Zone: for everything that is world editor-related (object data, campaigns, general questions like the fixed random seed, ...).

Where do you think this belongs and where did you put it?
(Report your own post with the message "Move to Triggers & Scripts, please").
 
Level 18
Joined
Oct 25, 2006
Messages
1,171
Ok thanks, I knew for the "'copy as text" command, this is just what I did. I didnt know the "[/trigger][/hidden]".
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Wow, I've learned here is that the French world editor is a piece of cr*p.
It isn't French, neither is it English, some things (like Attaquer-avancer) are French, though the rest of the sentence is English with a few random symbols (most of the time Ã, ©) in between, while those have almost nothing to do with French xD

In any case, this leaks:
  • Unité - Create (Point-value of (Trained unit)) [here point value of units means number of units in the squad) (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at (Position of (Trained unit)) facing Orientation bâtiment par défaut degrees
(Position of (Trained Unit))
I guess the facing orientation is "Bâtiment par default degrees", so it is all right.

  • Groupe unité - Order (Last created unit group) to Attaquer-Avancer vers (Rally-Point of (Triggering unit) as a point)
Leaks "Rally-Point of (Triggering Unit)"

  • Unité - Set the custom value of (Random unit from (Units in (Playable map area) matching ((Custom value of (Matching unit)) Egal Ã* Temp_Integer))) to (Custom value of (Dying unit))
Leaks "Units in (Playable map area)"

  • Groupe unité - Order UnitGroup[(Custom value of (Triggering unit))] to Attaquer-Avancer vers (Target point of issued order)
Leaks "Target point of issued order"


I'll try to figure out why the last trigger crashes the world editor... in the meanwhile, fix the leaks ^^
 
Level 18
Joined
Oct 25, 2006
Messages
1,171
It is not a problem of memory leaks... (but thanks :D)

EDIT: Sorry double posting.

I found why it wasnt working, when I was creating the unit group I was also adding the leader itself to the group. So when I was giving orders to leader triggers ordered him to make again and again the same order.

Anyway thanks for memory leaks.
 
Last edited:
Status
Not open for further replies.
Top