|
 |
|
|
|
|
|
GTA Modification Forums
Help with code for some area C#
 |
|
 |
| |
jstq  |
Posted: Wednesday, May 1 2013, 05:38
|
Player Hater

Group: Members
Joined: Nov 17, 2012

|
 black 1 is player's car red 2 is player's car direction green 3 is camera direction gray 4 is on screen area, expanding to left and red 5 is not on screen area I need code which will return true for any car in area 5. Method isOnScreen often returns true for not on screen cars, so its bad for me. And some question - how much foots is screen width while player is in car/not in car for 1920 pixels? How to get foots count for maximum view distance? Whats the fastest way to know, is really car displayed on screen or not? (isOnScreen will return true if between car and player is a building or wall).
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
sextitsboobsyeah  |
Posted: Wednesday, May 1 2013, 06:49
|
Player Hater

Group: BUSTED!
Joined: May 1, 2013

|
ah ok, i know some spanish, nm lol take this example: vehicle.Position == vehicle.GetOffsetPosition(new Vector3(0, 0, 0)) is true so a point in front of car or behind u change y value vehicle.GetOffsetPosition(new Vector3(0, 5, 0)) is about 5 meters in front of car so a point to left or right u change x value vehicle.GetOffsetPosition(new Vector3(5, 0, 0)) is about 5 meters to right and to get a point behind and to the left vehicle.GetOffsetPosition(new Vector3(-5, -5, 0)) vehicle.GetOffsetPosition(new Vector3(left/right, front/back, up/down)) now because u are using offset positions and not world positions, u can create your picture using a horizontal parabola formula, i dont use normally but i understand how these things work so i am studying a little and i will make a picture to explain in your picture i would say the point for that offset is something like... vehicle.GetOffsetPosition(new Vector3(7.5, 2.6, 0)), something like that, just a guess but u can use algebra to calculate any point relative to your focus point... being the car this is cool, i just found... http://www.wolframalpha.com/input/?i=plot+...-+3%29^2+%3D+11 This post has been edited by sextitsboobsyeah on Wednesday, May 1 2013, 07:26
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
sextitsboobsyeah  |
Posted: Wednesday, May 1 2013, 07:27
|
Player Hater

Group: BUSTED!
Joined: May 1, 2013

|
| QUOTE (jstq @ Wednesday, May 1 2013, 07:05) | | Player.Vehicle.GetOffsetPosition(Player.Position + Player.Direction*150); |
fixed, also i dont understand what u mean for this, u need to study vector math to understand how to calculate stuff with vectors, this is cool though i like to learn this stuff and now im reading about parabolas lol ill try to post an example tomorrow This post has been edited by sextitsboobsyeah on Wednesday, May 1 2013, 07:45
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
sextitsboobsyeah  |
Posted: Thursday, May 2 2013, 07:26
|
Player Hater

Group: BUSTED!
Joined: May 1, 2013

|
| QUOTE (jstq @ Wednesday, May 1 2013, 07:44) | i just dint get why that offset function is in vehicle class. If we have player position and some vector, we do not need any vehicle to calculate offset position imo. Or we need, cus that function is in vehicle class? In other way, what this function takes from vehicle exemplar to calculate offset? If it gets vehicle position, why we need player.position? |
it uses a native function to get the offset of a vehicle, it is what r* created, not sure why they didnt make one to get offsets from peds this is what the code inside that method is: <Module>.Scripting.?A0x8c04474b.GetOffsetFromCarInWorldCoords(this.pHandle, Offset.X, Offset.Y, Offset.Z, &x, &y, &z); GetOffsetFromCarInWorldCoords was created by rockstar so u can see the method is specific to cars only, so it couldnt be applied to a ped unless u do some reversing and make the method think a ped is a car... that's another story, im sure it is possible though... maybe there is an offset for ped native?? also im not understanding your question but u use offset from car so u dont have to deal with world coordinates and the direction of your car will always be looking up on the y axis and the x axis will always be to the left and right of the car what u need to do is use a horizontal parabola formula opening to the right and position it to the left of your car, think of your car on a x and y axis, the car is at 0, 0 Example:  | CODE | namespace Parabola { using System; using System.Drawing; using System.Windows.Forms; using System.Collections.Generic; using GTA;
public class Main : Script { Blip[] blips;
public Main() { BindKey(Keys.B, Draw); blips = new Blip[61]; }
private void Draw() { foreach (Blip blip in blips) if (Game.Exists(blip)) blip.Delete();
if (!Game.LocalPlayer.Character.isInVehicle()) return;
for (float y = -30; y < 31; y++) blips[(int)y + 30] = Blip.AddBlip(Game.LocalPlayer.Character.CurrentVehicle.GetOffsetPosition(new Vector3(xVal(y, -5, 0, 5), y, 0))); foreach (Blip blip in blips) if (Game.Exists(blip)) blip.Scale = 0.5f; }
private float xVal(float y, float h, float k, float a) { float x = 0;
x = 1 / (4 * a) * ((y - k) * (y - k)) + h;
return x; } } } |
last thing u must do is determine if another car is inside or outside this parabola, the shape of the parabola can be modified by messing with the "a" value, eventually u will position the camera at the vertex and the car will be the focus point at (0, 0)... here i made vertex at (-5, 0) so a = 5 since that is how far vertex is from focus so u would do someting like... camera.Position = vehicle.GetOffsetPosition(new Vetcor3(-5, 0, 0)) This post has been edited by sextitsboobsyeah on Thursday, May 2 2013, 23:36
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
blowjobcumpussy  |
|
Player Hater

Group: BUSTED!
Joined: May 10, 2013

|
| QUOTE (jstq @ Wednesday, May 1 2013, 07:05) | | Player.Position + Player.Direction*150; |
what i wrote before i dont think was correct im just noticing, i fixed it now in quote to what i think u meant to write earlier this is how it works, u start at your player, now your direction represents a length of 1 in the game so it's distance is 1f in the world... understand? so if u have this direction and make it's range 150 times bigger, you can use that value to travel from any point 150f in the direction player is looking  Direction Example: let's say u need a direction from ped to another ped Vector3.Normalize method takes a vector3 value and converts it into a length of 1... example: | CODE | | Vector3.Normalize(Player.Character.Direction * 150) == Player.Character.Direction //this is true |
this is how a Vector3's length is calculated: (x^2 + y^2 + z^2)^0.5 or | CODE | | float vector3Length = (float)Math.Sqrt((vector3.X * vector3.X) + (vector3.Y * vector3.Y) + (vector3.Z * vector3.Z)); |
I explain these because they are important and can help u to understand how to calculate directions or to get a direction from one object to another. For directions from one object to another u simply subtract the position of the object, that the direction originates from, from the position of the object you are looking at. That vector3 value resulting from the subtraction tells u the direction but it is more that 1 unit long so u normalize it, this example below gives u direction from ped1 to ped2: | CODE | | Vector3 directironFromPed1ToPed2 = Vector3.Normalize(ped2.Position - ped1.Position) |
so normalizing the vector3 in this example is actually doing this: | CODE | Vecto3 vector3 = ped2.Position - ped1.Position; float normalizeMultiplier = 1 / vector3.Length();//see length code above
Vector3 directironFromPed1ToPed2 = new Vector3(vector3.X * normalizeMultiplier, vector3.Y * normalizeMultiplier, vector3.Z * normalizeMultiplier); |
this will return true just to illustrate it | CODE | | ped2.Position == Vector3.Normalize(ped2.Position - ped1.Position) * ped1.Position.DistanceTo(ped2.Position) + ped1.Position |
so i think this what u were originally trying to write, hope that makes sense with google translate This post has been edited by blowjobcumpussy on Saturday, May 11 2013, 01:36
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|