Raised This Month: $ Target: $400
 0% 

Solved How to get coordinates of rectangle the corpse lies in?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 11-20-2023 , 20:07   How to get coordinates of rectangle the corpse lies in?
Reply With Quote #1

Hi. Could someone please explain how to get coordinates of rectangle the corpse lies in? I first tried to get EV_VEC_absmin and EV_VEC_absmax but seems it gives me coordinates of alive player (see first image). What I need is illustrated on the second image. White sparkle is player origin for dead player (z axis is shifted toward the ground), black ones are the points I need. Here is what I did.
PHP Code:
static Float:origin[3];
static 
Float:p1[3];
static 
Float:p2[3];
static 
Float:p3[3];
static 
Float:p4[3];

entity_get_vector(cEV_VEC_originorigin);
origin[2] -= 32.0;
p1 origin;
p1[0] -= 16.0;
p2 origin;
p2[0] += 16.0;
p3 p1;
p3[1] += 64.0;
p4 p2;
p4[1] += 64.0
It kinda works, but with no respect to the corpse's angle (see the third image). I tried to apply angle but unfortunately I have poor knowledge of vector algebra.
PHP Code:
get_coordinates(c)
{
    static 
Float:angles[3];

    ...
    
entity_get_vector(cEV_VEC_anglesangles);
    
rotate_point(p1angles[1]);
    ...
}

rotate_point(Float:origin[3], Float:angle)
{
    new 
Float:x;
    new 
Float:y;
    new 
Float:sin;
    new 
Float:cos;

    
origin[0];
    
origin[1];
    
server_print("p [%f, %f, %f]"origin[0], origin[1], origin[2]);
    
sin floatsin(angledegrees);
    
cos floatcos(angledegrees);
    
origin[0] = cos sin;
    
origin[1] = sin cos;
    
server_print("mod [%f, %f, %f]"origin[0], origin[1], origin[2]);

The angle here is the second value for EV_VEC_angles vector as it seems the only value that changes over time. With this function I got completely different coordinates which are far from the original.
PHP Code:
[452.2028802370.059814, -123.968750]
mod [-2408.280761147.831207, -123.968750
The formula I used was found on SO (Rotation in 2D).
Attached Thumbnails
Click image for larger version

Name:	2023-11-21_01:31:10.jpg
Views:	32
Size:	83.6 KB
ID:	202254   Click image for larger version

Name:	2023-11-21_01_29_40(1).jpg
Views:	31
Size:	83.0 KB
ID:	202257   Click image for larger version

Name:	2023-11-21_01:49:44.jpg
Views:	33
Size:	81.6 KB
ID:	202258  

Last edited by damage220; 12-01-2023 at 18:41.
damage220 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-26-2023 , 04:30   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #2

https://github.com/Natsheh11/Jailbre...y_ttt.sma#L367

Btw its not possible to rotate entity size due its limitations to only rectangle shapes..
__________________
@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
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 11-30-2023 , 13:11   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
https://github.com/Natsheh11/Jailbre...y_ttt.sma#L367

Btw its not possible to rotate entity size due its limitations to only rectangle shapes..
I do not want to rotate corpses. I need coordinates of points of corpse's box according to angle the corpse lies on the ground, like you may see on the second image. I would be also happy if someone could advise on how to get corpse center (like stomach coordinates)

Looking at the code I do not see anything related to my problem. There are only corpse's origin and angles which I already have.

Last edited by damage220; 11-30-2023 at 13:12.
damage220 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Siiiiiiiiuu
Old 11-30-2023 , 14:10   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #4

The first picture is correct. When a player dies the death animation is sent and the entity stops being solid. It’s max and mins does not change because if you want the model to be displayed properly it requires the max & mins to stay the same. You should provide more information of what you really want to accomplish so we can tell you what is the best way. Maybe creating a new entity & force a specific death animation would help you. But we can’t tell for sure if you are not telling us what’s your final goal.
__________________
Jhob94 is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 11-30-2023 , 17:46   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #5

Quote:
Originally Posted by Jhob94 View Post
The first picture is correct. When a player dies the death animation is sent and the entity stops being solid. It’s max and mins does not change because if you want the model to be displayed properly it requires the max & mins to stay the same. You should provide more information of what you really want to accomplish so we can tell you what is the best way. Maybe creating a new entity & force a specific death animation would help you. But we can’t tell for sure if you are not telling us what’s your final goal.
My final goal is to allow player to revive another player while standing on that player's corpse. Original idea was to get 4 points to form rectangle and check whether position of the rescuer is inside the rectangle. For now I get corpse's origin and check distance between me and the corpse. My problem is corpse's origin is near legs (light point on image 2). I need it to be at the middle of the corpse.
damage220 is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 12-01-2023 , 14:01   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #6

why not just use distance <= 72 units which is the default player height? you're over-complicating it imo.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-01-2023 , 16:19   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #7

If you want to be specific you can get the BonePosition of the stomach using GetBonePosition function from the engine.

https://wiki.alliedmods.net/FakeMeta...etBonePosition

But the catch is you need an entity corpse that is server side, and not the default corpse because its client side...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-01-2023 at 16:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-01-2023 , 17:38   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #8

Quote:
Originally Posted by georgik57 View Post
why not just use distance <= 72 units which is the default player height? you're over-complicating it imo.
Then you will be able to revive far enough from the corpse, even through the wall.
damage220 is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-01-2023 , 18:40   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
If you want to be specific you can get the BonePosition of the stomach using GetBonePosition function from the engine.

https://wiki.alliedmods.net/FakeMeta...etBonePosition

But the catch is you need an entity corpse that is server side, and not the default corpse because its client side...
Luckily I already have one. Thank you, works great.
PHP Code:
engfunc(EngFunc_GetBonePositionent2pelvis_originpelvis_angles); 
Attached Thumbnails
Click image for larger version

Name:	2023-12-02_00:30:28.jpg
Views:	13
Size:	82.7 KB
ID:	202389  
damage220 is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 12-02-2023 , 06:58   Re: How to get coordinates of rectangle the corpse lies in?
Reply With Quote #10

Quote:
Originally Posted by damage220 View Post
Then you will be able to revive far enough from the corpse, even through the wall.
Corpses will clip through walls anyway. For example with headshot animation while with the back on a wall. 90% of the body will be inside the wall or on the other side of it.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply


Thread Tools
Display Modes

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 07:02.


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