[Trigger] Advanced Driving Question

Status
Not open for further replies.
Level 22
Joined
Jul 25, 2009
Messages
3,087
Okay anyone who wants to help me out, here's what I'm doing. I began working on a map called Black Winter about 4-6 months ago. In this map I plan to include an instance or two where you are driving vehicles, more specifically a tank. What I need to know is how can I:

.1 Get into the tank as a hero, and be able to get out at any time. (Sorta figured out)
.2 Have one player drive and another player fire the cannons or machine guns.
.3 Be able to switch seats. (Switch between driving and firing or maybe even between firing several weapons)

The tank will be driving via right clicking on the location you want to go, for easiness, and firing the weapon in the tank will work the same (Right click where you wanna shoot.) I was thinking I could use a dummy unit as the unit controlled by whoever is using the turret using a grenade spell I made.

This will require a shitload triggering so if you really want to help, perhaps you would like to implement it for me in GUI. I'm not the greatest at triggering.
 
1) You can use Mount - Dismount ability too, but you can also trigger it to hide the hero, once you cast an ability and target a tank, hiding the tank as well, and creating a new tank (hero #2):
  • Tr
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Hashtable = (Last created hashtable)
  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Tank Entrance
    • (Unit-type of (Target unit of ability being cast)) Equal to Tank (normal)
  • Actions
    • Set Points[1] = (Position of (Target unit of ability being cast))
    • Unit - Hide (Target unit of ability being cast)
    • Unit - Hide (Triggering unit)
    • Unit - Create 1 Tank (hero) for (Owner of (Triggering unit)) at Point1 facing (Facing of (Target unit of ability being cast))
    • Hashtable - Save Handle of (Triggering unit) as Key(caster) of (Key(Last created unit)) in Hashtable
    • Hashtable - Save Handle of (Target unit of ability being cast) as Key(tank) of (Key(Last created unit)) in Hashtable
    • Custom script: call RemoveLocation (udg_Points[1])
Give the Tank (hero) an ability, called Exit for example.

  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Exit
  • Actions
    • Set Points[2] = (Position of (Triggering unit))
    • Set Units[1] = (Load Key(caster) of (Key(Triggering unit)) in Hashtable)
    • Set Units[2] = (Load Key(tank) of (Key(Triggering unit)) in Hashtable)
    • For each (Integer A) from 1 to 2, do (Actions)
      • Loop - Actions
        • Unit - Move Units[(IntegerA)] at Point1
        • Unit - Unhide Units[(IntegerA)]
    • Unit - Kill (Triggering unit)
    • Unit - Remove (Triggering unit) from the game
    • Custom script: call RemoveLocation (udg_Points[2])
2) You can do it with the way I showed you above. Obviously the tank will firstly become a hero and then have another unit to become its guns, right? We will combine the following trigger with the first trigger above, since they will be sharing the same ability.
  • Tr
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Tank Entrance
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (Unit-type of (Target unit of ability being cast)) Equal to Tank (normal)
      • Then - Actions
        • Set Points[1] = (Position of (Target unit of ability being cast))
        • Unit - Hide (Target unit of ability being cast)
        • Unit - Hide (Triggering unit)
        • Unit - Create 1 Tank (hero) for (Owner of (Triggering unit)) at Point1 facing (Facing of (Target unit of ability being cast))
        • Hashtable - Save Handle of (Triggering unit) as Key(caster) of (Key(Last created unit)) in Hashtable
        • Hashtable - Save Handle of (Target unit of ability being cast) as Key(tank) of (Key(Last created unit)) in Hashtable
        • Custom script: call RemoveLocation (udg_Points[1])
      • Else - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Unit-type of (Triggering unit)) Equal to Tank (hero)
          • Then - Actions
            • Player - For (Owner of (Triggering unit)), turn Full shared units On toward (Owner of (Target unit of ability being cast)) //Can't find a better action for this :/
            • Hashtable - Save Handle of (Target of ability being cast) as Key(tank) of (Key(Triggering unit)) in Hashtable
            • Unit - Hide (Triggering unit)
            • Selection - Add (Target unit of ability being cast) to selection for (Owner of (Triggering unit))
3) You can find out yourself, now that I posted the triggers you need :]
Just check the owner of the unit. If it's not equal to the owner of the unit that casts the "Switch seats" ability (Player Comparison), then he is the one that fires the tank's guns. Change the ownership of the tank to the owner of this unit (Triggering unit) and make the Owner of the other unit to turn Full shared units On toward (Owner of (Triggering unit)).

Reference:
https://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
 
Status
Not open for further replies.
Back
Top