AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   change entity path (https://forums.alliedmods.net/showthread.php?t=57671)

kp_uparrow 07-08-2007 20:10

change entity path
 
is there a way to change the path that an entity is flying by origin?? like the entity is going straight, then needs to fly towards a different origin

i need it to fly toward an origin because im trying to create an accuracy effect, the entity try to fly towards the origin dead on but the script gives it some random numbers to make the aiming inaccurate

stupok 07-09-2007 01:59

Re: change entity path
 
How about this?

http://forums.alliedmods.net/showthread.php?t=49343
Code:

set_speed(ent,Float:speed,mode=0,const Float:origin[3]={0.0,0.0,0.0})
/*
*
*  Sets ent's speed in the direction specified
*  by the mode variable
*
*  Modes:
*  0 = In direction ent is currently moving
*        but not including the z axis
*  1 = In direction ent is currently moving
*  2 = In direction ent is currently looking
*  3 = In direction ent is currently looking
*        but not including the z axis
*  4 = In direction of origin[3]
*
*
*  Use a negative speed to go in the opposite
*  direction of the specified mode.
*
*/


kp_uparrow 07-10-2007 01:09

Re: change entity path
 
will try, currently im creating a fake model at the origin and making it follow, really wierd
Code:
stock entity_set_follow(entity, target, Float:speed) {   if (!is_valid_ent(entity) || !is_valid_ent(target)) return 0   new Float:entity_origin[3], Float:target_origin[3]   entity_get_vector(entity, EV_VEC_origin, entity_origin)   entity_get_vector(target, EV_VEC_origin, target_origin)   new Float:diff[3]   diff[0] = target_origin[0] - entity_origin[0]   diff[1] = target_origin[1] - entity_origin[1]   diff[2] = target_origin[2] - entity_origin[2]   new Float:length = floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))   new Float:Velocity[3]   Velocity[0] = diff[0] * (speed / length)   Velocity[1] = diff[1] * (speed / length)   Velocity[2] = diff[2] * (speed / length)   entity_set_vector(entity, EV_VEC_velocity, Velocity)   return 1 }



can i just edit the above to : ?

Code:
stock entity_set_follow2(entity,const Float:target_origin[3]={0.0,0.0,0.0}, Float:speed) {   if (!is_valid_ent(entity)) return 0   new Float:entity_origin[3]   entity_get_vector(entity, EV_VEC_origin, entity_origin)   new Float:diff[3]   diff[0] = target_origin[0] - entity_origin[0]   diff[1] = target_origin[1] - entity_origin[1]   diff[2] = target_origin[2] - entity_origin[2]   new Float:length = floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))   new Float:Velocity[3]   Velocity[0] = diff[0] * (speed / length)   Velocity[1] = diff[1] * (speed / length)   Velocity[2] = diff[2] * (speed / length)   entity_set_vector(entity, EV_VEC_velocity, Velocity)   return 1 }


so far its working!

Ownage 07-10-2007 12:31

Re: change entity path
 
calculating xyz is hard man, hes in calculus right?


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

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