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

Problem with unit ownership

Status
Not open for further replies.
Level 8
Joined
Sep 15, 2006
Messages
426
My problem is: I have a unit that is controlled with the arrow keys, therefore I have events that look like "Owner of (Mech 00) Presses the Left Arrow Key". These work fine when I give the player ownership straight up, but in my map I need to be able to take away the ownership and return it. Whenever that happens, the controll triggers stop working. What's the problem here?
 
Level 8
Joined
Jan 18, 2007
Messages
331
well becous your camera trigger is triggered with a owner of mech 00 you shuld add run trigger (that camera trigger) to the trigger you use to "restore" the unit ownership with. try that (oh the run trigger is under trigger in the actions file=))
 
Level 8
Joined
Sep 15, 2006
Messages
426
I'm not sure how running the trigger would have any affect, given that the trigger doesn't seem to understand that I actually own the unit. Or am I missing something? I DO know where stuff is in WE. I've been using it for a long time :smile:
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
You need to understand how Events work to fix this --

Code only runs when it's told to. Thus, the "Create event" code only runs, logically, when it needs to Create the event (in this case at map initialization for all GUI triggers).

However, that means that it will run off whatever Owner of (Mech 00) was at the time. Since it doesn't ever run that initializer for the trigger again, it doesn't check back.

To fix this, try, whenever you change the ownership, doing this;

  • Custom script: call DestroyTrigger( gg_trg_ArrowKeyMoveTriggerNameHere )
  • Custom script: call InitTrig_ArrowKeyMoveTriggerNameHere()
replacing ArrowKeyMoveTriggerNameHere with your arrow key trigger's name
 
Level 8
Joined
Sep 15, 2006
Messages
426
You sure "call InitTrig_ArrowKeyMoveTriggerNameHere()" is right? I get an error saying that it expects a function name every time I use it.
 
Level 8
Joined
Sep 15, 2006
Messages
426
I'm only new enough to JASS to not be able to figure this stuff out for myself. I know to put in the names of my triggers. :) Thanks a lot for the help though.
 
Status
Not open for further replies.
Top