[Project] Third Person Shooter

wingdnosring

New Member
Reaction score
16
Yeah I did. Aiming is considerably easier when you can see where your shooting. The offset is there to a) clear the center of the screen and b) I like how it looks :).

Onisagi, for hiding the unit's health bars, do I need a unit TYPE variable, or just a unit variable?
 

onisagi

New Member
Reaction score
6
xxxtrickyxxx: its interesting how you implemented everything using galaxy custom script... xD. I'm just wondering is ther a specific reason its in galaxy, cuz you can implement that just as easily with triggers. You're still workin on that movement system ya? you should put in support for what happens when people are holding opposite keys, right now it moves in a dominant direction.

wingdnosring: you're only gonna need to create a "unit type" global variable to define what unit to use for the grenade. Then you're gonna need to make custom explosion effect from data editor. I duplicated Siege tank's siege mode cannon (damage) effect along with its corresponding actor only, and tweaked those settings for the explosion visual+AOE damage.

You don't ever need to keep track of the grenade unit that you're creating, because my cannon AOE effect actually blows up the grenade unit as it lands.

Sample video of what i got so far xD
http://www.youtube.com/watch?v=GmU5zyNH2RI

I really dislike the shaky camera, to the point where i'd rather sacrifice vision to prevent it... xD

You'll probably miss it in the video, but the first second i'm swapping weapons from primary gun to grenades. Tab key scrolls through my weapon slots (Melee, Side Arm, Primary, Secondary), and left click's effect is based on the current weapon slot i'm using on my specific player. Multiplayer enabled already, i might upload this map for some multiplayer grenade deathmatch... rofl...
 

wingdnosring

New Member
Reaction score
16
Very cool so far. Is it possible to stop them form detonating upon impact? I'd rather they detonated on a timer.

I'm currently moving things into a library to make everything more accessible to other people that want to use the system.

So far I've managed to change new weapon creation into one line of code :O.
 

onisagi

New Member
Reaction score
6
yea it should be pretty easy to stick a timer in there before detonation, making it bounce off walls will require vector calculus tho.

The grenade movement step size can be tweaked smaller to give it more resolution. Right now its set to 0.05, making it smaller will let you see the grenade's flight better.

I didn't put in a cooldown on it yet, so that's why i can rapid fire it... xD
 

onisagi

New Member
Reaction score
6
You "run trigger" this trigger to call it, it does practically everything on its own. It's set to direct its firing to camera yaw/pitch though, which can be changed to something else if you're using it for something else. Also you can probably add in a "wait" action right before the explosion action near the bottom to add a delay, maybe even put on the seeker missile beeping sound before, and turn off the sound after timer xD.

I scaled down a sphere unit to act as grenade. Just too lazy to adjust the scale inside data editor, i'm sure performance wise it would better tho; the grenade model choice isn't finalized anyways... xD

It flies too high right now though, i'll try to fix that when i have some time.

To anyone using this... remember to give credit where its due ;]. Hope it works out for ya.

Implementation instructions:
Make Global Variables:
Projectile Initial Speed (Real) = 30.0 // Speed in which your projectile is initially thrown
Gravity (Real) = 4.0 // gravitational acceleration grid/s^2
Projectile Type (Unit Type) = Sphere // whatever unit yu want

Gravity should actually be more like 5.0, but i lowered it to "fake" air friction and wutever. Names of variables can be changed if you don't like how mines sound.
Code:
Lob
    Events
    Local Variables
        Throw Height = 0.5 <Real>
        Camera Yaw = (Camera Yaw of Player(1)) <Real>
        Camera Pitch = (360.0 - (Camera Pitch of Player(1))) <Real>
        Vz = (Projectile Initial Speed * ((Sin(Camera Pitch)) / 2.0)) <Real>
        Vx = (Projectile Initial Speed * ((Cos(Camera Pitch)) * (Cos(Camera Yaw)))) <Real>
        Vy = (Projectile Initial Speed * ((Cos(Camera Pitch)) * (Sin(Camera Yaw)))) <Real>
        Step Size = 0.01 <Real>
        Loops = 0 <Integer>
    Conditions
    Actions
        Unit - Create 1 Projectile Type for player 1 at (Position of Player Unit[1]) facing Camera Yaw degrees (No Options)
        Unit - Set (Last created unit) scale to (10.0%, 10.0%, 10.0%) of its original size
        Unit - Change (Last created unit) height to Throw Height over 0.0 seconds
        General - While (Conditions) are true, do (Actions)
            Conditions
                (Height of (Last created unit)) > 0.0
            Actions
                Variable - Set Vz = (Vz - (Gravity * Step Size))
                Unit - Move (Last created unit) instantly to ((Position of (Last created unit)) offset by ((Vx * Step Size), (Vy * Step Size))) (No Blend)
                Unit - Make (Last created unit) face Camera Yaw over 0.0 seconds
                Unit - Change (Last created unit) height to ((Height of (Last created unit)) + Vz) over 0.0 seconds
                General - Wait Step Size Game Time seconds
                Variable - Set Loops = (Loops + 1)
        Environment - Create Grenade (Damage) on (Last created unit) from Player Unit[1]
        Trigger - Turn (Current trigger) Off

Shouldn't be too hard to tweak to your liking. I wanted to add in debugging mode where you can set initial velocity and gravity ingame through text commands... but im busy today.

Air friction, maybe later...
 

wingdnosring

New Member
Reaction score
16
Looks sweet, I'll try importing it shortly. Is there any known way to assign weapons or image links to variables? If so, I could limit my code so much more.

I've just transfered just about everything into a custom library (man did that ever take a while) and creating weapons only takes one line now :). It's the indirect effects like dialog image and weapon changes that I can't seem to amalgamate.
 

onisagi

New Member
Reaction score
6
when you make a new variable at the top of the drop-down list are 4 Types that people commonly miss:
- Preset
- Record
- Game Link
- File

under each is a whole list of subtypes. I believe you're looking for File->Image and Game Link->Weapon?

Basically you can just assume that if its a value that you can set in a trigger, then its a value that can be put into its own variable. Dunno how true the statement is, but it hasn't failed me yet.

As for the lob trigger above, i think you can set multiplayer functionality by defining a temporary "current player" variable that you set inside the trigger that calls it to "triggering player", and then inside the lob trigger it'll store the "player" into its own local var and commence its operations under that player only. You need to transfer the global player var to local player var in case someone calls the trigger concurrently and change the global "player" var.

Personally, i'm just gonna convert the whole trigger into galaxy custom script to make it an action definition that allows parameters to be passed inside. So i can just pass in player number as a parameter. It'll fit in well with my traceline action.
 

onisagi

New Member
Reaction score
6
remove the part of the trigger that says:
Variable - Set Loops = (Loops + 1)
as well as the Loops variable, it isnt needed for the code's functionality... just for me to see how many times it loops before the projectile lands.
 

wingdnosring

New Member
Reaction score
16
K. Sorry, I still haven't gotten around to copying it into my library yet. Still workign out a couple of issues.

Is it possible to select a random number that is divisible by x between min and max? If so, that would really help me out, because right now burst weapons can go negative on ammo, which is quite....wrong.
 

Dave312

Censored for your safe viewing
Reaction score
269
Is it possible to select a random number that is divisible by x between min and max? If so, that would really help me out, because right now burst weapons can go negative on ammo, which is quite....wrong.

Go random integer between (min/x) and (max/x) and then multiply the result by x
 

onisagi

New Member
Reaction score
6
you should give more info on what you're trying to do too, in case there's something entirely different you can try.

How does dividing by a number cause ammo to become negative? It just sounds like you're missing an if-statement somewhere.
 

wingdnosring

New Member
Reaction score
16
Only burst weapons can go negative. It's because it takes a chunk of ammo for each shot, so, if it shoots five shots but the gun only had 4 ammo left, it knocks it down to -1. I could just put in some if statements for this, but I'd rather ammo was always proeprly divisible by the weapon's burst amount.

I tried copying in your grenade code, but it's not working. The trigger is so simple, I'm not sure how I messed it up. Basically, if I'm looking downward the grenade moves up slightly but never moves on the x,y coordinates. If I'm looking straight or upwards the grenade doesn't appear at all.

Here's how I implemented it:

Code:
                        Variable - Set Grenade Traj Distance = 0.03
                        Variable - Set Pitch = (360.0 - (Camera Pitch of Player(Grenade Traj Creation Loop)))
                        Variable - Set Vx = (Grenade Traj Distance * ((Cos(Pitch)) * (Cos((Camera Yaw of Player(Grenade Traj Creation Loop))))))
                        Variable - Set Vy = (Grenade Traj Distance * ((Cos(Pitch)) * (Sin((Camera Yaw of Player(Grenade Traj Creation Loop))))))
                        Variable - Set Vz = (Grenade Traj Distance * ((Sin(Pitch)) / 2.0))
                        Unit - Create 1 Grenade Trajectory for player Grenade Traj Creation Loop at Shooter Positions[Grenade Traj Creation Loop] facing (Position of InvisibleTargetDummy[Grenade Traj Creation Loop]) (No Options)
                        Unit - Change (Last created unit) height to (ThrowHeight + (Ground height at Shooter Positions[Grenade Traj Creation Loop])) over 0.0 seconds
                        Unit - Set (Last created unit) custom value 0 to (Vx * 0.01)
                        Unit - Set (Last created unit) custom value 1 to (Vy * 0.01)
                        Unit - Set (Last created unit) custom value 2 to (Vz * 0.01)
                        Unit Group - Add (Last created unit) to GrenadeGroups[Grenade Traj Creation Loop]

Then I do this every 0.01 seconds to the grenade group:

Code:
                               Unit - Set (Picked unit) custom value 2 to ((Custom value 2 of (Picked unit)) + (4.0 * 0.01))
                                        Variable - Set CurrentGrenadePointPlay = (Position of (Picked unit))
                                        Variable - Set FutureGrenadePointPlay = (CurrentGrenadePointPlay offset by ((Custom value 0 of (Picked unit)), (Custom value 1 of (Picked unit))))
                                        Unit - Order (Picked unit) to ( Move targeting FutureGrenadePointPlay) (Replace Existing Orders)
                                        Unit - Change (Picked unit) height to (Custom value 2 of (Picked unit)) over 0.0 seconds

Ahhh...now that I think of it, I think custom values are the culprit yet again. I bet it's because custom values can't be negative. Guess I need another way to do this...

I think I can upload version 6 once the grenades are working. I think you'll all be surprised by the changes. It's about sixteen trillion (lol) times better than version 5.
 

onisagi

New Member
Reaction score
6
Will it finally have a working hp bar xD? You made a spiffy custom UI hu?

btw, just store the Vx,Vy,Vz vars in local variables. Each time you run the trigger, it's actually creating its own instance, and all the local variables inside are unique to each grenade, thats functionally the same as having a custom value that can be negative.

also you seem to be... not subtracting gravity from Vz, that'll cause it to just fly in the direction that you aimed it and it won't ever come back down.

Since you've opted to use issue order to do the horizontal movement, then you'll need to dynamically change the grenade's walking speed according to your pitch angle.

Example:
At pitch 0, your aiming perfectly horizontal thus the grenade walking speed should be maximum
Vxy = maximumSpeed * cos(0) = maximumSpeed

At pitch 60, your grenade speed should be half of the maximum, because cos(60) = 0.5
Vxy = maximumSpeed * cos(60) = maximumSpeed * 0.5

which means Vxy = maximumSpeed * cos(pitch), you'll then need to figure out how the unit speed works and see if you need to scale Vxy to make it match up accordingly with the unit property "speed"

I've considered unit walking thing too, it'll definitely smooth out the movement a bit, but it doesn't sync with the height updating, and takes a little more effort to implement. It should be okay if you reduce unit collision radius and radius of unit clustering to zero, to make sure there's no chance of other units effecting the grenade's flight and making it fly weird.
 

wingdnosring

New Member
Reaction score
16
Unit - Set (Picked unit) custom value 2 to ((Custom value 2 of (Picked unit)) + (4.0 * 0.01))

That was my gravity. I didn't realize local variables could have several instances at once. That's good to know, I'll just make it all one trigger and move instantly if I can. When ignoring terrain height, moving instantly can have really weird effects.

And no, I still haven't been able to remove the health bars. I did exactly as you said Pick all (unit type var) units in entire map matching <conditions> with at most any amount. Then remove unit variable's status bar.

That's exactly what I'm doing, but it doesn't work.

Spiffy UI? Not exactly, but the whole thing is just workign so much better now and can actually be edited without an hour of freaking work.

[Edit]: Got your grenades working, but I think the pitch is a bit off. It's super sensitive when determining height and if aiming level or downwards they go straight to the marine's feet. I'm gonna play with it a little bit.
 

onisagi

New Member
Reaction score
6
yea thats the problem... i'm not sure why its so sensitive. Just aiming at like above 45 degree angle it reacts like i throw it almost straight up... I'mma put some debug code in there and see if i can see why its reacting that way.

It works pretty well if you're throwing it within a certain range of angles tho... its just weird how it feels like its increasing the throwing height exponentially wen yu aim up.

if you throw it horizontally, and it explodes at your feet, thats most likely because either your gravity is too high, or your initially velocity is too low. So it doesn't go very far before hitting the floor.

Also i've noticed that my current grenade trigger doesn't work with changing terrain height, because it uses relative heights. I'll see if i can fix that. It seems Blizzard isn't very absolute terrain height friendly, they like to do everything relative to the terrain... I'll just need to add or subtract terrain height as it steps forward.
 

wingdnosring

New Member
Reaction score
16
Yeah, I got it working no prob. I'm uploading version6 now so you can see how I editted it. Basically, I just messed around with the values until the camera pitch influenced distance more than height.

[Edit]: Uh-oh. Sorry Onisagi, I just realized I forgot to credit you for the grenade triggers. I will add it in for the next version. Sorry about that.
 

onisagi

New Member
Reaction score
6
i found out why my height movement is off.... its because everything is being multiplied by step size except for Vz....... can't believe i missed that

Alright here's some improvements to the algorithm that i made so far:
The current settings that i've pasted here feel optimal in my opinion, try them out and see if you like it. I tried my best to make the code more modular and optimal.

Code:
Lob
    Events
    Local Variables
        Launch Height = 0.5 <Real>
        Launch Position = ((Position of Player Unit[1]) offset by 0.01 towards Camera Yaw degrees) <Point>
        Camera Yaw = (Camera Yaw of Player(1)) <Real>
        Camera Pitch = (370.0 - (Camera Pitch of Player(1))) <Real>
        Vz = (Projectile Initial Speed * (Sin(Camera Pitch))) <Real>
        Vx = (Projectile Initial Speed * ((Cos(Camera Pitch)) * (Cos(Camera Yaw)))) <Real>
        Vy = (Projectile Initial Speed * ((Cos(Camera Pitch)) * (Sin(Camera Yaw)))) <Real>
        Step Size = 0.05 <Real>
        Initial Terrain Height = 0.0 <Real>
    Conditions
    Actions
        Unit - Create 1 Projectile Type for player 1 at Launch Position facing Camera Yaw degrees (No Options)
        Unit - Change (Last created unit) height to Launch Height over 0.0 seconds
        Variable - Set Initial Terrain Height = (Ground height at (Position of (Last created unit)))
        General - While (Conditions) are true, do (Actions)
            Conditions
                (Height of (Last created unit)) > 0.0
            Actions
                Unit - Move (Last created unit) instantly to ((Position of (Last created unit)) offset by ((Vx * Step Size), (Vy * Step Size))) (No Blend)
                Unit - Make (Last created unit) face Camera Yaw over 0.0 seconds
                Unit - Change (Last created unit) height to ((Height of (Last created unit)) + (Vz * Step Size)) over 0.0 seconds
                General - Wait 0.0 Game Time seconds
                Variable - Set Vz = (Vz - (Gravity * Step Size))
        Environment - Create Grenade (Damage) on (Last created unit) from Player Unit[1]
        Trigger - Turn (Current trigger) Off

Important changes from the previous algorithm:
- wait time = 0 game time seconds (any other time makes the grenade move in slow motion)
- Vz now properly multiplied by step size
- Added 10 degrees to the camera pitch (this makes it so aiming horizontally actually aims it at 10 degrees, immensely easier to see and shoot with - i recommend you try this change for sure)
- Gravity = 5.0
- Projectile Initial Speed = 15
- removed grenade scaling action (waste of cpu cycles)
- Ignore set "initial terrain height" (beginnings of code that'll fix the grenade's height moving over changing terrain)
- Can optimize even more by multiplying Vx and Vy by step size in the variable initialization (since Vx/Vy doesn't change inside the while loop, saves resources). However Vz changes within the loop, so you must keep re-multiplying it OR pre-multiply gravity by (set size)^2, then you can multiply Vz by step size in initialization too.

Notes on usage:
* smaller step size = smoother movement animation (0.05 recommended)
* smaller wait time between loops = faster grenade movement (0.0 recommended)
* It's good that you kept throw height as a variable too, because it would make a good custom variable to set for different units that vary in height you mite be able to control.
* keep in mind that I have the following global variables set outside the trigger, because they're constants and waste of resources to keep creating inside trigger instances (technically true for "step size" too, o well):

Projectile Initial Speed = 15.0 <Real>
Gravity = 5.0 <Real>
Projectile Type = Sphere <Game Link - Unit>
 

wingdnosring

New Member
Reaction score
16
Nice changes. I did the pre-multiply step before and then undid it to make absolutely sure I had your code right.

Did you try out version 6? What did you think?
 

onisagi

New Member
Reaction score
6
really nice. I like how it puts you straight in the middle of a battle. Now you just need an opening cinematic where your plane crash lands.

I noticed you were able to reduce weapon creation to one line, very nice. You know you could make a clickable interface for your action definition using the "Grammar Text" field? It'll make it more functionally like the editor's native Actions.

You have more than one area that has the grenade algorithm, you forgot to remove the one that isn't functional?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top