Raised This Month: $ Target: $400
 0% 

Get Map Plane (Surface) Direction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-16-2024 , 00:24   Re: Get Map Plane (Surface) Direction
Reply With Quote #1

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
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-16-2024 at 00:25.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 01-18-2024 , 20:51   Re: Get Map Plane (Surface) Direction
Reply With Quote #2

Quote:
Originally Posted by Natsheh View Post
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.
Phant is offline
Send a message via ICQ to Phant
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-18-2024 , 21:14   Re: Get Map Plane (Surface) Direction
Reply With Quote #3

Quote:
Originally Posted by Phant View Post
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...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 01-19-2024 , 18:23   Re: Get Map Plane (Surface) Direction
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
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 .
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
Attached Thumbnails
Click image for larger version

Name:	crossfire0004.jpg
Views:	20
Size:	82.5 KB
ID:	202887  

Last edited by Phant; 01-19-2024 at 18:26.
Phant is offline
Send a message via ICQ to Phant
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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