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

Complex Convoluted Car Triggers - Need Help

Status
Not open for further replies.
Level 6
Joined
Aug 12, 2007
Messages
201
I'm having a ton of trouble with my cars and any help would be appreciated. Here are the triggers I'm using right now:

  • CarInteract
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Interact
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of ability being cast)) Equal to Automobile (Pale Red Ford Falcon)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Target unit of ability being cast)) Equal to Player 12 (Brown)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Target unit of ability being cast) has an item of type Car Battery) Equal to True
                  • ((Target unit of ability being cast) has an item of type Tires) Equal to True
                  • ((Target unit of ability being cast) has an item of type Engine) Equal to True
                  • ((Target unit of ability being cast) has an item of type Fuel) Equal to True
                • Then - Actions
                  • Set CarDriverArray[(Player number of (Triggering player))] = (Triggering unit)
                  • Unit - Change ownership of (Target unit of ability being cast) to (Owner of (Triggering unit)) and Change color
                • Else - Actions
            • Else - Actions
          • Unit - Set the custom value of (Triggering unit) to ((Player number of (Owner of (Target unit of ability being cast))) + 1)
          • Set TempPoint2 = (Position of (Triggering unit))
          • Set InCarArray[(Player number of (Triggering player))] = (Target unit of ability being cast)
          • Unit - Move (Triggering unit) instantly to (Center of InCar <gen>)
          • Unit - Pause (Triggering unit)
          • Selection - Remove (Triggering unit) from selection for (Owner of (Triggering unit))
          • Unit - Create 1 VisionDummy for (Owner of (Triggering unit)) at TempPoint2 facing Default building facing degrees
          • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Night Elf Druid Of The Talon - Faerie Fire InCarArray[(Player number of (Owner of (Triggering unit)))]
        • Else - Actions
  • MovePlayerBack
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Exit Car
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Sold unit)) Equal to (Owner of InCarArray[(Player number of (Owner of (Sold unit)))])
        • Then - Actions
          • Unit - Change ownership of InCarArray[(Player number of (Owner of (Sold unit)))] to Player 12 (Brown) and Change color
        • Else - Actions
      • Unit - Unpause UnitArray[(Player number of (Owner of (Sold unit)))]
      • Unit - Move UnitArray[(Player number of (Owner of (Sold unit)))] instantly to (Position of InCarArray[(Player number of (Owner of (Sold unit)))])
      • Unit - Remove All buffs from InCarArray[(Player number of (Owner of (Sold unit)))]
      • Unit - Remove (Sold unit) from the game
  • CarDeathCondition
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Automobile (Pale Red Ford Falcon)
    • Actions
      • Set UnitsInPlayableMapArea = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitsInPlayableMapArea and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Equal to ((Player number of (Owner of (Triggering unit))) + 1)
            • Then - Actions
              • Unit - Kill (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitsInPlayableMapArea)
This is by no means a perfect system, more like a jury rigged mess that I can't get to act stable. What I want my cars to do is this: When the car has all the car parts in its inventory, using Interact on it moves you off into a closed portion of the map and gives you control of the car. Anyone else who uses interact on the car is moved off as well but they don't get control of the car. If the car parts aren't all there, you still get into the car but it stays immovable under player 12's control. That is my first problem, checking to see if it has a driver already. That alone is not the problem, its easy, its the next part coming up that it has issues with. When the car dies, I want it to kill all the players that are inside of it. I'm having a ton of issues trying to 'mark' which units are in which car and when that car dies, they die with it. I have no knowledge of Jass or how to set local variables, so unless you have a ton of time to help me, I'd prefer it to be GUI.

Right now with those triggers most of what I said works save for killing the units, I don't have a sound way of checking what unit is holding who yet at all.

And no, using Cargo Hold to physically store the units in the car is not an option as far as I make of it, because you can't play units from other teams into your cargo hold.

Also if it helps, it is not possible for a player to be controlling more then one car at a time as you only control one unit, a single hero, at a time in this map, so MUI via Arrays is fine.

Right now I am wishing there was a way to set sort of artificial 'Children to Parent' relationship between the Car and the units, so that if I killed that Car unit, all the Children units would die as well.
 
Level 8
Joined
Apr 30, 2009
Messages
338
For your problem with matching a driver to a car, you should use a hashtable.

Save unit handle:
save handle of (driver_unit) as "driver" of key(car_unit) in hashtable(car_data)

then when you want to manipulate the driver (like kill it) you can:

Event- a unit dies

Condition- (Triggering Unit) = a car

Action- kill unit: load "dirver" of key(Triggering Unit) from (car_data)
 
Status
Not open for further replies.
Top