- Joined
- Oct 27, 2007
- Messages
- 23
this has been done before but i didnt really like any of the others ons so i made one myself.
Arrow Key Movement
1.0
1) Create 3 Variables , named "Up", "Right" , "Left". Make those 3 boolean arrays for the type and make a new variable called Players_Hero with type Unit Array. and another variable named TempPoint and its type point array.
2) Create a map init trigger and set some unit into the Players_Hero variable
3) Create a new trigger named "Up Pressed"
4) add this event to the trigger : Player - Player 1 (Red) Presses the Up Arrow key
5) add the variable up in the actions part and make it look like this
Set Up[(Player number of (Triggering player))] = True
6) Make that for all the arrow keys exept for down.
Example:
1.1
Now we are going to create the "release triggers" you will basicly be doing the same thing as the pressed ones but like this
2.0
Create a new trigger named Movement. this trigger will be detecting the variables to order a unit to move. for example :
if the variable Up is = True then it will move that unit up.
1) create the event Time - Every 0.25 seconds of game time
2) add the action Player Group - Pick all players and do actions
Loop actions
3) in the loop actions part create an If/Then/Else action. so far it should look like this :
4) after that , create under the Then -Actions part the variable TempPoint like this
You're still not done. now for the diaganol movement part. we wont be actually ordering the unit to move diaganol we will move him instantly to point. this is pretty simple so im just going to post the trigger for diaganols.
Arrow Key Movement
1.0
1) Create 3 Variables , named "Up", "Right" , "Left". Make those 3 boolean arrays for the type and make a new variable called Players_Hero with type Unit Array. and another variable named TempPoint and its type point array.
2) Create a map init trigger and set some unit into the Players_Hero variable
3) Create a new trigger named "Up Pressed"
4) add this event to the trigger : Player - Player 1 (Red) Presses the Up Arrow key
5) add the variable up in the actions part and make it look like this
Set Up[(Player number of (Triggering player))] = True
6) Make that for all the arrow keys exept for down.
Example:
-
]Up Press
-
Events
- Player - Player 1 (Red) Presses the Up Arrow key
- Player - Player 2 (Blue) Presses the Up Arrow key
- Player - Player 3 (Teal) Presses the Up Arrow key
- Player - Player 4 (Purple) Presses the Up Arrow key
- Conditions
-
Actions
- Set Up[(Player number of (Triggering player))] = True
-
Events
-
Right Press
-
Events
- Player - Player 1 (Red) Presses the Right Arrow key
- Player - Player 2 (Blue) Presses the Right Arrow key
- Player - Player 3 (Teal) Presses the Right Arrow key
- Conditions
-
Actions
- Set Right[(Player number of (Triggering player))] = True
-
Events
-
Left Press
-
Events
- Player - Player 1 (Red) Presses the Left Arrow key
- Player - Player 2 (Blue) Presses the Left Arrow key
- Player - Player 3 (Teal) Presses the Left Arrow key
- Player - Player 4 (Purple) Presses the Left Arrow key
- Conditions
-
Actions
- Set Left[(Player number of (Triggering player))] = True
-
Events
Now we are going to create the "release triggers" you will basicly be doing the same thing as the pressed ones but like this
-
Up Release
-
Events
- Player - Player 1 (Red) Releases the Up Arrow key
- Player - Player 2 (Blue) Releases the Up Arrow key
- Player - Player 3 (Teal) Releases the Up Arrow key
- Player - Player 4 (Purple) Releases the Up Arrow key
- Conditions
-
Actions
- Set Up[(Player number of (Triggering player))] = False
- Unit - Order PlayersHero[(Player number of (Triggering player))] to Stop
-
Events
2.0
Create a new trigger named Movement. this trigger will be detecting the variables to order a unit to move. for example :
if the variable Up is = True then it will move that unit up.
1) create the event Time - Every 0.25 seconds of game time
2) add the action Player Group - Pick all players and do actions
Loop actions
3) in the loop actions part create an If/Then/Else action. so far it should look like this :
-
Untitled Trigger 001
-
Events
- Time - Every 0.25 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Then - Actions
- Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Events
- Up[(Player number of (Picked player))] Equal to True
- Left[(Player number of (Picked player))] Equal to False
- Right[(Player number of (Picked player))] Equal to False
4) after that , create under the Then -Actions part the variable TempPoint like this
- Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
- Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
-
Movement
-
Events
- Time - Every 0.25 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Up[(Player number of (Picked player))] Equal to True
- Left[(Player number of (Picked player))] Equal to False
- Right[(Player number of (Picked player))] Equal to False
-
Then - Actions
- Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
- Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Right[(Player number of (Picked player))] Equal to True
-
Then - Actions
- Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
- Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards ((Facing of PlayersHero[(Player number of (Picked player))]) + -90.00) degrees)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Left[(Player number of (Picked player))] Equal to True
-
Then - Actions
- Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
- Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards ((Facing of PlayersHero[(Player number of (Picked player))]) + 90.00) degrees)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Events
-
Stop Turn
-
Events
- Time - Every 0.30 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Up[(Player number of (Picked player))] Equal to True
- Left[(Player number of (Picked player))] Equal to True
-
Then - Actions
- Unit - Make PlayersHero[(Player number of (Picked player))] face ((Facing of PlayersHero[(Player number of (Picked player))]) + 65.00) over 0.10 seconds
- Set TempPoint[(Player number of (Picked player))] = ((Position of PlayersHero[(Player number of (Picked player))]) offset by 10.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
- Unit - Move PlayersHero[(Player number of (Picked player))] instantly to TempPoint[(Player number of (Picked player))]
- Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Up[(Player number of (Picked player))] Equal to True
- Right[(Player number of (Picked player))] Equal to True
-
Then - Actions
- Unit - Make PlayersHero[(Player number of (Picked player))] face ((Facing of PlayersHero[(Player number of (Picked player))]) + -65.00) over 0.10 seconds
- Set TempPoint[(Player number of (Picked player))] = ((Position of PlayersHero[(Player number of (Picked player))]) offset by -10.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
- Unit - Move PlayersHero[(Player number of (Picked player))] instantly to TempPoint[(Player number of (Picked player))]
- Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Events
Attachments
Last edited by a moderator: