AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help on Vectors/Origins. (https://forums.alliedmods.net/showthread.php?t=60277)

Drak 08-30-2007 15:38

Help on Vectors/Origins.
 
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?

purple_pixie 08-31-2007 04:54

Re: Help on Vectors/Origins.
 
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 ].

Greenberet 08-31-2007 05:16

Re: Help on Vectors/Origins.
 
xs is enough...
Code:
xs_vec_sub(const Float:in1[], const Float:in2[], Float:out[]) xs_vec_normalize(const Float:vec[], Float:out[])

Drak 08-31-2007 06:12

Re: Help on Vectors/Origins.
 
Quote:

Originally Posted by Greenberet (Post 525509)
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.


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

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