HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Esc Key Pressed

10-05-2008, 07:30 AM#1
TheXenocide
I have created an advanced building menu by morphing a unit into another unit and I have worked out most of the bugs; however, after the unit is morphed into the advanced builder I want to automatically morph it back to the original unit, so it seem seamless to the user. There are (at least) 3 cases when this needs to happen:
1) The unit becomes unselected
2) The unit builds an advanced building
3) The controller presses the <Esc> key, or selects cancel

I have fixed problems 1 & 2, but I have been unsuccessful in finding a solution for 3.

I would prefer not to have the user manually switch the units back.

Any ideas?

Thanks.

EDIT: I just realized that the morph ability is messing with the mana of the units. Is there anything that can be done to fix it (preferably without multi-instantiable triggering necessary)? This is my best attempt to fix it:
Trigger:
Advanced Buildings
Collapse Events
Unit - A unit Begins casting an ability
Conditions
Collapse Actions
Set Temp_mana = (Mana of (Triggering unit))
Set Temp_max_mana = (Max mana of (Triggering unit))
Set Temp_life = (Life of (Triggering unit))
Set Temp_max_life = (Max life of (Triggering unit))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Ability being cast) Equal to Advanced Buildings (spiritwolf)
Collapse Then - Actions
Unit - Order (Triggering unit) to Stop
Unit - Add Morph (Blue/Green) to (Triggering unit)
Unit - Set life of (Triggering unit) to Temp_life
Advanced - For (Triggering unit) Decrease mana maximum by 1000
Advanced - For (Triggering unit) Increase mana maximum by (Integer(Temp_max_mana))
Unit - Set mana of (Triggering unit) to Temp_mana
Game - Force (Owner of (Triggering unit)) to press the key B
Else - Actions
10-05-2008, 09:55 AM#2
grim001
The user pressing Escape can be detected with the the playerevent EVENT_PLAYER_END_CINEMATIC.
10-05-2008, 02:25 PM#3
Bobo_The_Kodo
Or in GUI; A player skips a cinematic sequence
10-05-2008, 08:20 PM#4
TheXenocide
Thanks for the quick replies. That works great when the user actually presses the <Esc> key, but I still don't know of a way to determine when the user clicks the cancel button. Is there a way to determine button click events? or some other workaround?

Also, there is still a problem with the morph ability that causes the amount of mana to change. Is there a way to fix it so that the unit has the proper amount of mana before, during, and after being morphed?
10-05-2008, 10:01 PM#5
Pyrogasm
Yeah, but it requires you to run a very fast periodic trigger that forces the player controlling the unit to press a UI key, such has K. In the Object Editor, you'll need to create an instant-cast ability with the same key as its hotkey (in this case K).

When the player switches to the advanced build menu, add the ability to the unit, and when he does anything other than cancel, remove the ability.

The final thing you must do is detect when the unit is ordered the orderid of the ability you created (so if you based it on Roar, check for "roar"). If a unit is ordered this order and is of the proper type, then you know that the unit is an advanced builder that a player has just pressed the cancel button.
10-06-2008, 04:22 AM#6
TheXenocide
Thanks Pyro, that worked great. The reason that the mana was getting messed up was because I was adjusting the maximum mana of the units in game, this causes wierd issues with morph. After trying everything I could think of, I completely re-did the way in which I deal with mana (map specific) so that it would work properly.

Thanks,
-Xeno
10-06-2008, 05:05 AM#7
Pyrogasm
Sure thing. I'm surprised you deciphered what it is you needed to do from my post. Something that complex usually takes a more detailed explanation xD.