|
/*
* _______ _ _ __ __
* | _____/ | | | | \ \ __ / /
* | | | | | | | | / \ | |
* | | | |____| | | |/ __ \| |
* | | ___ | ______ | | / \ |
* | | |_ | | | | | | / \ |
* | | | | | | | | | | | |
* | |____| | | | | | | | | |
* |_______/ |_| |_| \_/ \_/
*
*
*
* Last Edited: 12-31-07
*
* ============
* Changelog:
* ============
*
* v2.0
* -Added ML
*
* v1.0
* -Initial Release
*
*/
#define VERSION "2.0"
#include <amxmodx>
#include <amxmisc>
#include <chr_engine>
#define PET_NUM 7
static const pet_name[PET_NUM][32] =
{
"Headcrab",
"Rat",
"Bat",
"Frog",
"Floater",
"Cockroach",
"Hyper Bat"
}
static const pet_models[PET_NUM][32] =
{
"models/headcrab.mdl",
"models/bigrat.mdl",
"models/boid.mdl",
"models/chumtoad.mdl",
"models/floater.mdl",
"models/roach.mdl",
"models/stukabat.mdl"
}
static const pet_idle[PET_NUM] =
{
0,
1,
0,
0,
0,
1,
13
}
static const Float:pet_idle_speed[PET_NUM] =
{
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
0.5
}
static const pet_run[PET_NUM] =
{
4,
4,
0,
5,
0,
0,
13
}
static const Float:pet_run_speed[PET_NUM] =
{
2.0,
3.0,
3.0,
0.75,
1.0,
1.0,
13.0
}
static const pet_die[PET_NUM] =
{
7,
7,
0,
12,
0,
0,
5
}
static const Float:pet_die_length[PET_NUM] =
{
2.4,
2.4,
0.1,
3.0,
0.1,
0.1,
3.0
}
static const Float:pet_minus_z_standing[PET_NUM] =
{
36.0,
36.0,
5.0,
36.0,
5.0,
36.0,
10.0
}
static const Float:pet_minus_z_crouching[PET_NUM] =
{
16.0,
16.0,
6.0,
16.0,
6.0,
16.0,
11.0
}
new pet[33]
new pettype[33]
new maxplayers
public plugin_init()
{
register_plugin("GHW Pet Followers",VERSION,"GHW_Chronic")
register_clcmd("say","say_hook")
register_clcmd("say_team","say_hook")
register_event("DeathMsg","DeathMsg","a")
register_forward(FM_Think,"FM_Think_hook")
maxplayers = get_maxplayers()
register_dictionary("GHW_Pet_Followers.txt")
}
public plugin_precache()
{
for(new i=0;i<PET_NUM;i++) precache_model(pet_models[i])
}
public DeathMsg(id) handle_DeathMsg(read_data(2))
public handle_DeathMsg(id)
{
if(pet[id] && pev_valid(pet[id]))
{
set_pev(pet[id],pev_sequence,pet_die[pettype[id]])
set_pev(pet[id],pev_gaitsequence,pet_die[pettype[id]])
set_pev(pet[id],pev_framerate,1.0)
set_pev(pet[id],pev_nextthink,pet_die_length[pettype[id]] + 1.0)
set_task(pet_die_length[pettype[id]],"remove_pet",pet[id])
}
pet[id]=0
}
public remove_pet(ent) if(pev_valid(ent)) engfunc(EngFunc_RemoveEntity,ent)
public say_hook(id)
{
new arg[32]
read_argv(1,arg,31)
if(equali(arg,"/pet Headcrab")) pet_cmd_handle(id,0)
else if(equali(arg,"/pet Rat")) pet_cmd_handle(id,1)
else if(equali(arg,"/pet Bat")) pet_cmd_handle(id,2)
else if(equali(arg,"/pet Frog")) pet_cmd_handle(id,3)
else if(equali(arg,"/pet Floater")) pet_cmd_handle(id,4)
else if(equali(arg,"/pet Cockroach")) pet_cmd_handle(id,5)
else if(equali(arg,"/pet Hyper") || equali(arg,"/pet Hyper Bat")) pet_cmd_handle(id,6)
else if(containi(arg,"/pet")==0) pet_cmd_handle(id,random_num(0,PET_NUM-1))
else if(containi(arg,"/nopet")==0)
{
handle_DeathMsg(id)
if(pet[id]) client_print(id,print_chat,"[AMXX] %L",id,"MSG_REMOVEPET")
else client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOREMOVEPET")
}
}
public pet_cmd_handle(id,num)
{
if(pet[id])
{
client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOGIVEPET_HAVE")
}
else if(!is_user_alive(id))
{
client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOGIVEPET_DEAD")
}
else
{
pet[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
set_pev(pet[id],pev_classname,"GHW_Pet")
pettype[id] = num
engfunc(EngFunc_SetModel,pet[id],pet_models[pettype[id]])
new Float:origin[3]
pev(id,pev_origin,origin)
if(is_user_crouching(id)) origin[2] -= pet_minus_z_crouching[pettype[id]]
else origin[2] -= pet_minus_z_standing[pettype[id]]
set_pev(pet[id],pev_origin,origin)
set_pev(pet[id],pev_solid,SOLID_NOT)
set_pev(pet[id],pev_movetype,MOVETYPE_FLY)
set_pev(pet[id],pev_owner,33)
set_pev(pet[id],pev_nextthink,1.0)
set_pev(pet[id],pev_sequence,0)
set_pev(pet[id],pev_gaitsequence,0)
set_pev(pet[id],pev_framerate,1.0)
client_print(id,print_chat,"[AMXX] %L",id,"MSG_GIVEPET",pet_name[pettype[id]])
}
}
public FM_Think_hook(ent)
{
for(new i=0;i<=maxplayers;i++)
{
if(ent==pet[i])
{
static Float:origin[3]
static Float:origin2[3]
static Float:velocity[3]
pev(ent,pev_origin,origin2)
get_offset_origin_body(i,Float:{50.0,0.0,0.0},origin)
if(is_user_crouching(i)) origin[2] -= pet_minus_z_crouching[pettype[i]]
else origin[2] -= pet_minus_z_standing[pettype[i]]
if(get_distance_f(origin,origin2)>300.0)
{
set_pev(ent,pev_origin,origin)
}
else if(get_distance_f(origin,origin2)>80.0)
{
get_speed_vector(origin2,origin,250.0,velocity)
set_pev(ent,pev_velocity,velocity)
if(pev(ent,pev_sequence)!=pet_run[pettype[i]] || pev(ent,pev_framerate)!=pet_run_speed[pettype[i]])
{
set_pev(ent,pev_sequence,pet_run[pettype[i]])
set_pev(ent,pev_gaitsequence,pet_run[pettype[i]])
set_pev(ent,pev_framerate,pet_run_speed[pettype[i]])
}
}
else if(get_distance_f(origin,origin2)<75.0)
{
if(pev(ent,pev_sequence)!=pet_idle[pettype[i]] || pev(ent,pev_framerate)!=pet_idle_speed[pettype[i]])
{
set_pev(ent,pev_sequence,pet_idle[pettype[i]])
set_pev(ent,pev_gaitsequence,pet_idle[pettype[i]])
set_pev(ent,pev_framerate,pet_idle_speed[pettype[i]])
}
set_pev(ent,pev_velocity,Float:{0.0,0.0,0.0})
}
pev(i,pev_origin,origin)
origin[2] = origin2[2]
entity_set_aim(ent,origin)
set_pev(ent,pev_nextthink,1.0)
break;
}
}
} |
|