Raised This Month: $ Target: $400
 0% 

Help on Vectors/Origins.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 08-30-2007 , 15:38   Help on Vectors/Origins.
Reply With Quote #1

I'm trying to figure out how to convert this piece of code from the HLSDK, to AMX.

Code:
void EntityThink( edict_t *pent ) {     edict_t *pEntity = NULL;     int mynum = ENTINDEX(pent);     pEntity = FIND_ENTITY_BY_STRING( pEntity, "classname", "player" );     while (!FNullEnt(pEntity))     {         Vector vecGo = pent->v.origin - pEntity->v.origin;          if (vecGo.Length() > 200)         {             vecGo = vecGo.Normalize();             pEntity->v.velocity = vecGo * 600;         }         pEntity = FIND_ENTITY_BY_STRING( pEntity, "classname", "player" );     }     entvars_t *pev = VARS( pent );     pev->nextthink = gpGlobals->time + 0.1; }

Here's what i have so far:
Code:
public Forward_Think(ent) {     new player;     while((player = engfunc(EngFunc_FindEntityByString,"classname","player")) != 0 )     {                 new Float:entOrigin[3]         new Float:plOrigin[3];                 pev(player,pev_origin,plOrigin);         pev(ent,pev_origin,entOrigin);                 entOrigin[0] - plOrigin[0]         entOrigin[1] - plOrigin[1]         entOrigin[2] - plOrigin[2]                 if(vector_length(entOrigin) > 200)         {         }             } }

I'm stuck at the part of "Vector vecGo = pent->v.origin - pEntity->v.origin;"
How can i create a 'vector' and subject two origins like that?
And then be able to set the players velocity to it?
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 08-31-2007 , 04:54   Re: Help on Vectors/Origins.
Reply With Quote #2

What exactly would that do?

Sounds like you need the chr_engine inc file ...

If you want to set a velocity in the direction of an origin it's definitely what you want ... otherwise I misunderstood - maybe someone else could help if it's clearer [ or maybe it's just not clear to muppets ].
purple_pixie is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 08-31-2007 , 05:16   Re: Help on Vectors/Origins.
Reply With Quote #3

xs is enough...
Code:
xs_vec_sub(const Float:in1[], const Float:in2[], Float:out[]) xs_vec_normalize(const Float:vec[], Float:out[])
__________________
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
Drak
Veteran Member
Join Date: Jul 2005
Old 08-31-2007 , 06:12   Re: Help on Vectors/Origins.
Reply With Quote #4

Quote:
Originally Posted by Greenberet View Post
xs is enough...
Code:
xs_vec_sub(const Float:in1[], const Float:in2[], Float:out[]) xs_vec_normalize(const Float:vec[], Float:out[])
Oh wow, i didn't even know there was those functions.
Works fine now, thanks.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
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 16:16.


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