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

[Trigger] Help with a "-give X" command

Status
Not open for further replies.
Level 2
Joined
Sep 19, 2010
Messages
7
Hey.
I'm trying to create a -give command, which is supposed to give the selected units of a player to another. It technically works. But it causes selection bugs, where you can end up giving a random unit. It also makes you unable to do anything sometimes. (Except for chatting) The picture should explain a lot as well.

Some help as to what's the problem is very appreciated.

n6FGRcX.png
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Why do you have the condition If (Owner of (Picked unit)) Equal to (Triggering player) ?

If I were you, I give those all Heroes to Neutral Passive first, then later change ownership.

Take a look at this test map.
 

Attachments

  • Hero Selection -give.w3x
    12.8 KB · Views: 41
Level 14
Joined
Jun 27, 2008
Messages
1,325
Why do you have the condition If (Owner of (Picked unit)) Equal to (Triggering player) ?

If I were you, I give those all Heroes to Neutral Passive first, then later change ownership.

Take a look at this test map.

uhm im pretty sure hes not trying to build a hero selection.

but Nzill, i dont really get your problem. What exactly isnt working (explain the "where you can end up giving a random unit.").

If you plan on creating one trigger for every player (so that every player has access to all commands) you might wanna look for a better solution than creating 12 triggers manually.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
LOL I misunderstood the topic =,="

He wanted to do a trigger that allows you to give your own units, to other players of your own selection, right ?

Example: -give 3

This will give your currently selected units to Player 3, right ?

It's better to use integer, rather than string, such as red/blue/yellow/etc.

Because Integer, you can relate with Player Number, more efficient.

EDIT:
Here's the edited test map.
 

Attachments

  • Hero Selection -give.w3x
    13.7 KB · Views: 39
Level 2
Joined
Sep 19, 2010
Messages
7
I'm not exactly the best concerning triggers by the way. :p
Muzzel: For example, after you typed the -give command, and gave something to someone, bugs would occur. If you for example typed "-give teal" you'd maybe give a random unit to teal, that you didn't even have selected.

Defskull: 10, 11 and 12 doesn't work for some reason. But besides that, I'd prefer to have a it you type red/blue/yellow/etc. It seems as if the colour name is the most used, and therefore seems more user-friendly.
Btw, your map crashes if you type "-give (anything but a number here)"
 
Level 2
Joined
Sep 19, 2010
Messages
7
Well well. I found out, after some testing, that it still doesn't work proper. It does certainly seem to fail less often than before. Assume you have unit X and Y selected, but it might be that both are given and unit C is given as well.
 
Level 2
Joined
Sep 19, 2010
Messages
7
I'm horrible at explaining... I'll try again.
Anyway, it's an example. Assume you have two units controlled, and you write the command. (-give blue, or whatever colour really.) And, what then might happen, is that the two units at given. But a random unit of yours, elsewhere on the map, might -also- be given to the player.
Does this make a bit more sense?
 
Level 8
Joined
Feb 3, 2013
Messages
277
I think you got it fixed,
but in case you didn't
your ifelse statement is wrong
it should be
if owner of picked unit is not equal to triggering player.

still i think this trigger will still have a lot of loopholes and you should approach it another way
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,894
  • Give
    • Events
      • Player - Player 1 (Red) types a chat message containing -give as A substring
    • Conditions
      • (Integer((Substring((Entered chat string), 6, 8)))) Not equal to (Player number of (Triggering player))
    • Actions
      • Set SelectedGroup = (Units owned by (Triggering player) matching (((Matching unit) is selected by (Triggering player)) Equal to True))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SelectedGroup is empty) Equal to False
        • Then - Actions
          • Unit Group - Pick every unit in SelectedGroup and do (Actions)
            • Loop - Actions
              • Unit - Change ownership of (Picked unit) to (Player((Integer((Substring((Entered chat string), 6, 8)))))) and Change color
              • Custom script: call DestroyGroup(udg_SelectedGroup)
        • Else - Actions
Here. Tested and it seemed any random unit of mine wasn't given to the other player.
 
Last edited:
Status
Not open for further replies.
Top