AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get Map Plane (Surface) Direction (https://forums.alliedmods.net/showthread.php?t=345463)

Phant 01-15-2024 18:11

Get Map Plane (Surface) Direction
 
1 Attachment(s)
I have Float coordinates (XYZ) on a map, lying on some physical plane of the map. How can I obtain the direction (vector?) of the plane on which this point is located? For example, if it's a regular flat floor, the direction is strictly vertical (90° upward). Thank you.

DJEarthQuake 01-15-2024 21:33

Re: Get Map Plane (Surface) Direction
 
Always null {0,0,0} since it is not moving.

Natsheh 01-16-2024 00:24

Re: Get Map Plane (Surface) Direction
 
You need to execute a traceline from a point in/to a wall/floor/ceiling/surface and then collect the required data from the tracehandler according to what you need which is TR_vecPlaneNormal

fysiks 01-16-2024 02:44

Re: Get Map Plane (Surface) Direction
 
Quote:

Originally Posted by DJEarthQuake (Post 2816117)
Always null {0,0,0} since it is not moving.

The question isn't related to velocity.

Phant 01-18-2024 20:51

Re: Get Map Plane (Surface) Direction
 
Quote:

Originally Posted by Natsheh (Post 2816122)
You need to execute a traceline from a point in/to a wall/floor/ceiling/surface and then collect the required data from the tracehandler according to what you need which is TR_vecPlaneNormal

Thanks for your reply.
I work with cannons (func_tankmortar) on the crossfire map (Half-Life). Specifically, I intercept env_explosion:

At the moment of its call, I can determine that it was produced from the cannon (func_tankmortar), the coordinates, and angles of the cannon (if I'm doing everything correctly). Therefore, having the final coordinates of env_explosion, I can call EngFunc_TraceLine (with subsequent TR_vecPlaneNormal), but this code doesn't work.
Code:
    new szClassname[32]     pev(inflictor, pev_classname, szClassname, 31)     client_print(0, print_chat, "CLASSNAME: %s", szClassname)     new Float:originet[3]     pev(inflictor, pev_origin, originet)     client_print(0, print_chat, "ORIGIN OF CANNON: %f %f %f", originet[0], originet[1], originet[2])     new Float:angles[3]     pev(inflictor, pev_angles, angles)     client_print(0, print_chat, "ANGLES OF CANNON: %f %f %f", angles[0], angles[1], angles[2])         new Float:NormalVector[3]     new trace = create_tr2()     engfunc(EngFunc_TraceLine, originet, angles, IGNORE_MONSTERS, 0, trace)     get_tr2(trace, TR_vecPlaneNormal, NormalVector)     free_tr2(trace)     client_print(0, print_chat, "NORMAL_VEC: %f %f %f", NormalVector[0], NormalVector[1], NormalVector[2])
I must be doing something wrong. There are plenty of examples on the forum, but most of them are related to the player's point of view.

Natsheh 01-18-2024 21:14

Re: Get Map Plane (Surface) Direction
 
Quote:

Originally Posted by Phant (Post 2816259)
Thanks for your reply.
I work with cannons (func_tankmortar) on the crossfire map (Half-Life). Specifically, I intercept env_explosion:

At the moment of its call, I can determine that it was produced from the cannon (func_tankmortar), the coordinates, and angles of the cannon (if I'm doing everything correctly). Therefore, having the final coordinates of env_explosion, I can call EngFunc_TraceLine (with subsequent TR_vecPlaneNormal), but this code doesn't work.
Code:
    new szClassname[32]     pev(inflictor, pev_classname, szClassname, 31)     client_print(0, print_chat, "CLASSNAME: %s", szClassname)     new Float:originet[3]     pev(inflictor, pev_origin, originet)     client_print(0, print_chat, "ORIGIN OF CANNON: %f %f %f", originet[0], originet[1], originet[2])     new Float:angles[3]     pev(inflictor, pev_angles, angles)     client_print(0, print_chat, "ANGLES OF CANNON: %f %f %f", angles[0], angles[1], angles[2])         new Float:NormalVector[3]     new trace = create_tr2()     engfunc(EngFunc_TraceLine, originet, angles, IGNORE_MONSTERS, 0, trace)     get_tr2(trace, TR_vecPlaneNormal, NormalVector)     free_tr2(trace)     client_print(0, print_chat, "NORMAL_VEC: %f %f %f", NormalVector[0], NormalVector[1], NormalVector[2])
I must be doing something wrong. There are plenty of examples on the forum, but most of them are related to the player's point of view.

Indeed you are...

engfunc(EngFunc_TraceLine, originet, angles, IGNORE_MONSTERS, 0, trace)

The 2nd parameter here (angles) should be replaced with the end coords of where the Traceline should go AKA destination coordinates...

The 4th parameter here ( 0 ) should be replaced with the entity to ignore which in your case is inflictor since we don't need the traceline to stop at the begining...

DJEarthQuake 01-19-2024 16:19

Re: Get Map Plane (Surface) Direction
 
Ok when I saw (vector?) that got me. TR_vecPlaneNormal... looks like I need to brush up on my calculus. Never have I seen a need for that. What are you trying to accomplish by intercepting env_explosion? There are plugins that can make one view the course with cords by attaching view all the way to blocking the boom by having the crowbar drawn already as the shell approaches.

Phant 01-19-2024 18:23

Re: Get Map Plane (Surface) Direction
 
1 Attachment(s)
Quote:

Originally Posted by Natsheh (Post 2816260)
Indeed you are...

engfunc(EngFunc_TraceLine, originet, angles, IGNORE_MONSTERS, 0, trace)

The 2nd parameter here (angles) should be replaced with the end coords of where the Traceline should go AKA destination coordinates...

The 4th parameter here ( 0 ) should be replaced with the entity to ignore which in your case is inflictor since we don't need the traceline to stop at the begining...

I made changes to the code, but NORMAL_VEC (NormalVector) are still equal to zero :cry:.
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> #include <engine> #define PLUGIN "Crossfire Cannons" #define VERSION "1.0" #define AUTHOR "Phant" #define MODEL   "models/cindergibs.mdl" #define TE_BREAKMODEL   108 #define VELOCITY    75 #define VELOCITY_RANDOM 10 #define SIZE    10 #define LIFE    50 #define THROWING_POWER  200 new g_model public plugin_precache() {     g_model = precache_model(MODEL) } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     RegisterHam(Ham_Spawn, "env_explosion", "explosion_spwn", 1) } public explosion_spwn(iEnt) {     new Float:origin[3]     pev(iEnt, pev_origin, origin)     new inflictor = pev(iEnt, pev_owner)     client_print(0, print_chat, "OWNER: %i", inflictor)     new szClassname[32]     pev(inflictor, pev_classname, szClassname, 31)     client_print(0, print_chat, "CLASSNAME: %s", szClassname)     new Float:originet[3]     pev(inflictor, pev_origin, originet)     client_print(0, print_chat, "ORIGIN OF CANNON: %f %f %f", originet[0], originet[1], originet[2])     new Float:angles[3]     pev(inflictor, pev_angles, angles)     client_print(0, print_chat, "ANGLES OF CANNON: %f %f %f", angles[0], angles[1], angles[2])         new Float:NormalVector[3]     new trace = create_tr2()     engfunc(EngFunc_TraceLine, originet, origin, IGNORE_MONSTERS, inflictor, trace)     get_tr2(trace, TR_vecPlaneNormal, NormalVector)     client_print(0, print_chat, "NORMAL_VEC: %f %f %f", NormalVector[0], NormalVector[1], NormalVector[2])     free_tr2(trace)         toss_gibs(origin) } public toss_gibs(Float:origin[3]) {     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)     write_byte(TE_BREAKMODEL)     write_coord(floatround(origin[0]))     write_coord(floatround(origin[1]))     write_coord(floatround(origin[2]))     write_coord(SIZE)     write_coord(SIZE)     write_coord(SIZE)     write_coord(random_num(-VELOCITY, VELOCITY))     write_coord(random_num(-VELOCITY, VELOCITY))     write_coord(THROWING_POWER)     write_byte(VELOCITY_RANDOM)     write_short(g_model)     write_byte(random_num(8, 16))     write_byte(LIFE)     write_byte(0)     message_end() }
Code:

OWNER: 277
CLASSNAME: func_tankmortar
ORIGIN OF CANNON: -368.000000 -1520.000000 -1360.000000
ANGLES OF CANNON: 21.164882 84.911384 0.000000
NORMAL_VEC: 0.000000 0.000000 0.000000


DJEarthQuake 01-19-2024 19:09

Re: Get Map Plane (Surface) Direction
 
Good luck!

Natsheh 01-20-2024 00:53

Re: Get Map Plane (Surface) Direction
 
There, this should give out the needed results...

Spoiler


All times are GMT -4. The time now is 00:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.