Staredit Network > Forums > SC2 Assistance > Topic: SC:Editor 1.2 FPS traceline
SC:Editor 1.2 FPS traceline
Jan 25 2011, 11:38 pm
By: doite  

Jan 25 2011, 11:38 pm doite Post #1



Hey,

Well i have a question. Title pretty much sums it up, but what im trying to do is to create a traceline for a, what you could almost call, FPS game now when version 1.2 is out. The camera itself is locked, so you cant turn, or move, but the mouse is free. So i have to, when shooting on targets, track the position of mouse, and when its over a unit -> set that unit in a unit varaible. Much like any other traceline, but i really dont have any experiance with mouse tracking and how it would work with the unit, since the units distance from the camera may differ from different situations.

I do have a unit, which is hidden, at the location of the camera.

Would appreciate help, on a quite low level, since i may not know the new functions that well!

Thanks in advance

PS: Just to clearify - The yaw of the camera is not movable, so ONLY the mouse can be moved.



None.

Jan 25 2011, 11:59 pm Roy Post #2

An artist's depiction of an Extended Unit Death

Are you concerned with network traffic, or do you intend for this to be a one-player map?

If the latter, you could use the new 'Mouse Moved' event to move a global point variable to the position of the player's mouse, and perform any math from the point of the camera to the point at the mouse (i.e. "Distance Between Points" or "Angle Between Points").

Player1Mouse
    Events
        UI - Player 1 moves mouse.
    Local Variables
    Conditions
    Actions
        Variable - Set P1Mouse = (Point((Mouse X position in the world), (Mouse Y position in the world), (Mouse Z position in the world)))

I'm not entirely sure what you're asking, but I hope this is helpful in some way.




Jan 26 2011, 12:08 am doite Post #3



hmm... well...
It made me atleast thinking...

If i do that, save the position of the mouse into a varaible... then do a "player click left mouse (trigger: shoot) then save the position of the unit closest to point of mouse... the somehow do a if then else, with condition Angle between Mouse point and camera VS Unit point and camera =< 1.. then also have a hight check... "hight of unit < mouse Z location.. then maybe it would work...

But since theres sadly no condition i can do this with then i cant.

Roy thats anyway, allwas appreciate the responses.

What im trying to do is this:




None.

Jan 26 2011, 1:01 am Roy Post #4

An artist's depiction of an Extended Unit Death

Okay, so this is a trigger I wrote which I think will make a point move like a bullet flying in the direction of a clicked mouse.

Shoot
      Events
            UI - Player 1 clicks Left mouse button Down.
      Local Variables
            ClickPoint = (Point((Mouse X position clicked in the world), (Mouse Y position clicked in the world), (Mouse Z position clicked in the world))) <Point>
            FireAngle = (Angle from PointOfCamera to ClickPoint) <Real>
            Distance = (Distance between PointOfCamera and ClickPoint) <Real>
            HeightSlope = (((Height of ClickPoint) - (Height of PointOfCamera)) / Distance) <Real>
            HitUnit = No Unit <Unit>
            CurrentRange = 0.0 <Real>
            MaxRange = 100.0 <Real (Constant)>
            Bullet = No Point <Point>
      Conditions
      Actions
            General - While (Conditions) are true, do (Actions)
                  Conditions
                        HitUnit == No Unit
                        CurrentRange < MaxRange
                        (Height of Bullet) >= (Ground height at Bullet)
                  Actions
                        Variable - Modify CurrentRange: + 0.5
                        Variable - Set Bullet = (PointOfCamera offset by CurrentRange towards FireAngle degrees)
                        Point - Set the height of Bullet to (HeightSlope * CurrentRange)
                        Unit Group - Pick each unit in (Any units in (Region(Bullet, 0.3)) owned by player 2 matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
                              Actions
                                    General - If (Conditions) then do (Actions) else do (Actions)
                                          If
                                                (Height of (Picked unit)) >= (Height of Bullet)
                                          Then
                                                Variable - Set HitUnit = (Picked unit)
                                          Else
                        General - Wait 0.01 Game Time seconds
            General - If (Conditions) then do (Actions) else do (Actions)
                  If
                        HitUnit != No Unit
                  Then
                        Unit - Kill HitUnit
                  Else


The local variables find all the needed data to make the calculations, such as finding the slope of the line.
The while loop follows the path of the line, and stops either when it finds a unit, reaches a certain distance, or hits the ground.
If a unit is found, that unit is killed.

I assumed P1 to be the shooter and P2 to be the units that P1 is shooting. I'm not sure if this works in the way I'm imagining, though.




Jan 26 2011, 2:06 am doite Post #5



Shoot 2
Events
UI - Player Any Player clicks Left mouse button Down.
Local Variables
ClickPoint = (Point((Mouse X position clicked in the world), (Mouse Y position clicked in the world), (Mouse Z position clicked in the world))) <Point>
FireAngle = (Angle from CameraPoint to ClickPoint) <Real>
Distance = (Distance between CameraPoint and ClickPoint) <Real>
HightSlope = (((Height of ClickPoint) - (Height of CameraPoint)) / Distance) <Real>
HitUnit = No Unit <Unit>
CurrentRange = 0.0 <Real>
MaxRange = 100.0 <Real (Constant)>
Bullet = No Point <Point>
Conditions
And
Conditions
(PlayerUnit[(Triggering player)] is alive) == true
(PlayerUnit[(Triggering player)] is alive) == true
AttackOnCooldown[(Triggering player)] == false
CurAmmo[(Triggering player)] > 0
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
HitUnit == No Unit
CurrentRange < MaxRange
(Height of Bullet) >= (Ground height at Bullet)
Then
Variable - Modify CurrentRange: + 0.5
Variable - Set Bullet = (CameraPoint offset by CurrentRange towards FireAngle degrees)
Point - Set the height of Bullet to (HightSlope * CurrentRange)
Unit Group - Pick each unit in (Any units in (Region(Bullet, 0.3)) owned by player 15 matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Height of (Picked unit)) >= (Height of Bullet)
Then
Variable - Set Unit[(Triggering player)] = (Picked unit)
Else
General - Wait 0.01 Game Time seconds
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
HitUnit != No Unit
Then
Environment - Execute Ghost - C-10 Canister Rifle (Damage) on HitUnit from PlayerUnit[(Triggering player)]
Else
Sound - Play Ghost_AttackLaunch for (All players) (at 100.0% volume, skip the first 0.0 seconds)
Variable - Set AttackOnCooldown[(Triggering player)] = true
Trigger - Run Cool Down Attack (Ignore Conditions, Don't Wait until it finishes)
Variable - Modify CurAmmo[(Triggering player)]: - 1
General - If (Conditions) then do (Actions) else do (Actions)
If
CurAmmo[(Triggering player)] == 0
Then
Variable - Set Reloading[(Triggering player)] = true
Trigger - Run Reload (Ignore Conditions, Don't Wait until it finishes)
Else

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thats what i did, but it doesnt work. It gives the error:

Trigger Error in Get_Shoot2_func;
could not get "p" from perameter in
'pointgetheight' (value: 0)



None.

Jan 26 2011, 3:42 am Roy Post #6

An artist's depiction of an Extended Unit Death

Ah, it is actually a problem with the code I wrote. You're trying to get the height of "Bullet" when it is not set to a given point.

Set Bullet to be the same position and same height as the camera's point before the while loop.

And for formatting the trigger text, the easiest way is to use the [pre] tag.




Jan 26 2011, 4:40 am payne Post #7

:payne:

Quote from Roy
Ah, it is actually a problem with the code I wrote. You're trying to get the height of "Bullet" when it is not set to a given point.

Set Bullet to be the same position and same height as the camera's point before the while loop.

And for formatting the trigger text, the easiest way is to use the [pre] tag.
Or use this website: http://vgshorts.com/BBCode/BBCode3.php



None.

Jan 26 2011, 5:01 pm doite Post #8



Shoot 2
Events
UI - Player Any Player clicks Left mouse button Down.
Local Variables
ClickPoint = (Point((Mouse X position clicked in the world), (Mouse Y position clicked in the world), (Mouse Z position clicked in the world))) <Point>
FireAngle = (Angle from CameraPoint to ClickPoint) <Real>
Distance = (Distance between CameraPoint and ClickPoint) <Real>
HightSlope = (((Height of ClickPoint) - (Height of CameraPoint)) / Distance) <Real>
HitUnit = No Unit <Unit>
CurrentRange = 0.0 <Real>
MaxRange = 100.0 <Real (Constant)>
Bullet = No Point <Point>
Conditions
And
Conditions
(PlayerUnit[(Triggering player)] is alive) == true
(PlayerUnit[(Triggering player)] is alive) == true
AttackOnCooldown[(Triggering player)] == false
CurAmmo[(Triggering player)] > 0
Actions
Point - Set the height of Bullet to (Height of CameraPoint)
General - While (Conditions) are true, do (Actions)
Conditions
HitUnit == No Unit
CurrentRange < MaxRange
(Height of Bullet) >= (Ground height at Bullet)
Actions
Variable - Modify CurrentRange: + 0.5
Variable - Set Bullet = (CameraPoint offset by CurrentRange towards FireAngle degrees)
Point - Set the height of Bullet to (HightSlope * CurrentRange)
Unit Group - Pick each unit in (Any units in (Region(Bullet, 0.3)) owned by player 15 matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Height of (Picked unit)) >= (Height of Bullet)
Then
Variable - Set Unit[(Triggering player)] = (Picked unit)
Else
General - Wait 0.01 Game Time seconds
General - If (Conditions) then do (Actions) else do (Actions)
If
HitUnit != No Unit
Then
Environment - Execute Ghost - C-10 Canister Rifle (Damage) on HitUnit from PlayerUnit[(Triggering player)]
Else
Sound - Play Ghost_AttackLaunch for (All players) (at 100.0% volume, skip the first 0.0 seconds)
Variable - Set AttackOnCooldown[(Triggering player)] = true
Trigger - Run Cool Down Attack (Ignore Conditions, Don't Wait until it finishes)
Variable - Modify CurAmmo[(Triggering player)]: - 1
General - If (Conditions) then do (Actions) else do (Actions)
If
CurAmmo[(Triggering player)] == 0
Then
Variable - Set Reloading[(Triggering player)] = true
Trigger - Run Reload (Ignore Conditions, Don't Wait until it finishes)
Else


Still the same issue mr Roy.



None.

Jan 26 2011, 5:10 pm payne Post #9

:payne:

http://vgshorts.com/BBCode/BBCode3.php?ID=241
(this is just your trigger rendered, not a fix :P)

I saw that you use two times the condition "(PlayerUnit[(Triggering player)] is alive) == true". Why that?



None.

Jan 27 2011, 3:14 am Roy Post #10

An artist's depiction of an Extended Unit Death

Change the default of the Bullet local variable.

Bullet = (Point((X of CameraPoint), (Y of CameraPoint), (Height of CameraPoint))) <Point>


(It's "Point From XYZ")




Jan 27 2011, 4:07 pm doite Post #11



http://www.mediafire.com/?h5p5vj4j1o5o8hi

Im sorry for being such an freelancer, i allwas do it all bymyself, but i really cant get it working. I sent this.
The map is just a test to get it working and ignore layout, and .. basicly everything.
The trigger = shoot2

"Hold "F" to jump up
*Release "F" to cover
*Click left mouse to shoot

Only 1 unit. He wont do any harm, but if you sucessfully shoot him he will back start fleeing



None.

Jan 27 2011, 7:00 pm doite Post #12



Sooooooooooooooooooooooooooooooooooooooooooooo borring, but i made it way to easy instead.

Event: Unit clicked
Action: Create damage on unit from unit

......
So what im now instead trying to do is to create the model "ghost impact" at the location i click.

"Event: mouse clicked"
Action: Create effect, or actor, or what ever, at point Mouse click x,y,z.

How to create such an actor, or effect?

PS: 2 things:
1. Im sorry im pstin this dataeditorial question here now.
2. im sorry i didnt forfill the trigger you created roy, but since the impact is direct, and no projectile has to be directed from camera view to unit, i made it easy (just didnt think of it before)

what i mean with my quetion is that i want to create a "bullet hit splash" at point where im shooting (like in the video from above)



None.

Jan 28 2011, 2:13 am Roy Post #13

An artist's depiction of an Extended Unit Death

I did a few tests and figured out that I had a few misconceptions on how the Z-axis operates for these functions. As it turns out, the mouse clicked events completely disregard the Z-axis position and set the click point to the (X, Y) coordinate of the terrain the mouse clicks.

This means that there really is no direct solution to your problem. The clicked distance is exponentially based on the pitch of the camera, and at a certain point the mouse is being clicked beyond the horizon of the map, yielding a steady, high number. Therefore, using the distance of the click and modifying the model's height to correspond with it is impossible.

Furthermore, there doesn't seem to be a way to get the mouse position relative to the screen, which would be perfect for what you're trying to accomplish.

The reason this is (seemingly) impossible while FPS games are possible is because FPS games can use the camera yaw and pitch to shoot in the direction they are facing, and do not have to rely on clicking position. Your system cannot utilize these camera aspects perfectly because you also have the position of the mouse relative to the screen as a variable to the game's functionality.

(Creating the model is really simple, it's just "Actor - Create Model at Point"; the problem is getting the proper point/height).

Unless you know of a way to get the mouse's position relative to the screen, I don't think this is possible.




Jan 28 2011, 4:29 pm doite Post #14



Hmm i feared this! Thanks alot roy for all your help!

Regarding the model, there is. Theres a library "at a certain site im not allowed to name" where you detect screen resolution of the player -> you do a math which is based on screen resolution and the relation to where mouse is in comparison with where the image is archored.
But i dont know the math for it, ill figure it out! thanks alot mate!



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[03:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[06:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[05:41 am]
Ultraviolet -- 🤔 so inf is in you?
[04:57 am]
O)FaRTy1billion[MM] -- my name is mud
[04:35 am]
Ultraviolet -- mud, meet my friend, the stick
[2024-5-16. : 10:07 pm]
lil-Inferno -- nah
[2024-5-16. : 8:36 pm]
Ultraviolet -- Inf, we've got a job for you. ASUS has been very naughty and we need our lil guy to go do their mom's to teach them if they fuck around, they gon' find out
[2024-5-16. : 5:25 pm]
NudeRaider -- there he is, right on time! Go UV! :D
[2024-5-16. : 5:24 pm]
lil-Inferno -- poopoo
[2024-5-16. : 5:14 pm]
UndeadStar -- I wonder if that's what happened to me. A returned product (screen) was "officially lost" for a while before being found and refunded. Maybe it would have remained "lost" if I didn't communicate?
Please log in to shout.


Members Online: Sylph-Of-Space, Roy, 1madisonc911rb1