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

[Solved] Events and player numbers

Status
Not open for further replies.
Level 9
Joined
Jun 1, 2008
Messages
180
Really small question. Whenever a unit starts an ability, can I get the player's number as triggering player, or the owner of triggering unit? So far I've been thinking that both should work, but my map got so effin bugged that I'm not so sure about it. Pretty much the whole stuff is screwed, so I'd be really happy if this was the mistake I made. :vw_sleep:
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
It's really, really easy to test this yourself, you know?
All you had to do was put this trigger in a map:
  • Melee Initialization
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of (Triggering player))
Place a few heroes and done.

Answer: yes, both work.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Why give up the project? :/

Here's another interesting idea: try debugging the trigger ;)
I say this to many people: debugging is a 'tool' that programmers often use, and is extremely helpful.

Here's an easy example of a spell that doesn't always work:

  • Test
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set caster = (Casting unit)
      • Wait 5.00 seconds
      • Special Effect - Create a special effect attached to the overhead of caster using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Here is how it looks like, debugged:

  • Test
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Spell cast
      • Set caster = (Casting unit)
      • Game - Display to (All players) the text: (caster1: + (Name of caster))
      • Wait 5.00 seconds
      • Game - Display to (All players) the text: (caster2: + (Name of caster))
      • Special Effect - Create a special effect attached to the overhead of caster using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Game - Display to (All players) the text: Spell Finished
When I run this trigger a few times, I suddenly notice that the "caster2"-message is sometimes incorrect.
Now I know immediately where my problem lies and can start from there, instead of staring at the trigger for a while.
(This can be solved by simply using "triggering unit" instead of a variable).


Of course, this example is really easy, but it shows the technique on how to do it.
Just place game messages for all important data (coordinates, unit name, player name, or just "condition true" / "condition false", things like that).
Once you see a piece of data that is not what you want, you know where the error is.
Simple and effective. (And it saves the pain of asking others the entire time: with this, you can easily rely on yourself).
 
Level 9
Joined
Jun 1, 2008
Messages
180
I've been trying to do that kinda stuff. Will give it another go again, but it's totally random. It's mostly not about things being left out, the stuff that's happening just doesn't make any sense. For example, there is a unit that's been summoned for player 1 for example, and there's a different one for player 2. When player 2's unit should disappear, it suddenly turns into the model of player 1's unit. Also a different problem is related to the way I wanted to do the animation. You should know that this is a fighting game styled map, side view, whatever, and because of all the animations, I'm constantly deleting units and making new ones, just so it runs smoothly and is as fast as it can be. Most of the time it works perfectly, then suddenly the unit is no longer created in the region I want it to be in, but on the center of the map area. It just doesn't make any sense. We've tried every single ability (as it's an issue that's caused by some sort of interaction between the 2 units), and it happens randomly. Just weird...
Anyway, I'll try your solution. The only problem is that I don't have anyone to test with. At first I thought that it was coming from the numbers - that I can't set 1 or 2 correctly for variables, but after trying it in single both as player 1 and player 2, that didn't seem to be the case. The triggers need some sort of interaction with another player to fail.
Thanks for the helpful suggestion!
 
Status
Not open for further replies.
Top