With the performance success of Hotel vs Zombies i figured i would share how i made the shooting so smooth. As many people know i am a trigger whore, i do not like to use the data editor for in depth things. So, i made a projectile system from the trigger editor and of course, it works perfectly!
Alot of people have been asking me for some of my code and until now i never really share anything but the way i see it is. I am tired of making 12893719387 maps because no one else is making the type of maps i am for some reason. So, ill give people a boost here and hopefully i can play some fun content i could have made but didnt have to thanks to the creativity and time of others :)
Here is a sample of how i did it.
*Firing Projectiles*
P1 Engineer Rocket Launcher
Events
UI - Player 1 clicks Right mouse button Down.
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Played Controlled Unit[1] Energy (Current)) >= 20.0
Then
Unit - Set Played Controlled Unit[1] Energy to ((Played Controlled Unit[1] Energy (Current)) - 20.0)
Unit - Pause Played Controlled Unit[1]
Unit - Make Played Controlled Unit[1] face (Current camera yaw of player 1) over 0.0 seconds
Animation - Play Attack Right animation for (Actor for Played Controlled Unit[1]) as Default, using Non Looping, Model Driven Looping options and Default Time blend time
Sound - Play Immortal_AttackLaunch (1) for (All players) on Played Controlled Unit[1] with Z offset 0.0 (at 100.0% volume, skip the first 0.0 seconds)
Unit - Create 1 SCV for player 1 at ((Position of Played Controlled Unit[1]) offset by 1.0 towards (Facing of Played Controlled Unit[1]) degrees) using default facing (No Options)
Unit - Set forced status bar state on (Last created unit) to Off
Unit - Turn (Last created unit) Status Bar state Off
Unit - Order (Last created unit) to ( Move targeting ((Position of Played Controlled Unit[1]) offset by 20.0 towards (Facing of Played Controlled Unit[1]) degrees)) (Replace Existing Orders)
Unit - Unpause Played Controlled Unit[1]
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
(Played Controlled Unit[1] Energy (Current)) < 20.0
Then
Sound - Play Alert_TerranNotEnoughEnergy (1) for Player 1 (at 100.0% volume, skip the first 0.0 seconds)
UI - Display "Not Enough Energy!!" for Player 1 to Directive area
General - Wait 2.0 Real Time seconds
UI - Clear Directive Messages for Player 1
Else
*How to detect collision of projectiles*
Projectile Collision (Rocket Launcher)
Events
Unit - Any Unit Enters _______ (Insert Region aka Hit box here)
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Owner of (Triggering unit)) == 1
(Unit type of (Triggering unit)) == SCV
Then
Environment - Create a Large Terran explosion at (Position of (Triggering unit))
Environment - Deal damage using Raven - Seeker (Damage) on (Unit attached to (Triggering region)) from Played Controlled Unit[1] with 0.0 extra damage
Unit - Kill (Triggering unit)
All you have to do is change the models for the SCV (Projectile) and increase its movement speed :).
My baneling for the bomberman map use the same mechanics. But rather than use hitbox as region and you have to move the region around, i use auto cast abilities on the projectile unit itself. Which works even better.
the second if in the first trigger is sensless.
the movementspeed can be increased by triggers, too.
also: is the trigger only for player 1 or why do u use a fixed array index? :)
My baneling for the bomberman map use the same mechanics. But rather
than use hitbox as region and you have to move the region around, i use
auto cast abilities on the projectile unit itself. Which works even
better.
<</quote>>
I have hitboxes attached to each and every zombie on the map, which moves the region with them :)
the second if in the first trigger is sensless.
the movementspeed can be increased by triggers, too.
also: is the trigger only for player 1 or why do u use a fixed array
index? :)
greez
<</quote>>
I use a fixed array because its a class based map, when u choose a certain class differant triggers are switched on and off depending on what class you use.
hm ok, but thats still no reason for using a fixed index.
if there are different classes you can just check what class the player plays when he clicks the mouse and run the correct trigger. dont really see connection there.
I understand what you're saying but what i dont get is i've been asked 10000 times how i get my games to play so smooth on bnet and i finally give out some triggers and i get this type of response? lol. It works, you can use it how you want but this is how i use it and it works 100% fine.
I was searching around and found this. Although its lagless what would you do about cliffs (flying)?
If I'm wrong about any of this I'm sorry. Although I do like your "How to detect collision of projectiles" section. I had never thought about using regions before.
Okay now for why I'm posting. I need to know if there is a way to use this and make a bullet trail?
no offense but why would you use regions for collision?.... considering it doesnt take height into account?
why not just use the natural "search areas" on a behavior with height difference validators?
you can also detect cliff collision this way.
I dont think Ive tried any of your maps bounty so I really dunno how you map plays or what map your talking about?
And doesnt this method run into issues if one player fires off 100 different projectiles at different targets.... your logic would have to account for which projectile is intended for each target.....
But yeah ....unit enters region I spose gets the job done.....
Just use the classic system, as in like the actual programming way. Just check and see if the projectile is in contact with a 3D point that is not pathable. Draw a line from the caster the target point on a 2D plane. Then pick each enemy unit in that area. Then draw a 3D line in the same fashion, using the pick each point feature with the 2D line you just created, but on a 3D system. Then if the point is occupied, create a dummy actor at that location, and don't cast the actual ability.
It's actually a lot more complicated than that. Oh I just noticed this forum was from February, I hope this post isn't completely useless. Maybe someone will find use in this.
Other boring stuff v v v
Note that if you are using missiles that do not fire in a line, there is a more complicated method that must be used to find the hit detection. Also, if a unit fires a slower moving missile, like a marauder, there is another way that this must be done. Also note that the above method is not by any means the best way to do this. It is probably the easiest, as it uses all triggers, but is not the most effective. Also, please do not claim that something like this does not cause lag, because it does. On an average computer, a simple keypress trigger like that causes a shit ton of lag. Maybe you don't remember having a shit computer, but I do. Not ripping on this system because, as he said, it does work.
Once again, I hope this wasn't completely useless because this forum was from February. W.E.
Rollback Post to RevisionRollBack
Great to be back and part of the community again!
To post a comment, please login or register a new account.
With the performance success of Hotel vs Zombies i figured i would share how i made the shooting so smooth. As many people know i am a trigger whore, i do not like to use the data editor for in depth things. So, i made a projectile system from the trigger editor and of course, it works perfectly!
Alot of people have been asking me for some of my code and until now i never really share anything but the way i see it is. I am tired of making 12893719387 maps because no one else is making the type of maps i am for some reason. So, ill give people a boost here and hopefully i can play some fun content i could have made but didnt have to thanks to the creativity and time of others :)
Here is a sample of how i did it.
*Firing Projectiles*
P1 Engineer Rocket Launcher
Events
UI - Player 1 clicks Right mouse button Down.
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Played Controlled Unit[1] Energy (Current)) >= 20.0
Then
Unit - Set Played Controlled Unit[1] Energy to ((Played Controlled Unit[1] Energy (Current)) - 20.0)
Unit - Pause Played Controlled Unit[1]
Unit - Make Played Controlled Unit[1] face (Current camera yaw of player 1) over 0.0 seconds
Animation - Play Attack Right animation for (Actor for Played Controlled Unit[1]) as Default, using Non Looping, Model Driven Looping options and Default Time blend time
Sound - Play Immortal_AttackLaunch (1) for (All players) on Played Controlled Unit[1] with Z offset 0.0 (at 100.0% volume, skip the first 0.0 seconds)
Unit - Create 1 SCV for player 1 at ((Position of Played Controlled Unit[1]) offset by 1.0 towards (Facing of Played Controlled Unit[1]) degrees) using default facing (No Options)
Unit - Set forced status bar state on (Last created unit) to Off
Unit - Turn (Last created unit) Status Bar state Off
Unit - Order (Last created unit) to ( Move targeting ((Position of Played Controlled Unit[1]) offset by 20.0 towards (Facing of Played Controlled Unit[1]) degrees)) (Replace Existing Orders)
Unit - Unpause Played Controlled Unit[1]
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
(Played Controlled Unit[1] Energy (Current)) < 20.0
Then
Sound - Play Alert_TerranNotEnoughEnergy (1) for Player 1 (at 100.0% volume, skip the first 0.0 seconds)
UI - Display "Not Enough Energy!!" for Player 1 to Directive area
General - Wait 2.0 Real Time seconds
UI - Clear Directive Messages for Player 1
Else
*How to detect collision of projectiles*
Projectile Collision (Rocket Launcher)
Events
Unit - Any Unit Enters _______ (Insert Region aka Hit box here)
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Owner of (Triggering unit)) == 1
(Unit type of (Triggering unit)) == SCV
Then
Environment - Create a Large Terran explosion at (Position of (Triggering unit))
Environment - Deal damage using Raven - Seeker (Damage) on (Unit attached to (Triggering region)) from Played Controlled Unit[1] with 0.0 extra damage
Unit - Kill (Triggering unit)
All you have to do is change the models for the SCV (Projectile) and increase its movement speed :).
My baneling for the bomberman map use the same mechanics. But rather than use hitbox as region and you have to move the region around, i use auto cast abilities on the projectile unit itself. Which works even better.
the second if in the first trigger is sensless.
the movementspeed can be increased by triggers, too.
also: is the trigger only for player 1 or why do u use a fixed array index? :)
greez
@Mille25: Go
He probably not copy its from the actual map :P, who wants that.
<<quote 198297>>
@Mille25: Go
He probably not copy its from the actual map :P, who wants that.
<</quote>>
I did copy it from the actual map, that is only one players trigger for one weapon. The second if then is not useless as the projectiles use energy.
<<quote 198286>>
My baneling for the bomberman map use the same mechanics. But rather
than use hitbox as region and you have to move the region around, i use
auto cast abilities on the projectile unit itself. Which works even
better.
<</quote>>
I have hitboxes attached to each and every zombie on the map, which moves the region with them :)
<<quote 198292>>
the second if in the first trigger is sensless.
the movementspeed can be increased by triggers, too.
also: is the trigger only for player 1 or why do u use a fixed array
index? :)
greez
<</quote>>
I use a fixed array because its a class based map, when u choose a certain class differant triggers are switched on and off depending on what class you use.
@Bounty_98: Go
hm ok, but thats still no reason for using a fixed index.
if there are different classes you can just check what class the player plays when he clicks the mouse and run the correct trigger. dont really see connection there.
@Mille25
I understand what you're saying but what i dont get is i've been asked 10000 times how i get my games to play so smooth on bnet and i finally give out some triggers and i get this type of response? lol. It works, you can use it how you want but this is how i use it and it works 100% fine.
I was searching around and found this. Although its lagless what would you do about cliffs (flying)?
If I'm wrong about any of this I'm sorry. Although I do like your "How to detect collision of projectiles" section. I had never thought about using regions before. Okay now for why I'm posting. I need to know if there is a way to use this and make a bullet trail?
@gamemore: Go
no offense but why would you use regions for collision?.... considering it doesnt take height into account?
why not just use the natural "search areas" on a behavior with height difference validators?
you can also detect cliff collision this way.
I dont think Ive tried any of your maps bounty so I really dunno how you map plays or what map your talking about?
And doesnt this method run into issues if one player fires off 100 different projectiles at different targets.... your logic would have to account for which projectile is intended for each target.....
But yeah ....unit enters region I spose gets the job done.....
Just use the classic system, as in like the actual programming way. Just check and see if the projectile is in contact with a 3D point that is not pathable. Draw a line from the caster the target point on a 2D plane. Then pick each enemy unit in that area. Then draw a 3D line in the same fashion, using the pick each point feature with the 2D line you just created, but on a 3D system. Then if the point is occupied, create a dummy actor at that location, and don't cast the actual ability.
It's actually a lot more complicated than that. Oh I just noticed this forum was from February, I hope this post isn't completely useless. Maybe someone will find use in this.
Other boring stuff v v v
Note that if you are using missiles that do not fire in a line, there is a more complicated method that must be used to find the hit detection. Also, if a unit fires a slower moving missile, like a marauder, there is another way that this must be done. Also note that the above method is not by any means the best way to do this. It is probably the easiest, as it uses all triggers, but is not the most effective. Also, please do not claim that something like this does not cause lag, because it does. On an average computer, a simple keypress trigger like that causes a shit ton of lag. Maybe you don't remember having a shit computer, but I do. Not ripping on this system because, as he said, it does work.
Once again, I hope this wasn't completely useless because this forum was from February. W.E.
Great to be back and part of the community again!