Car Help

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Hey guys,

What I'm trying to do is make a system where a player unit can own a car. What I need from the system is to only allow the player's car to move when a unit owned by the player who has the car keys in their inventory is loaded into the car.

Here's what I got in terms of buying the car:

Trigger 1:
Code:
Buying a Car
    Events
        Player - Player 1 (Red) Selects a unit
    Conditions
        (Triggering unit) Equal to Salesman (Male 2) 0019 <gen>
        CarOwned Equal to False
    Actions
        Unit Group - Pick every unit in (Units within 256.00 of (Position of (Triggering unit))) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Owner of (Picked unit)) Equal to Player 1 (Red)
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                CarDialogCreated Equal to False
                            Then - Actions
                                Dialog - Change the title of BuyingCarDialog to Do you Wish to Buy ...
                                Dialog - Create a dialog button for BuyingCarDialog labelled Yes, here's 200 gol...
                                Set BuyingCarDialogButtons[1] = (Last created dialog Button)
                                Dialog - Create a dialog button for BuyingCarDialog labelled I don't have that s...
                                Set BuyingCarDialogButtons[2] = (Last created dialog Button)
                                Dialog - Show BuyingCarDialog for Player 1 (Red)
                                Set CarDialogCreated = True
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                CarDialogCreated Equal to True
                            Then - Actions
                                Dialog - Show BuyingCarDialog for Player 1 (Red)
                            Else - Actions
                        Trigger - Turn on Buying a Car Dialog Button Clicked <gen>
                    Else - Actions

Trigger 2:
Code:
Buying a Car Dialog Button Clicked
    Events
        Dialog - A dialog button is clicked for BuyingCarDialog
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 1 (Red) Current gold) Less than 200
            Then - Actions
                Game - Display to (All players) the text: You don't have enou...
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Clicked dialog button) Equal to BuyingCarDialogButtons[1]
                (Player 1 (Red) Current gold) Greater than or equal to 200
            Then - Actions
                Dialog - Hide BuyingCarDialog for Player 1 (Red)
                Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - 200)
                Special Effect - Destroy SpecialEffect[1]
                Hero - Create Car Keys and give it to PlayerUnit
                Set CarKeys = (Last created item)
                Set CarKeyHolder = PlayerUnit
                Set CarKeyIDNo = (Random integer number between 100000 and 999999)
                Item - Set the custom value of CarKeys to CarKeyIDNo
                Multiboard - Set the text for Multiboard item in column 2, row 6 to (String(CarKeyIDNo))
                Set CarOwned = True
                Set CarInteger = (CarInteger + 1)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 1
                    Then - Actions
                        Unit - Change ownership of Car 0001 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of Car 0001 <gen> to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 2
                    Then - Actions
                        Unit - Change ownership of Car 0002 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 3
                    Then - Actions
                        Unit - Change ownership of Car 0003 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 4
                    Then - Actions
                        Unit - Change ownership of Car 0004 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 5
                    Then - Actions
                        Unit - Change ownership of Car 0005 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 6
                    Then - Actions
                        Unit - Change ownership of Car 0006 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 7
                    Then - Actions
                        Unit - Change ownership of Car 0007 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 8
                    Then - Actions
                        Unit - Change ownership of Car 0008 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 9
                    Then - Actions
                        Unit - Change ownership of Car 0009 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 10
                    Then - Actions
                        Unit - Change ownership of Car 0010 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 11
                    Then - Actions
                        Unit - Change ownership of Car 0018 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 12
                    Then - Actions
                        Unit - Change ownership of Car 0017 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 13
                    Then - Actions
                        Unit - Change ownership of Car 0016 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 14
                    Then - Actions
                        Unit - Change ownership of Car 0015 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 15
                    Then - Actions
                        Unit - Change ownership of Car 0014 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 16
                    Then - Actions
                        Unit - Change ownership of Car 0013 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 17
                    Then - Actions
                        Unit - Change ownership of Car 0012 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CarInteger Equal to 18
                    Then - Actions
                        Unit - Change ownership of Car 0011 <gen> to Player 1 (Red) and Change color
                        Unit - Set the custom value of (Last created unit) to CarKeyIDNo
                        Set PlayerCar = (Last created unit)
                    Else - Actions
                Unit - Pause PlayerCar
                Trigger - Run Car Info <gen> (checking conditions)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Clicked dialog button) Equal to BuyingCarDialogButtons[2]
            Then - Actions
                Dialog - Hide BuyingCarDialog for Player 1 (Red)
                Game - Display to (All players) the text: |ccffffcc00Salesman...
            Else - Actions


My question is: how do I make a system that only allow the player's car to move when a unit owned by the player who has the car keys in their inventory is loaded into the car?
 

Whoareyou.

New Member
Reaction score
24
Trigger:
  • Events
    • Unit - A unit Is loaded into a transport
    • (Item carried by (Triggering unit) in slot 1) Equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 2) Equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 3) Equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 4) Equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 5) Equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 6) Equal to Car Keys &lt;gen&gt;
    • Actions
      • Do nothing


Or

Trigger:
  • Events
    • Unit - A unit Is loaded into a transport
    • Conditions
    • (Item carried by (Triggering unit) in slot 1) Not equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 2) Not equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 3) Not equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 4) Not equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 5) Not equal to Car Keys &lt;gen&gt;
    • (Item carried by (Triggering unit) in slot 6) Not equal to Car Keys &lt;gen&gt;
    • Actions
      • Unit - Human &lt;gen&gt; to Stop
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
I tried that, but that set of actions doesn't quite do what I want to do.

What I need is a trigger (or set of triggers) which says that unless the player's unit which has the car keys is in the car, the car cannot move at all.
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
How do i create an ability with no effect? Because then I'll change the ownership of the car and load the car key holder into the car after the car key holder has cast the ability on the car.
 

Ryushi

"I will stand, or I will fall. I will not sit."
Reaction score
59
You could base the ability off of Channel, and change it's target type to Unit Target. Everything else can be changed so the ability has no effect.

EDIT:
You could use these triggers to get the effect you initially wanted:
Trigger:
  • Trigger 1
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Your Car Unit)) and do (Actions)
        • Loop - Actions
          • Set Boolean = False
          • Set TempUnit = (Picked unit)
          • Unit Group - Pick every unit in UnitGroup and do (Actions)
            • Loop - Actions
              • For each (Integer A) from 1 to 6, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Item carried by (Picked unit) in slot (Integer A))) Equal to Your Key Item
                      • ((Picked unit) is loaded into TempUnit) Equal to True
                    • Then - Actions
                      • Set Boolean = True
                    • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Boolean Equal to True
            • Then - Actions
              • Actions that allow movement of car
            • Else - Actions
              • Actions that prevent movement of car

Trigger:
  • Trigger 2
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
    • Actions
      • Unit Group - Add (Loading unit) to UnitGroup
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Something Like This?: Ability.jpg
 

Ryushi

"I will stand, or I will fall. I will not sit."
Reaction score
59
You have the right idea, the problem is that healing wave is hard coded so that it cannot be used on units at full health. You could base that ability off of Chain Lightning, and do relatively the same thing, or you could base it off of Channel.
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Here's what I got for loading the unit in:

Trigger:
Code:
Unit Loads
    Events
        Unit - A unit Begins casting an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to Load (Custom)
                (Target unit of ability being cast) Equal to PlayerCar
            Then - Actions
                Cinematic - Disable user control for Player Group - Player 1 (Red)
                Unit - Change ownership of PlayerCar to Player 1 (Red) and Retain color
                Unit - Move CarKeyHolder instantly to (Position of PlayerCar)
                Unit - Order PlayerCar to Load CarKeyHolder
                Cinematic - Enable user control for (All players)
                Selection - Add PlayerCar to selection for Player 1 (Red)
            Else - Actions

Also See the image attached. I'm yet to make the unload trigger, but I'm working on that now.

Ability.jpg
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Sorry to Double Post, but how do I get my car to unload all the units remaining in its cargo through triggers?

(P.S. 200th Post :D)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top