Hey,
I havn't really searched much on these matters as I normally would but I thought I may aswell.
Im basically creating a new weapon and asking for ideas on firing a rocket.
First I would create the rocket entity.
* What sort of movetype, TOSS?
* Should it be solid?
* The ent size
* Set the model
Then I would set the origin/rotation(so that it lines up with the direction the user is aiming in) - How would I do this?
PHP Code:
set_pev(g_ent_player_model[id], pev_aiment, id)
Then I would set the velocity- How would I do this?
PHP Code:
velocity_by_aim (id, ROCKET_SPEED, rocket_velocity)
Then I would need to detect the impact origin of the rocket and make it explode - Any ideas on this?
On impact it would explode and cause damage in a radius - Using a sphere
PHP Code:
EngFunc_FindEntityInSphere
And search for players?
Then the rocket would be deleted.
I understand that I can find most of this out by looking through plugins, but I have limited time and I intend to do it while waiting on this topic.
I appreciate any help.
Thanks
EDIT:Confused, this code works on a local server made by "create game" on the cs menu. But doesn't work when I put it on my server?
PHP Code:
#include <amxmodx>
#include <fakemeta>
#define MODEL_CLASSNAME "apache_rocket"
#define APACHE_ROCKET_MODEL_PATH "models/rpgrocket.mdl"
#define ROCKET_SPEED "800"
new g_rocket[33]
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, APACHE_ROCKET_MODEL_PATH)
}
public plugin_init()
{
register_concmd("fire_rocket","fm_fire_rocket")
}
public fm_fire_rocket(id)
{
g_rocket[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
client_print(0, print_chat, "Create Named Enitiy")
if(!pev_valid(g_rocket[id])) return;
set_pev(g_rocket[id], pev_classname, MODEL_CLASSNAME)
client_print(0, print_chat, "Model Classname")
set_pev(g_rocket[id], pev_movetype, MOVETYPE_TOSS)
client_print(0, print_chat, "Movetype")
set_pev(g_rocket[id], pev_solid, SOLID_BBOX)
client_print(0, print_chat, "SOLID BBOX")
engfunc(EngFunc_SetSize,g_rocket[id],Float:{-5.0,-5.0,-5.0},Float:{5.0,5.0,5.0})
set_pev(g_rocket[id], pev_owner, id)
client_print(0, print_chat, "owner")
engfunc(EngFunc_SetModel, g_rocket[id], APACHE_ROCKET_MODEL_PATH)
client_print(0, print_chat, "MODEL")
new Float:Origin[3]
pev(id, pev_origin, Origin)
Origin[2] = Origin[2] + 32
engfunc(EngFunc_SetOrigin,g_rocket[id],Origin)
new Float:rocket_velocity[3]
velocity_by_aim (id, 800, rocket_velocity)
client_print(0, print_chat, "VELOCITY")
set_pev(g_rocket[id], pev_velocity, rocket_velocity)
client_print(0, print_chat, "set velocity")
set_task(5.0, "remove_rocket", id)
client_print(0, print_chat, "Task")
}
public remove_rocket(id)
{
remove_task(id)
engfunc(EngFunc_RemoveEntity, g_rocket[id])
client_print(0, print_chat, "Remove rocket")
}
Code is experimental.