AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with reorienting a rocket (Team Fortress Classic) (https://forums.alliedmods.net/showthread.php?t=335461)

wirehead1 12-06-2021 18:19

help with reorienting a rocket (Team Fortress Classic)
 
Hello, okay so in TFC you have a rocket launcher that serves as the aim origin for the rocket, but this is off-center. It kind of diagonally aims the rocket into your crosshair's destination.

I wish to capture a rocket launch event, get the rocket, and re-fire it dead center of the player's aim. I want quake 3 style rockets basically.

Some code snippets to jog the memory:

Quote:

public PlayerPreThink(id)
{
// Apply this to all living human players

if( is_user_alive(id) && !is_user_bot(id) )
{
// See if a player is attacking

static button;
button = pev(id, pev_button);
if ((RocketDelay[id] == 0) && (button & IN_ATTACK) && (LaglessRocketsEnabled[id] == 1))
{
// If he is, see if he's carrying a rocket launcher

new wpnent1 = find_ent_by_owner(-1, "tf_weapon_rpg", id);
if (wpnent1 > 0)// && (LaglessRocketsEnabled[id] == 1))
{
// If he is, find entities within 50 units of the weapon origin

new Float:wpnorig[3];
pev(wpnent1, pev_origin, wpnorig)
new tent = 0;
while((tent = engfunc(EngFunc_FindEntityInSphere, tent, wpnorig, 50.0)))
{
// Check the found entities for RPG rockets

new sztargetname[31];
pev(tent, pev_classname, sztargetname, 31);
if (equal(sztargetname, tf_rpg_rocket))
{
// Determine that a found rocket was fired by the player

new rocketowner = pev(tent, pev_owner);
if (id == rocketowner)
{ //do stuff with rocket here...}}}}}}}

wirehead1 12-06-2021 20:45

Re: help with reorienting a rocket (Team Fortress Classic)
 
In other words, I want to do this:

// get user's view angle
pev( id, pev_v_angle, viewangles );

// get user's origin
pev(id, pev_origin, usrorig);

// move rocket projectile to user's origin
engfunc(EngFunc_SetOrigin, rocket, usrorig);

// change its view angle to players'
set_pev(rocket,pev_angles,viewangles);

// and apply 900 units of speed (vector_length of 900) to it

Here I'm confused.

wirehead1 12-06-2021 21:05

Re: help with reorienting a rocket (Team Fortress Classic)
 
Quake 3 has a command "makevectors" that makes a vector with length of 1 from viewangles.

https://quakewiki.org/wiki/makevectors

What is the amxmodx equivalent of this?

wirehead1 12-06-2021 21:35

Re: help with reorienting a rocket (Team Fortress Classic)
 
Ah, I have it.

velocity_by_aim(iIndex, iVelocity, Float:vRetValue[3]);

HamletEagle 12-07-2021 03:58

Re: help with reorienting a rocket (Team Fortress Classic)
 
Quote:

Originally Posted by wirehead1 (Post 2765242)
Quake 3 has a command "makevectors" that makes a vector with length of 1 from viewangles.

https://quakewiki.org/wiki/makevectors

What is the amxmodx equivalent of this?

https://forums.alliedmods.net/showthread.php?t=262138

wirehead1 12-07-2021 15:39

Re: help with reorienting a rocket (Team Fortress Classic)
 
@HamletEagle yes that page was pivotal in figuring this out, thanks.

Going to make an update to the lagless rocket plugin in some days.


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

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