Raised This Month: $ Target: $400
 0% 

Model always in 15 units after eyes


Post New Thread Reply   
 
Thread Tools Display Modes
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 08-08-2008 , 03:35   Re: Model always in 15 units after eyes
Reply With Quote #11

Quote:
Originally Posted by danielkza View Post
I never tested it and i have no time to write the code,but i suppose using and angle vector from the player's eye position will do the job.
The problem is not creating entity but in moving it correctly. Because using pre/postthink of player doesnt change origin of entity as fast as player moves and he can look through entity while he moves faster than frame updates. At every frame player moves about 4-5 units and we need to update at every 1 unit to disallow moving through entity
__________________
draft is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-08-2008 , 12:37   Re: Model always in 15 units after eyes
Reply With Quote #12

Quote:
Originally Posted by draft View Post
The problem is not creating entity but in moving it correctly. Because using pre/postthink of player doesnt change origin of entity as fast as player moves and he can look through entity while he moves faster than frame updates. At every frame player moves about 4-5 units and we need to update at every 1 unit to disallow moving through entity
You can try to hook the server frame, I don't think there's a hook faster than that. But it would be much easier to ajust the model's origin and use pev_aiment/movetype_follow.
danielkza is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 08-08-2008 , 14:46   Re: Model always in 15 units after eyes
Reply With Quote #13

omg, omg............ ive said that i already tried this method....
Quote:
using pre/postthink of player doesnt change origin of entity as fast as player moves and he can look through entity while he moves faster than frame updates
__________________
draft is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-08-2008 , 14:53   Re: Model always in 15 units after eyes
Reply With Quote #14

Quote:
Originally Posted by draft View Post
omg, omg............ ive said that i already tried this method....
I did not say player pre/post think,i explicity said server frame. It's not possible to be a delay using this,it is executed every time the server processess everything.
PHP Code:
register_forward(FM_StartFrame,"fwStartFrame"
danielkza is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-08-2008 , 14:59   Re: Model always in 15 units after eyes
Reply With Quote #15

Or you could create your own that would be quicker:

Code:
new g_thinking_ent; public plugin_init() {     g_thinking_ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));     if( pev_valid(g_thinking_ent) )     {         register_forward(FM_Think, "FwdThink");         set_pev(g_thinking_ent, pev_nextthink, get_gametime() + 1.0);     } } public FwdThink(ent) {     if( ent != g_thinking_ent )     {         return;     }         // your code         set_pev(g_thinking_ent, pev_nextthink, get_gametime()); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-08-2008 , 20:29   Re: Model always in 15 units after eyes
Reply With Quote #16

Anger makes the frog sad. :( Let's clear this up.

draft wants a model to move with a player and always appear 15 units in front of him. However, pev_aiment will set the model to be inside of the player instead of in front of him. Also, using pre/post think hooks doesn't update the model position fast enough; it's choppy.

What Vet was saying is that if you are using your own custom model (as opposed to a stock HL/CS one), you can actually change the model's origin (in a modeling program, not AMXX), so that setting it as pev_aiment will make it appear in front of the player. This is possible and would work.

danielkza also later suggested changing the model's origin (again, in a modeling program, not with AMXX) so that it will appear in front of the player as a pev_aiment. This is possible and would work.

X-olent suggested updating the position in the entity's think, instead of the player's pre/post think, but this might actually be even choppier (or the same as using server frame).

So what to do?

If you are using a custom model, then as suggested before, you should edit the model's origin in a modeling program so that you can just use pev_aiment.

If you are using some other model or you can't edit the model, then you will probably have to use FM_AddToFullPack, but that can be resource-intensive. If this is the case, say so and I can show you how to do this.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 08-08-2008 at 20:31.
XxAvalanchexX is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 08-09-2008 , 04:40   Re: Model always in 15 units after eyes
Reply With Quote #17

=))) Thx for ur attention but ...
ive tried pev_aiment with custom model that ive made in all different ways but pev_aiment makes its angle always in such way that player has the model at back. It was bad surprise but its reality =)
Also, i have found that better way is to use standart, especially player models, because they dont need to be precached by new server players and they are always shown good by wallhacks.
Code:
register_forward(FM_StartFrame,"fwStartFrame") 

thx didnt know about that, so i will try and X-olent method also.
Quote:
FM_AddToFullPack
I would be grateful if u give me some tutor about it

__________________
draft is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-09-2008 , 11:08   Re: Model always in 15 units after eyes
Reply With Quote #18

http://botman.planethalflife.gamespy...d/qaa.shtml#q2

Quote:
Q: I'm trying to attach a model to the player, and believe the right way to go about it is by setting the entity's movetype to MOVETYPE_FOLLOW and it's aiment to the player->edict(). What I don't understand though, is how to specify where on the player the attached model gets attached. I would appreciate any help. Thanks.

A: You cant specify that in the code in any easy way im afraid. What you need to do is when you create the model that your are going to attach, you need to attach it to the same skeleton as the player model uses, and to the bone in that skeleton you want it to follow. For example if your makeing a new weapon, you attach it to the hand, if your making a flag or something, you attach it to the players back or whatever. You can also attach different parts of your model to different parts of the player skeleton if you want to, look at the egon model for example. The backpack is attached to the players back and the gun to the players hand. Hope this helps you out...
I would do that if you could. Here is the alternative:

Code:
#include <amxmodx> #include <fakemeta> // classname of your entity to move new const ENT_CLASS[]   = "whatever"; public plugin_init() {     register_forward(FM_AddToFullPack,"fw_addtofullpack",1); } public fw_addtofullpack(es_state,e,ent,host,hostflags,player,pSet) {     // this was not sent to the client     if(!get_orig_retval()) return FMRES_IGNORED;         // the entity in question is a player, definitely not our entity     if(player) return FMRES_IGNORED;     static classname[24];     pev(ent,pev_classname,classname,23);         // not our entity     if(!equal(classname,ENT_CLASS)) return FMRES_IGNORED;         // assuming you set your entity's owner field to the player     new owner = pev(ent,pev_owner);     if(!is_user_connected(owner)) return FMRES_IGNORED;         // calculate vectors based on our direction     static Float:vAngles[3], Float:vForward[3], Float:vRight[3], Float:vUp[3];     pev(owner,pev_v_angle,vAngles);     engfunc(EngFunc_AngleVectors,vAngles,vForward,vRight,vUp);         // get our view origin     static Float:vOrigin[3], Float:vOffset[3];     pev(owner,pev_origin,vOrigin);     pev(owner,pev_view_ofs,vOffset);         // set the origin to ours plus 15 units forward     for(new i=0;i<3;i++) vOrigin[i] += vOffset[i] + (vForward[i] * 15.0);     set_es(es_state,ES_Origin,vOrigin);         return FMRES_HANDLED; }

The first thing to note is that, testing this just by myself (without any other players), this is called roughly 100 times each second for that one entity (ENT_CLASS) alone. So this can obviously be very intensive, and if you are going to use this, you should come up with more ways to optimize the code. (Maybe set integer pev fields to mark your entity, so you can narrow it down more easily before having to compare a string a million times a minute).

The second thing is that the first check (get_orig_retval) will fail if the entity is not relatively within view of the player. So you will still have to update the entity's origin to the player's origin, although not necessarily every pre/post think. You could use the entity think method that X-olent posted and only have it update every one or two seconds. Also, this method won't work if you set an aiment for the entity.

Cheers.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 08-12-2008 , 08:31   Re: Model always in 15 units after eyes
Reply With Quote #19

Great thanks Avalance for ur help
But... Ive tried to set origin of models with fwStartFrame and it caused great lag when there are a lot of players on server, so other fast-set origin methods are to expensive for CPU, so the only way is to use pev_aiment with model sinchronized with skeleton of player but for now its too hard for me to make it.
But i like the method of addtofullpack forward. Ill try this to detect fov changing in aimbot detections. Lets hope its not so laggy as model updating. Anyway, great thanks and +karma
__________________
draft is offline
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 14:07.


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