Junior Member
|
09-02-2012
, 17:40
[Ayuda] Pasar plugin de Hero Mod a Zombie Mod
|
#1
|
Hola como dice el nombre, estoy intentando pasar un plugin de heroMod a ZombieMod y no me sale. Me podrian decir alguna manera para que me saliera bien, quiero aprender para pasar mas códigos de HeroMod a ZombieMod y si alguen me pudiera enseñar gracias
PHP Code:
// ---END OF BAZOOKA CVARS---
*/
#include <amxmod>
#include <amxmisc>
#include <Vexd_Utilities>
#include <superheromod>
#if defined AMX98
#include <cmath>
#endif
#define DT 0.1
#define PI 3.1415926535897932384626433832795
new beam, boom, ls_dot
new Float:fAngleBaz
new bool:roundfreeze
new round_delay
new has_rocket[33]
/* missile_inv: fake,common,laserguide,guncam,antimissile,heatseeker,ropeseeking,multimissile */
new missile_inv[33][8]
new using_menu[33]
new is_scan_rocket[33]
new is_heat_rocket[33]
new radar_batt[33]
new gHeroName[]="Bazooka"
new bool:gHasBazookaPowers[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Bazooka","4.0","JTP10181 / AssKicR")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("bazooka_level", "8" )
register_cvar("bazooka_buy","0")
register_cvar("bazooka_fuel","6.0")
register_cvar("bazooka_sdfuel","2.0")
register_cvar("bazooka_sdcount","6")
register_cvar("bazooka_sdrotate","6")
register_cvar("bazooka_sdradius","32")
register_cvar("bazooka_ammo1","2")
register_cvar("bazooka_ammo2","2")
register_cvar("bazooka_ammo3","1")
register_cvar("bazooka_ammo4","1")
register_cvar("bazooka_ammo5","1")
register_cvar("bazooka_ammo6","1")
register_cvar("bazooka_ammo7","1")
register_cvar("bazooka_ammo7ta","0")
register_cvar("bazooka_cost1","1000")
register_cvar("bazooka_cost2","3000")
register_cvar("bazooka_cost3","3000")
register_cvar("bazooka_cost4","2000")
register_cvar("bazooka_cost5","4000")
register_cvar("bazooka_cost6","4000")
register_cvar("bazooka_cost7","5000")
register_cvar("bazooka_speed","1000")
register_cvar("bazooka_sdspeed","750")
register_cvar("bazooka_hsspeed","1200")
register_cvar("bazooka_rsspeed","1200")
register_cvar("bazooka_obeygravity","1")
register_cvar("bazooka_damradius","240")
register_cvar("bazooka_maxdamage","140")
register_cvar("bazooka_radarbattery","100")
register_cvar("bazooka_spawndelay","0")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Rocket-Laucher", "Fire Many Different Types of Rockets", true, "bazooka_level" )
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("bazooka_init", "bazooka_init")
shRegHeroInit(gHeroName, "bazooka_init")
// KEYDOWN
register_srvcmd("bazooka_kd", "bazooka_kd")
shRegKeyDown(gHeroName, "bazooka_kd")
//CLIENT QUICK COMMANDS
register_clcmd("bazooka_missile","fire_missile")
register_clcmd("bazooka_laserguided_missile","fire_missile")
register_clcmd("bazooka_guncamera_missile","fire_missile")
register_clcmd("bazooka_anti_missile","fire_missile")
register_clcmd("bazooka_heatseeking_missile","fire_missile")
register_clcmd("bazooka_ropeseeking_missile","fire_missile")
register_clcmd("bazooka_swirlingdeath_missile","fire_missile")
//EVENTS
register_logevent("round_start", 2, "1=Round_Start")
register_logevent("round_end", 2, "1=Round_End")
register_logevent("round_end", 2, "1&Restart_Round_")
register_event("DeathMsg","death_event","a")
//MISSILE MENU
register_menucmd(register_menuid("Fire Missile Menu"),1023,"action_main_menu")
//MISSILE CHECKS
register_srvcmd("lasermissile_chk","laser_check")
//SWIRLING DEATH MISSILES
set_task(0.1,"RocketThink",0,"",0,"b")
}
//----------------------------------------------------------------------------------------------
public bazooka_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has BlackLotus
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gHasBazookaPowers[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------
public bazooka_kd()
{
if ( !hasRoundStarted() ) return PLUGIN_HANDLED
// First Argument is an id with bazooka
new temp[6]
read_argv(1,temp,5)
new id=str_to_num(temp)
if ( !is_user_alive(id) || !gHasBazookaPowers[id] ) return PLUGIN_HANDLED
show_main_menu(id)
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound("vox/_period.wav")
precache_sound("debris/beamstart8.wav")
precache_sound("weapons/explode3.wav")
precache_sound("weapons/rocketfire1.wav")
precache_sound("ambience/rocket_steam1.wav")
precache_sound("weapons/rocket1.wav")
precache_sound("ambience/particle_suck2.wav")
precache_model("models/rpgrocket.mdl")
beam = precache_model("sprites/smoke.spr")
boom = precache_model("sprites/zerogxplode.spr")
ls_dot = precache_model("sprites/laserdot.spr")
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
is_scan_rocket[id] = 0
is_heat_rocket[id] = 0
using_menu[id] = 0
has_rocket[id] = 0
if(get_cvar_num("bazooka_buy") == 0){
missile_inv[id][1] = get_cvar_num("bazooka_ammo1")
missile_inv[id][2] = get_cvar_num("bazooka_ammo2")
missile_inv[id][3] = get_cvar_num("bazooka_ammo3")
missile_inv[id][4] = get_cvar_num("bazooka_ammo4")
missile_inv[id][5] = get_cvar_num("bazooka_ammo5")
missile_inv[id][6] = get_cvar_num("bazooka_ammo6")
missile_inv[id][7] = get_cvar_num("bazooka_ammo7")
}
radar_batt[id] = get_cvar_num("bazooka_radarbattery")
}
//----------------------------------------------------------------------------------------------
public client_disconnect(id)
{
remove_task(id)
is_scan_rocket[id] = 0
is_heat_rocket[id] = 0
has_rocket[id] = 0
}
//----------------------------------------------------------------------------------------------
#if defined AMX_NEW
public vexd_pfntouch(pToucher, pTouched) {
entity_touch(pToucher, pTouched)
}
public entity_touch(entity1, entity2) {
new pToucher = entity1
new pTouched = entity2
#else
public vexd_pfntouch(pToucher, pTouched) {
#endif
if ( !is_valid_ent(pToucher) ) return
new szClassName[32]
Entvars_Get_String(pToucher, EV_SZ_classname, szClassName, 31)
if(equal(szClassName, "bazooka_missile_ent")) {
new damradius = get_cvar_num("bazooka_damradius")
new maxdamage = get_cvar_num("bazooka_maxdamage")
if (damradius <= 0) {
debugMessage("(Bazooka) Damage Radius must be set higher than 0, defaulting to 240",0,0)
damradius = 240
set_cvar_num("bazooka_damradius",damradius)
}
if (maxdamage <= 0) {
debugMessage("(Bazooka) Max Damage must be set higher than 0, defaulting to 140",0,0)
maxdamage = 140
set_cvar_num("bazooka_maxdamage",maxdamage)
}
remove_task(pToucher)
new Float:fl_vExplodeAt[3]
Entvars_Get_Vector(pToucher, EV_VEC_origin, fl_vExplodeAt)
new vExplodeAt[3]
vExplodeAt[0] = floatround(fl_vExplodeAt[0])
vExplodeAt[1] = floatround(fl_vExplodeAt[1])
vExplodeAt[2] = floatround(fl_vExplodeAt[2])
new id = Entvars_Get_Edict(pToucher, EV_ENT_owner)
new origin[3],dist,i,Float:dRatio,damage
AttachView(id, id)
if(has_rocket[id] == pToucher)
has_rocket[id] = 0
for ( i = 1; i <= SH_MAXSLOTS; i++) {
if( !is_user_alive(i) ) continue
get_user_origin(i,origin)
dist = get_distance(origin,vExplodeAt)
if (dist <= damradius) {
dRatio = floatdiv(float(dist),float(damradius))
damage = maxdamage - floatround( maxdamage * dRatio)
shExtraDamage(i, id, damage, "Bazooka" )
}
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(3)
write_coord(vExplodeAt[0])
write_coord(vExplodeAt[1])
write_coord(vExplodeAt[2])
write_short(boom)
write_byte(100)
write_byte(15)
write_byte(0)
message_end()
emit_sound(pToucher, CHAN_WEAPON, "weapons/explode3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(pToucher, CHAN_VOICE, "weapons/explode3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
RemoveEntity(pToucher)
is_heat_rocket[id] = 0
is_scan_rocket[id] = 0
if ( is_valid_ent(pTouched) ) {
new szClassName2[32]
Entvars_Get_String(pTouched, EV_SZ_classname, szClassName2, 31)
if(equal(szClassName2, "bazooka_missile_ent")) {
remove_task(pTouched)
emit_sound(pTouched, CHAN_WEAPON, "weapons/explode3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(pTouched, CHAN_VOICE, "weapons/explode3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
new id2 = Entvars_Get_Edict(pTouched, EV_ENT_owner)
AttachView(id2, id2)
if(has_rocket[id2] == pTouched){
has_rocket[id2] = 0
is_heat_rocket[id2] = 0
is_scan_rocket[id2] = 0
}
RemoveEntity(pTouched)
}
}
}
}
//----------------------------------------------------------------------------------------------
public fire_missile(id)
{
if( roundfreeze || !is_user_alive(id))
return PLUGIN_HANDLED
if ( !gHasBazookaPowers[id] ) {
client_print(id,print_chat,"[SH](Bazooka) You do not have this hero")
return PLUGIN_HANDLED
}
show_missile_inv(id)
if(has_rocket[id]){
client_print(id,print_chat,"[SH](Bazooka) You cannot have more than one missile in the air at a time.")
return PLUGIN_HANDLED
}
new cmd[32],icmd
read_argv(0,cmd,31)
if(equal(cmd,"bazooka_missile")) icmd = 1
else if(equal(cmd,"bazooka_laserguided_missile")) icmd = 2
else if(equal(cmd,"bazooka_guncamera_missile")) icmd = 3
else if(equal(cmd,"bazooka_heatseeking_missile")) icmd = 5
else if(equal(cmd,"bazooka_ropeseeking_missile")) icmd = 6
else if(equal(cmd,"bazooka_swirlingdeath_missile")) icmd = 7
else icmd = 4
if(icmd == 4){
if(radar_batt[id] <= 0){
client_print(id,print_chat,"[SH](Bazooka) Your anti-missile radar batteries are dead.")
return PLUGIN_HANDLED
}
if(is_scan_rocket[id] == 1) {
remove_task(id)
is_scan_rocket[id] = 0
missile_inv[id][icmd] += 1
show_missile_inv(id)
if(using_menu[id])
show_main_menu(id)
set_hudmessage(0,255,0, -1.0, 0.30, 0, 0.02, 3.0, 1.01, 1.1, 4)
show_hudmessage(id,"ANTIMISSILE RADAR DEACTIVATED")
return PLUGIN_HANDLED
}
}
if( (icmd == 4 || icmd == 7) && (round_delay) && (get_cvar_num("bazooka_spawndelay")) ){
client_print(id,print_chat,"[SH](Bazooka) This missile type cannot be fired until 15 seconds after round start.")
return PLUGIN_HANDLED
}
if(get_cvar_num("bazooka_buy") == 1) {
new cvarname[32]
format(cvarname,31,"bazooka_cost%d",icmd)
new umoney = get_user_money(id)
new m_cost = get_cvar_num(cvarname)
if(umoney < m_cost){
client_print(id,print_chat,"[SH](Bazooka) Insufficient funds. Each of these missiles costs %d money",m_cost)
return PLUGIN_HANDLED
}
else {
set_user_money(id,umoney-m_cost,1)
}
}
else {
if( icmd == 7 && get_cvar_num("bazooka_ammo7ta")){
new sum
for(new i = 1; i <= 7; i++)
sum += missile_inv[id][i]
if(sum < 7) {
client_print(id,print_chat,"[SH](Bazooka) You do not have enough missiles to make a Swirling Death Missile.")
if (using_menu[id]) show_main_menu(id)
return PLUGIN_HANDLED
}
else{
new take
for(new b = 1; b <= 7; b++){
if(take < 7) {
for(new i=1; i <= 7; i++){
if( (missile_inv[id][i] > 0) && (take < 7) ){
missile_inv[id][i]--
take++
}
}
}
}
}
}
else if( missile_inv[id][icmd] <= 0 ){
switch(icmd){
case 1: client_print(id,print_chat,"[SH](Bazooka) You have no more Common Missiles.")
case 2: client_print(id,print_chat,"[SH](Bazooka) You have no more Laser Guided Missiles.")
case 3: client_print(id,print_chat,"[SH](Bazooka) You have no more Gun Camera Missiles.")
case 4: client_print(id,print_chat,"[SH](Bazooka) You have no more Anti-Missile Missiles.")
case 5: client_print(id,print_chat,"[SH](Bazooka) You have no more Heat Seeking Missiles.")
case 6: client_print(id,print_chat,"[SH](Bazooka) You have no more Rope Seeking Missiles.")
case 7: client_print(id,print_chat,"[SH](Bazooka) You have no more Swirling Death Missiles.")
}
return PLUGIN_HANDLED
}
else {
missile_inv[id][icmd] -= 1
}
}
if(icmd != 4){
show_missile_inv(id)
switch(icmd){
case 1: make_rocket(id,icmd,get_cvar_num("bazooka_speed"),0)
case 2: make_rocket(id,icmd,get_cvar_num("bazooka_speed"),0)
case 3: make_rocket(id,icmd,get_cvar_num("bazooka_speed"),0)
case 5: make_rocket(id,icmd,get_cvar_num("bazooka_hsspeed"),0)
case 6: make_rocket(id,icmd,get_cvar_num("bazooka_rsspeed"),0)
case 7: make_rocket(id,icmd,get_cvar_num("bazooka_sdspeed"),0)
default: make_rocket(id,icmd,get_cvar_num("bazooka_speed"),0)
}
}
else {
is_scan_rocket[id] = 1
set_task(0.2,"anti_missile_radar",id,"",0,"b")
set_task(0.3,"amr_pay",id,"",0,"b")
set_hudmessage(0,255,0, -1.0, 0.26, 0, 0.02, 3.0, 1.01, 1.1, 54)
show_hudmessage(id,"ANTIMISSILE RADAR SYSTEM ACTIVATED^nAim at missile you want to shoot down")
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public anti_missile_radar(id)
{
new tid = 0
new aimvec[3],origin[3],length
new radarvec1[3],radarvec2[3],radarvec3[3],radarvec4[3],radarvec5[3]
get_user_origin(id,origin)
get_user_origin(id,aimvec,3)
radarvec1[0]=aimvec[0]-origin[0]
radarvec1[1]=aimvec[1]-origin[1]
radarvec1[2]=aimvec[2]-origin[2]
length = sqroot(radarvec1[0]*radarvec1[0]+radarvec1[1]*radarvec1[1]+radarvec1[2]*radarvec1[2])
radarvec5[0]=radarvec1[0]*1750/length + origin[0]
radarvec5[1]=radarvec1[1]*1750/length + origin[1]
radarvec5[2]=radarvec1[2]*1750/length + origin[2]
radarvec4[0]=radarvec1[0]*1350/length + origin[0]
radarvec4[1]=radarvec1[1]*1350/length + origin[1]
radarvec4[2]=radarvec1[2]*1350/length + origin[2]
radarvec3[0]=radarvec1[0]*950/length + origin[0]
radarvec3[1]=radarvec1[1]*950/length + origin[1]
radarvec3[2]=radarvec1[2]*950/length + origin[2]
radarvec2[0]=radarvec1[0]*700/length + origin[0]
radarvec2[1]=radarvec1[1]*700/length + origin[1]
radarvec2[2]=radarvec1[2]*700/length + origin[2]
radarvec1[0]=radarvec1[0]*350/length + origin[0]
radarvec1[1]=radarvec1[1]*350/length + origin[1]
radarvec1[2]=radarvec1[2]*350/length + origin[2]
for(new i=1; i <= SH_MAXSLOTS; i++) {
if( (has_rocket[i] > SH_MAXSLOTS) && (i != id) && (tid < SH_MAXSLOTS) ){
new szClassName[32]
Entvars_Get_String(has_rocket[i], EV_SZ_classname, szClassName, 31)
if(equal(szClassName, "bazooka_missile_ent")) {
new rocketvec[3]
new Float:fl_rocketvec[3]
Entvars_Get_Vector(has_rocket[i], EV_VEC_origin, fl_rocketvec)
rocketvec[0] = floatround(fl_rocketvec[0])
rocketvec[1] = floatround(fl_rocketvec[1])
rocketvec[2] = floatround(fl_rocketvec[2])
if(get_distance(radarvec5,rocketvec) < 100)
tid = has_rocket[i]
else if(get_distance(radarvec4,rocketvec) < 100)
tid = has_rocket[i]
else if(get_distance(radarvec3,rocketvec) < 85)
tid = has_rocket[i]
else if(get_distance(radarvec2,rocketvec) < 70)
tid = has_rocket[i]
else if(get_distance(radarvec1,rocketvec) < 50)
tid = has_rocket[i]
}
}
}
if(tid > SH_MAXSLOTS){
client_cmd(id,"spk fvox/beep")
set_hudmessage(255,10,10, -1.0, 0.26, 0, 0.02, 3.0, 1.01, 1.1, 54)
show_hudmessage(id,"ANTIMISSILE LOCKED ONTO TARGET")
is_scan_rocket[id] = 0
remove_task(id)
make_rocket(id,4,get_cvar_num("bazooka_speed")*5,tid)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public amr_pay(id)
{
set_hudmessage(255,0,0, -1.0, 0.26, 0, 0.02, 3.0, 1.01, 1.1, 54)
if(radar_batt[id] < 1){
show_hudmessage(id,"WARNING: ANTIMISSILE RADAR SYSTEM FAILURE")
client_print(id,print_center,"^n^nBattery is dead")
is_scan_rocket[id] = 0
remove_task(id)
}
else{
client_print(id,print_center,"^n^n^nBattery %d",radar_batt[id])
}
radar_batt[id]--
client_cmd(id,"spk fvox/blip")
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
//make_rocket(userindex,commandtype,missilespeed,antimissleid)
make_rocket(id,icmd,iarg1,antimissile)
{
new args[16]
new Float:vOrigin[3]
new Float:vAngles[3]
Entvars_Get_Vector(id, EV_VEC_origin, vOrigin)
Entvars_Get_Vector(id, EV_VEC_v_angle, vAngles)
new notFloat_vOrigin[3]
notFloat_vOrigin[0] = floatround(vOrigin[0])
notFloat_vOrigin[1] = floatround(vOrigin[1])
notFloat_vOrigin[2] = floatround(vOrigin[2])
if(icmd == 5){
new aimvec[3]
get_user_origin(id,aimvec,3)
new dist = get_distance(notFloat_vOrigin,aimvec)
new found
new dist1 = 20000
new players[32], inum
get_players(players,inum,"a")
for(new i = 0 ;i < inum ;++i){
if(players[i] == id) continue
new soutput[8],output
get_user_info(players[i],"JP",soutput,7)
output = str_to_num(soutput)
if(output == 1){
new temp[3]
get_user_origin(players[i],temp)
dist1 = get_distance(temp,aimvec)
if(dist1 < dist){
dist = dist1
found = 1
args[6] = players[i]
}
}
}
if(!found){
client_print(id,print_chat,"[SH](Bazooka) Cannot fire Heat-Seeking Missile, no running JetPacks in view.")
if(get_cvar_num("bazooka_buy") == 1){
new umoney = get_user_money(id)
new m_cost = get_cvar_num("bazooka_cost5")
set_user_money(id,umoney+m_cost,1)
}
else {
missile_inv[id][5] += 1
show_missile_inv(id)
}
if(using_menu[id])
show_main_menu(id)
return PLUGIN_HANDLED
}
}
else if(icmd == 6){
new aimvec[3]
get_user_origin(id,aimvec,3)
new dist = get_distance(notFloat_vOrigin,aimvec)
new found
new dist1 = 20000
new players[32], inum
get_players(players,inum,"a")
for(new i = 0 ;i < inum ;++i){
if(players[i] == id) continue
new soutput[8],output
get_user_info(players[i],"ROPE",soutput,7)
output = str_to_num(soutput)
if(output == 1){
new temp[3]
get_user_origin(players[i],temp)
dist1 = get_distance(temp,aimvec)
if(dist1 < dist){
dist = dist1
found = 1
args[6] = players[i]
}
}
}
if(!found){
client_print(id,print_chat,"[SH](Bazooka) Cannot fire Rope-Seeking Missile, no Ropes in view.")
if(get_cvar_num("bazooka_buy") == 1){
new umoney = get_user_money(id)
new m_cost = get_cvar_num("bazooka_cost6")
set_user_money(id,umoney+m_cost,1)
}
else {
missile_inv[id][6] += 1
show_missile_inv(id)
}
if(using_menu[id])
show_main_menu(id)
return PLUGIN_HANDLED
}
}
using_menu[id] = 0
new NewEnt
NewEnt = CreateEntity("info_target")
if(NewEnt == 0) {
client_print(id,print_chat,"[SH](Bazooka) Rocket Failure")
return PLUGIN_HANDLED
}
has_rocket[id] = NewEnt
missile_inv[id][0] = 0
Entvars_Set_String(NewEnt, EV_SZ_classname, "bazooka_missile_ent")
ENT_SetModel(NewEnt, "models/rpgrocket.mdl")
new Float:fl_vecminsx[3] = {-1.0, -1.0, -1.0}
new Float:fl_vecmaxsx[3] = {1.0, 1.0, 1.0}
Entvars_Set_Vector(NewEnt, EV_VEC_mins,fl_vecminsx)
Entvars_Set_Vector(NewEnt, EV_VEC_maxs,fl_vecmaxsx)
ENT_SetOrigin(NewEnt, vOrigin)
Entvars_Set_Vector(NewEnt, EV_VEC_angles, vAngles)
Entvars_Set_Int(NewEnt, EV_INT_effects, 64)
Entvars_Set_Int(NewEnt, EV_INT_solid, 2)
if(get_cvar_num("bazooka_obeygravity")) {
Entvars_Set_Int(NewEnt, EV_INT_movetype, 6)
}
else {
Entvars_Set_Int(NewEnt, EV_INT_movetype, 5)
}
Entvars_Set_Edict(NewEnt, EV_ENT_owner, id)
Entvars_Set_Float(NewEnt, EV_FL_health, 10000.0)
Entvars_Set_Float(NewEnt, EV_FL_takedamage, 100.0)
Entvars_Set_Float(NewEnt, EV_FL_dmg_take, 100.0)
new Float:fl_iNewVelocity[3]
new iNewVelocity[3]
VelocityByAim(id, iarg1, fl_iNewVelocity)
Entvars_Set_Vector(NewEnt, EV_VEC_velocity, fl_iNewVelocity)
iNewVelocity[0] = floatround(fl_iNewVelocity[0])
iNewVelocity[1] = floatround(fl_iNewVelocity[1])
iNewVelocity[2] = floatround(fl_iNewVelocity[2])
emit_sound(NewEnt, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(NewEnt, CHAN_VOICE, "weapons/rocket1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
args[0] = id
args[1] = NewEnt
args[2] = iarg1
args[3] = iNewVelocity[0]
args[4] = iNewVelocity[1]
args[5] = iNewVelocity[2]
args[8] = notFloat_vOrigin[0]
args[9] = notFloat_vOrigin[1]
args[10] = notFloat_vOrigin[2]
switch(icmd){
case 1: {
make_trail(NewEnt,icmd)
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
set_task(0.1,"guide_rocket_comm",NewEnt,args,16,"b")
set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
}
case 2: {
make_trail(NewEnt,icmd)
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
set_task(0.1,"guide_rocket_las",NewEnt,args,16)
set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
}
case 3: {
make_trail(NewEnt,icmd)
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
Entvars_Set_Int(NewEnt, EV_INT_rendermode,1)
AttachView(id, NewEnt)
args[11] = 1
set_task(0.1,"guide_rocket_dir",NewEnt,args,16,"b")
set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
}
case 4: {
make_trail(NewEnt,icmd)
args[6] = antimissile
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
set_task(0.1,"guide_rocket_anti",NewEnt,args,16)
set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
}
case 5: {
is_heat_rocket[id] = 1
make_trail(NewEnt,icmd)
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
set_task(0.1,"guide_rocket_het",NewEnt,args,16)
set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
}
case 6: {
make_trail(NewEnt,icmd)
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
set_task(0.1,"guide_rocket_rope",NewEnt,args,16)
set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
}
case 7: {
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.000001)
SD_CircleRockets(NewEnt)
set_task(0.1,"guide_rocket_swirl",NewEnt,args,16)
set_task(get_cvar_float("bazooka_sdfuel"),"rocket_fuel_timer",NewEnt,args,16)
}
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
make_trail(NewEnt,style)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(NewEnt)
write_short(beam)
write_byte(45)
write_byte(4)
switch(style){
case 1: {
write_byte(254)
write_byte(254)
write_byte(254)
write_byte(100)
}
case 2: {
write_byte(254)
write_byte(254)
write_byte(100)
write_byte(100)
}
case 3: {
write_byte(100)
write_byte(254)
write_byte(254)
write_byte(100)
}
case 4: {
write_byte(254)
write_byte(150)
write_byte(50)
write_byte(100)
}
case 5: {
write_byte(250)
write_byte(100)
write_byte(100)
write_byte(100)
}
case 6: {
write_byte(100)
write_byte(250)
write_byte(100)
write_byte(100)
}
case 7: {
write_byte(100)
write_byte(100)
write_byte(250)
write_byte(100)
}
default: {
write_byte(254)
write_byte(254)
write_byte(254)
write_byte(100)
}
}
message_end()
}
//----------------------------------------------------------------------------------------------
public guide_rocket_comm(args[])
{
new ent = args[1]
if (!is_valid_ent(ent)) return
new Float:missile_health = Entvars_Get_Float(ent, EV_FL_health)
if(missile_health < 10000.0)
vexd_pfntouch(ent,0)
}
//----------------------------------------------------------------------------------------------
public guide_rocket_dir(args[])
{
new id = args[0]
new ent = args[1]
new speed = args[2]
new Float:fl_iNewVelocity[3]
if (!is_valid_ent(ent)) return
VelocityByAim(id, speed, fl_iNewVelocity)
Entvars_Set_Vector(ent, EV_VEC_velocity, fl_iNewVelocity)
new Float:vAngles[3]
Entvars_Get_Vector(id, EV_VEC_v_angle, vAngles)
Entvars_Set_Vector(ent, EV_VEC_angles, vAngles)
new Float:missile_health = Entvars_Get_Float(ent, EV_FL_health)
if(missile_health <10000.0) {
vexd_pfntouch(ent,0)
}
}
//----------------------------------------------------------------------------------------------
public guide_rocket_las(args[])
{
new aimvec[3],avgFactor
new Float:fl_origin[3]
new id = args[0]
new ent = args[1]
new speed = args[2]
if (!is_valid_ent(ent)) return
get_user_origin(id,aimvec,3)
//Make the Laser Dot
message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
write_byte( 17 )
write_coord(aimvec[0])
write_coord(aimvec[1])
write_coord(aimvec[2])
write_short( ls_dot )
write_byte( 10 )
write_byte( 255 )
message_end()
Entvars_Get_Vector(ent, EV_VEC_origin, fl_origin)
new iNewVelocity[3]
new origin[3]
origin[0] = floatround(fl_origin[0])
origin[1] = floatround(fl_origin[1])
origin[2] = floatround(fl_origin[2])
if(speed < 400)
avgFactor = 10
else if(speed < 850)
avgFactor = 4
else
avgFactor = 2
new velocityvec[3],length
velocityvec[0]=aimvec[0]-origin[0]
velocityvec[1]=aimvec[1]-origin[1]
velocityvec[2]=aimvec[2]-origin[2]
length = sqroot(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
velocityvec[0]=velocityvec[0]*speed/length
velocityvec[1]=velocityvec[1]*speed/length
velocityvec[2]=velocityvec[2]*speed/length
iNewVelocity[0] = (velocityvec[0] + (args[3] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[1] = (velocityvec[1] + (args[4] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[2] = (velocityvec[2] + (args[5] * (avgFactor-1) ) ) / avgFactor
new Float:fl_iNewVelocity[3]
fl_iNewVelocity[0] = iNewVelocity[0] + 0.0
fl_iNewVelocity[1] = iNewVelocity[1] + 0.0
fl_iNewVelocity[2] = iNewVelocity[2] + 0.0
Entvars_Set_Vector(ent, EV_VEC_velocity, fl_iNewVelocity)
args[3] = iNewVelocity[0]
args[4] = iNewVelocity[1]
args[5] = iNewVelocity[2]
args[8] = origin[0]
args[9] = origin[1]
args[10] = origin[2]
set_task(0.1,"guide_rocket_las",ent,args,16)
new Float:missile_health
missile_health = Float:Entvars_Get_Float(ent, EV_FL_health)
if(missile_health < 10000.0) {
vexd_pfntouch(ent,0)
}
}
//----------------------------------------------------------------------------------------------
public guide_rocket_het(args[])
{
new aimvec[3],avgFactor
new Float:fl_origin[3]
new t_aimvec[33][3]
new t_index[33]
new t_jp,dist
new jp_dist = 20000
new id = args[0]
new ent = args[1]
new speed = args[2]
new iNewVelocity[3]
if (!is_valid_ent(ent)) return
Entvars_Get_Vector(ent, EV_VEC_origin, fl_origin)
new origin[3]
origin[0] = floatround(fl_origin[0])
origin[1] = floatround(fl_origin[1])
origin[2] = floatround(fl_origin[2])
new soutput[8],output
get_user_info(args[6],"JP",soutput,7)
output = str_to_num(soutput)
if((output == 1) || (args[7] < 5)){
if(is_user_alive(args[6]) == 1){
get_user_origin(args[6],aimvec)
dist = get_distance(aimvec,origin)
}
else {
args[7] = 100
}
if(output == 1)
args[7] = 0
}
else {
new players[32], inum
get_players(players,inum,"a")
for(new i = 0 ;i < inum ;++i){
if(players[i] != id){
setc(soutput,8,0)
get_user_info(players[i],"JP",soutput,7)
output = str_to_num(soutput)
if(output){
new temp[3]
get_user_origin(players[i],temp)
t_aimvec[t_jp][0] = temp[0]
t_aimvec[t_jp][1] = temp[1]
t_aimvec[t_jp][2] = temp[2]
t_index[t_jp] = players[i]
t_jp++
}
}
}
for(new i = 0 ;i < t_jp ;++i){
new temp[3]
temp[0] = t_aimvec[i][0]
temp[1] = t_aimvec[i][1]
temp[2] = t_aimvec[i][2]
dist = get_distance(temp,origin)
if(dist < jp_dist){
aimvec[0] = temp[0]
aimvec[1] = temp[1]
aimvec[2] = temp[2]
jp_dist = dist
args[6] = t_index[i]
args[7] = 0
}
}
}
if(dist){
if(speed < 400)
avgFactor = 10
else if(speed < 850)
avgFactor = 4
else
avgFactor = 2
new length, velocityvec[3]
velocityvec[0]=aimvec[0]-origin[0]
velocityvec[1]=aimvec[1]-origin[1]
velocityvec[2]=aimvec[2]-origin[2]
length=sqroot(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
velocityvec[0]=velocityvec[0]*speed/length
velocityvec[1]=velocityvec[1]*speed/length
velocityvec[2]=velocityvec[2]*speed/length
iNewVelocity[0] = (velocityvec[0] + (args[3] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[1] = (velocityvec[1] + (args[4] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[2] = (velocityvec[2] + (args[5] * (avgFactor-1) ) ) / avgFactor
args[3] = iNewVelocity[0]
args[4] = iNewVelocity[1]
args[5] = iNewVelocity[2]
if(dist < 20){
vexd_pfntouch(ent,0)
return
}
}
args[7] += 1
new Float:fl_iNewVelocity[3]
fl_iNewVelocity[0] = args[3] +0.0
fl_iNewVelocity[1] = args[4] +0.0
fl_iNewVelocity[2] = args[5] +0.0
Entvars_Set_Vector(ent, EV_VEC_velocity, fl_iNewVelocity)
set_task(0.1,"guide_rocket_het",ent,args,16)
new Float:missile_health
missile_health = Float:Entvars_Get_Float(ent, EV_FL_health)
if(missile_health < 10000.0) {
vexd_pfntouch(ent,0)
}
}
//----------------------------------------------------------------------------------------------
public guide_rocket_anti(args[])
{
new Float:fl_aimvec[3]
new Float:fl_origin[3]
new avgFactor
new id = args[0]
new ent = args[1]
new speed = args[2]
new iNewVelocity[3]
if (!is_valid_ent(ent)) return
Entvars_Get_Vector(ent, EV_VEC_origin, fl_origin)
new origin[3]
origin[0] = floatround(fl_origin[0])
origin[1] = floatround(fl_origin[1])
origin[2] = floatround(fl_origin[2])
if(FindEntity(args[6], "bazooka_missile_ent") > 0){
Entvars_Get_Vector(args[6], EV_VEC_origin, fl_aimvec)
new aimvec[3]
aimvec[0] = floatround(fl_aimvec[0])
aimvec[1] = floatround(fl_aimvec[1])
aimvec[2] = floatround(fl_aimvec[2])
if(speed < 400)
avgFactor = 10
else if(speed < 850)
avgFactor = 4
else
avgFactor = 2
new length, velocityvec[3]
velocityvec[0]=aimvec[0]-origin[0]
velocityvec[1]=aimvec[1]-origin[1]
velocityvec[2]=aimvec[2]-origin[2]
length=sqroot(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
velocityvec[0]=velocityvec[0]*speed/length
velocityvec[1]=velocityvec[1]*speed/length
velocityvec[2]=velocityvec[2]*speed/length
iNewVelocity[0] = (velocityvec[0] + (args[3] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[1] = (velocityvec[1] + (args[4] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[2] = (velocityvec[2] + (args[5] * (avgFactor-1) ) ) / avgFactor
args[3] = iNewVelocity[0]
args[4] = iNewVelocity[1]
args[5] = iNewVelocity[2]
if(get_distance(origin,aimvec) < 150){
vexd_pfntouch(ent,args[6])
return
}
new Float:fl_iNewVelocity[3]
fl_iNewVelocity[0] = args[3] +0.0
fl_iNewVelocity[1] = args[4] +0.0
fl_iNewVelocity[2] = args[5] +0.0
Entvars_Set_Vector(ent, EV_VEC_velocity, fl_iNewVelocity)
set_task(0.1,"guide_rocket_anti",ent,args,16)
}
new Float:missile_health = Entvars_Get_Float(ent, EV_FL_health)
if(missile_health < 10000.0) {
vexd_pfntouch(ent,0)
}
client_cmd(id,"spk buttons/blip2")
}
//----------------------------------------------------------------------------------------------
public guide_rocket_rope(args[])
{
new aimvec[3],avgFactor
new Float:fl_origin[3]
new t_aimvec[33][3]
new t_index[33]
new t_jp,dist
new jp_dist = 20000
new id = args[0]
new ent = args[1]
new speed = args[2]
new iNewVelocity[3]
if (!is_valid_ent(ent)) return
Entvars_Get_Vector(ent, EV_VEC_origin, fl_origin)
new origin[3]
origin[0] = floatround(fl_origin[0])
origin[1] = floatround(fl_origin[1])
origin[2] = floatround(fl_origin[2])
new soutput[8],output
get_user_info(args[6],"ROPE",soutput,7)
output = str_to_num(soutput)
if((output == 1) || (args[7] < 31)){
if(is_user_alive(args[6]) == 1){
get_user_origin(args[6],aimvec)
dist = get_distance(aimvec,origin)
}
else {
args[7] = 100
}
if(output == 1)
args[7] = 0
}
else {
new players[32], inum
get_players(players,inum,"a")
for(new i = 0 ;i < inum ;++i){
if(players[i] != id){
setc(soutput,8,0)
get_user_info(players[i],"ROPE",soutput,7)
output = str_to_num(soutput)
if(output){
new temp[3]
get_user_origin(players[i],temp)
t_aimvec[t_jp][0] = temp[0]
t_aimvec[t_jp][1] = temp[1]
t_aimvec[t_jp][2] = temp[2]
t_index[t_jp] = players[i]
t_jp++
}
}
}
for(new i = 0 ;i < t_jp ;++i){
new temp[3]
temp[0] = t_aimvec[i][0]
temp[1] = t_aimvec[i][1]
temp[2] = t_aimvec[i][2]
dist = get_distance(temp,origin)
if(dist < jp_dist){
aimvec[0] = temp[0]
aimvec[1] = temp[1]
aimvec[2] = temp[2]
jp_dist = dist
args[6] = t_index[i]
args[7] = 0
}
}
}
if(dist){
if(speed < 400)
avgFactor = 10
else if(speed < 850)
avgFactor = 4
else
avgFactor = 2
new length, velocityvec[3]
velocityvec[0]=aimvec[0]-origin[0]
velocityvec[1]=aimvec[1]-origin[1]
velocityvec[2]=aimvec[2]-origin[2]
length=sqroot(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
velocityvec[0]=velocityvec[0]*speed/length
velocityvec[1]=velocityvec[1]*speed/length
velocityvec[2]=velocityvec[2]*speed/length
iNewVelocity[0] = (velocityvec[0] + (args[3] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[1] = (velocityvec[1] + (args[4] * (avgFactor-1) ) ) / avgFactor
iNewVelocity[2] = (velocityvec[2] + (args[5] * (avgFactor-1) ) ) / avgFactor
args[3] = iNewVelocity[0]
args[4] = iNewVelocity[1]
args[5] = iNewVelocity[2]
if(dist < 60){
vexd_pfntouch(ent,0)
return
}
}
args[7] += 1
new Float:fl_iNewVelocity[3]
fl_iNewVelocity[0] = args[3] +0.0
fl_iNewVelocity[1] = args[4] +0.0
fl_iNewVelocity[2] = args[5] +0.0
Entvars_Set_Vector(ent, EV_VEC_velocity, fl_iNewVelocity)
set_task(0.1,"guide_rocket_rope",ent,args,16)
new Float:missile_health
missile_health = Float:Entvars_Get_Float(ent, EV_FL_health)
if(missile_health <10000.0) {
vexd_pfntouch(ent,0)
}
}
//----------------------------------------------------------------------------------------------
public guide_rocket_swirl(args[]){
new ent = args[1]
if (!is_valid_ent(ent)) return
set_task(0.1,"guide_rocket_swirl",ent,args,16)
new Float:missile_health = Entvars_Get_Float(ent, EV_FL_health)
if(missile_health <10000.0) {
vexd_pfntouch(ent,0)
}
}
//----------------------------------------------------------------------------------------------
public rocket_fuel_timer(args[]){
new ent = args[1]
new id = args[0]
remove_task(ent)
if (!is_valid_ent(ent)) return
Entvars_Set_Int(ent, EV_INT_effects, 2)
Entvars_Set_Int(ent, EV_INT_rendermode,0)
Entvars_Set_Float(ent, EV_FL_gravity, 1.0)
Entvars_Set_Int(ent, EV_INT_iuser1, 0)
emit_sound(ent, CHAN_WEAPON, "debris/beamstart8.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
emit_sound(ent, CHAN_VOICE, "ambience/rocket_steam1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
if(args[11] == 1){
set_hudmessage(250,10,10,-1.0,0.45, 0, 0.0, 1.5, 0.5, 0.15, 54)
show_hudmessage(id,"WARNING: FUEL TANK EMPTY^nCONTROLS DISENGAGED")
}
set_task(0.1,"guide_rocket_comm",ent,args,16,"b")
}
//----------------------------------------------------------------------------------------------
public laser_check() {
new arg[32]
read_argv(1,arg,31)
new iarg = str_to_num(arg)
if(is_valid_ent(iarg)) {
new szClassName[32]
Entvars_Get_String(iarg, EV_SZ_classname, szClassName, 31)
if(equal(szClassName, "bazooka_missile_ent")) {
vexd_pfntouch(iarg,0)
}
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
show_missile_inv(id){
if(get_cvar_num("bazooka_buy") == 0){
new Message[350]
new len = 349
new n = 0
new sum
for(new i=1;i<8;i++)
sum += missile_inv[id][i]
set_hudmessage(255, 10, 10, 0.80, 0.60, 0, 0.02, 6.0, 1.01, 1.1, 55)
n += format( Message[n],len-n,"Common Missile ( %d )^n",missile_inv[id][1])
n += format( Message[n],len-n,"Laser Guided Missile ( %d )^n",missile_inv[id][2])
n += format( Message[n],len-n,"Gun Camera Missile ( %d )^n",missile_inv[id][3])
n += format( Message[n],len-n,"Anti-Missile Shots ( %d )^n",missile_inv[id][4])
n += format( Message[n],len-n,"Heat-Seeking Missile ( %d )^n",missile_inv[id][5])
n += format( Message[n],len-n,"Rope-Seeking Missile ( %d )^n",missile_inv[id][6])
if(get_cvar_num("bazooka_ammo7ta")) {
new sdcount = sum / 7
n += format( Message[n],len-n,"Swirling Death Missile ( %d )",sdcount)
}
else
n += format( Message[n],len-n,"Swirling Death Missile ( %d )",missile_inv[id][7])
show_hudmessage(id,Message)
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public show_main_menu(id) {
new menu_body[320]
new n = 0
new len = 319
if(!gHasBazookaPowers[id] || !is_user_alive(id))
return PLUGIN_HANDLED
n += format( menu_body[n],len-n,"\yFire Missile Menu^n\w^n")
if(get_cvar_num("bazooka_buy") == 1 ){
n += format( menu_body[n],len-n,"1. Common Missile - $%d^n",get_cvar_num("bazooka_cost1"))
n += format( menu_body[n],len-n,"2. Laser Guided Missile - $%d^n",get_cvar_num("bazooka_cost2"))
n += format( menu_body[n],len-n,"3. Gun Camera Missile - $%d^n",get_cvar_num("bazooka_cost3"))
n += format( menu_body[n],len-n,"4. Anti-Missile Shots - $%d^n",get_cvar_num("bazooka_cost4"))
n += format( menu_body[n],len-n,"5. Heat-Seeking Missile - $%d^n",get_cvar_num("bazooka_cost5"))
n += format( menu_body[n],len-n,"6. Rope-Seeking Missile - $%d^n",get_cvar_num("bazooka_cost6"))
n += format( menu_body[n],len-n,"7. Swirling Death Missile - $%d^n",get_cvar_num("bazooka_cost7"))
}
else {
new sum
for(new i=1;i<8;i++)
sum += missile_inv[id][i]
n += format( menu_body[n],len-n,"1. Common Missile ( %d )^n",missile_inv[id][1])
n += format( menu_body[n],len-n,"2. Laser Guided Missile ( %d )^n",missile_inv[id][2])
n += format( menu_body[n],len-n,"3. Gun Camera Missile ( %d )^n",missile_inv[id][3])
n += format( menu_body[n],len-n,"4. Anti-Missile Shots ( %d )^n",missile_inv[id][4])
n += format( menu_body[n],len-n,"5. Heat-Seeking Missile ( %d )^n",missile_inv[id][5])
n += format( menu_body[n],len-n,"6. Rope-Seeking Missile ( %d )^n",missile_inv[id][6])
if(get_cvar_num("bazooka_ammo7ta")) {
new sdcount = sum / 7
n += format( menu_body[n],len-n,"7. Swirling Death Missile ( %d )^n",sdcount)
}
else
n += format( menu_body[n],len-n,"7. Swirling Death Missile ( %d )^n",missile_inv[id][7])
}
n += format( menu_body[n],len-n,"0. Exit")
new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<9)
show_menu(id,keys,menu_body)
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public action_main_menu(id,key){
using_menu[id] = 1
key++
if(!gHasBazookaPowers[id] || !is_user_alive(id)) {
using_menu[id] = 0
return PLUGIN_HANDLED
}
if (roundfreeze && key != 10) {
show_main_menu(id)
return PLUGIN_HANDLED
}
switch(key){
case 1: client_cmd(id,"bazooka_missile")
case 2: client_cmd(id,"bazooka_laserguided_missile")
case 3: client_cmd(id,"bazooka_guncamera_missile")
case 4: client_cmd(id,"bazooka_anti_missile")
case 5: client_cmd(id,"bazooka_heatseeking_missile")
case 6: client_cmd(id,"bazooka_ropeseeking_missile")
case 7: client_cmd(id,"bazooka_swirlingdeath_missile")
case 10: using_menu[id] = 0
default: show_main_menu(id)
}
if (key >= 1 && key <= 7) {
if(get_cvar_num("bazooka_buy")){
new costcvar[32]
format(costcvar,31,"bazooka_cost%d",key)
if(get_user_money(id) < get_cvar_num(costcvar))
show_main_menu(id)
}
else {
if(key == 7 && !get_cvar_num("bazooka_ammo7ta") && missile_inv[id][key] <= 0)
show_main_menu(id)
else if(missile_inv[id][key] <= 0)
show_main_menu(id)
}
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public death_event(){
new victim
victim = read_data(2)
remove_task(victim)
is_scan_rocket[victim] = 0
using_menu[victim] = 0
}
//----------------------------------------------------------------------------------------------
public round_end(){
roundfreeze = true
for (new i=1; i <= get_maxplayers(); i++) {
if(is_user_connected(i)) {
if( !is_user_alive(i) && get_cvar_num("bazooka_buy") ){
missile_inv[i][1] = 0
missile_inv[i][2] = 0
missile_inv[i][3] = 0
missile_inv[i][4] = 0
missile_inv[i][5] = 0
missile_inv[i][6] = 0
missile_inv[i][7] = 0
}
}
if(has_rocket[i] > 0)
remove_missile(i,has_rocket[i])
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public round_start(){
roundfreeze = false
if (get_cvar_num("bazooka_spawndelay") && !round_delay) {
round_delay = 1
set_task(15.0,"roundstart_delay")
}
for (new i = 1; i <= get_maxplayers(); i++) {
radar_batt[i] = get_cvar_num("bazooka_radarbattery")
if(!get_cvar_num("bazooka_buy")){
missile_inv[i][1] = get_cvar_num("bazooka_ammo1")
missile_inv[i][2] = get_cvar_num("bazooka_ammo2")
missile_inv[i][3] = get_cvar_num("bazooka_ammo3")
missile_inv[i][4] = get_cvar_num("bazooka_ammo4")
missile_inv[i][5] = get_cvar_num("bazooka_ammo5")
missile_inv[i][6] = get_cvar_num("bazooka_ammo6")
missile_inv[i][7] = get_cvar_num("bazooka_ammo7")
}
}
new iCurrent
while ((iCurrent = FindEntity(-1, "bazooka_missile_ent")) > 0) {
new id = Entvars_Get_Edict(iCurrent, EV_ENT_owner)
remove_missile(id,iCurrent)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public roundstart_delay(){
round_delay = 0
}
//----------------------------------------------------------------------------------------------
remove_missile(id,missile){
new Float:fl_origin[3]
Entvars_Get_Vector(missile, EV_VEC_origin, fl_origin)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(14)
write_coord(floatround(fl_origin[0]))
write_coord(floatround(fl_origin[1]))
write_coord(floatround(fl_origin[2]))
write_byte (200)
write_byte (40)
write_byte (45)
message_end()
emit_sound(missile, CHAN_WEAPON, "ambience/particle_suck2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(missile, CHAN_VOICE, "ambience/particle_suck2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
has_rocket[id] = 0
is_heat_rocket[id] = 0
is_scan_rocket[id] = 0
remove_task(missile)
AttachView(id,id)
RemoveEntity(missile)
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public SD_CircleRockets(Ent){
new NUMBER_OF_ROCKETS = get_cvar_num("bazooka_sdcount")
new Float:ROCKET_RADIUS = get_cvar_float("bazooka_sdradius")
new Float:vOrigin[3]
new Float:vVelocity[3]
new Float:vEntOrig[3]
new Float:RotMatrix[3][3]
new Float:x, Float:y, Float:z, Float:theta
new i, id, NewEnt
if (!is_valid_ent(Ent)) return
Entvars_Get_Vector(Ent, EV_VEC_origin, vOrigin)
Entvars_Get_Vector(Ent, EV_VEC_velocity, vVelocity)
id = Entvars_Get_Edict(Ent, EV_ENT_owner)
RotMatrix[0][0]=vVelocity[0]
RotMatrix[0][1]=vVelocity[1]
RotMatrix[0][2]=vVelocity[2]
RotMatrix[1][0]=-vVelocity[1]
RotMatrix[1][1]=vVelocity[0]
RotMatrix[1][2]=0.0
SD_Normalise(RotMatrix[0])
SD_Normalise(RotMatrix[1])
RotMatrix[2][0]=((RotMatrix[0][1])*(RotMatrix[1][2]))-((RotMatrix[0][2])*(RotMatrix[1][1]))
RotMatrix[2][1]=((RotMatrix[0][2])*(RotMatrix[1][0]))-((RotMatrix[0][0])*(RotMatrix[1][2]))
RotMatrix[2][2]=((RotMatrix[0][0])*(RotMatrix[1][1]))-((RotMatrix[0][1])*(RotMatrix[1][0]))
for (i=0; i < NUMBER_OF_ROCKETS; i++){
theta = (float(i)/float(NUMBER_OF_ROCKETS))*2*PI+fAngleBaz
x = 0.0
#if !defined AMX98
y = floatcos(theta)*ROCKET_RADIUS
z = floatsin(theta)*ROCKET_RADIUS
#else
y = cos(theta)*ROCKET_RADIUS
z = sin(theta)*ROCKET_RADIUS
#endif
vEntOrig[0]=RotMatrix[0][0]*x+RotMatrix[1][0]*y+RotMatrix[2][0]*z
vEntOrig[1]=RotMatrix[0][1]*x+RotMatrix[1][1]*y+RotMatrix[2][1]*z
vEntOrig[2]=RotMatrix[0][2]*x+RotMatrix[1][2]*y+RotMatrix[2][2]*z
vEntOrig[0]+=vOrigin[0]
vEntOrig[1]+=vOrigin[1]
vEntOrig[2]+=vOrigin[2]
NewEnt = SD_CreateRocket(vEntOrig, vVelocity, id)
Entvars_Set_Int(NewEnt, EV_INT_iuser1, Ent)
Entvars_Set_Int(NewEnt, EV_INT_iuser2, i)
}
}
//----------------------------------------------------------------------------------------------
public SD_CreateRocket(Float:vOrigin[3], Float:vVelocity[3], id)
{
new Float:vAngles[3]
VecToAngles(vVelocity, vAngles)
new NewEnt = CreateEntity("info_target")
if(!NewEnt) return PLUGIN_CONTINUE
Entvars_Set_String(NewEnt, EV_SZ_classname, "bazooka_missile_ent")
ENT_SetModel(NewEnt, "models/rpgrocket.mdl")
new Float:fl_vecminsx[3] = {-1.0, -1.0, -1.0}
new Float:fl_vecmaxsx[3] = {1.0, 1.0, 1.0}
Entvars_Set_Vector(NewEnt, EV_VEC_mins, fl_vecminsx)
Entvars_Set_Vector(NewEnt, EV_VEC_maxs, fl_vecmaxsx)
ENT_SetOrigin(NewEnt, vOrigin)
Entvars_Set_Vector(NewEnt, EV_VEC_angles, vAngles)
Entvars_Set_Int(NewEnt, EV_INT_solid, 2)
Entvars_Set_Int(NewEnt, EV_INT_movetype, 6)
Entvars_Set_Edict(NewEnt, EV_ENT_owner, id)
Entvars_Set_Float(NewEnt, EV_FL_health, 10000.0)
Entvars_Set_Float(NewEnt, EV_FL_takedamage, 100.0)
Entvars_Set_Float(NewEnt, EV_FL_dmg_take, 100.0)
Entvars_Set_Vector(NewEnt, EV_VEC_velocity, vVelocity)
make_trail(NewEnt,7) // 7 = Swirling Missiles
Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.000001 )
emit_sound(NewEnt, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(NewEnt, CHAN_VOICE, "weapons/rocket1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
new args[16]
args[0] = id
args[1] = NewEnt
args[2] = get_cvar_num("bazooka_sdspeed")
args[3] = floatround(vVelocity[0])
args[4] = floatround(vVelocity[1])
args[5] = floatround(vVelocity[2])
set_task(get_cvar_float("bazooka_sdfuel"),"rocket_fuel_timer",NewEnt,args,16)
return NewEnt
}
//----------------------------------------------------------------------------------------------
public SD_Normalise(Float:Vector[3]){
new Float:NullVector[3] = {0.0,0.0,0.0}
new Float:fLength = VecDist(Vector, NullVector)
Vector[0] /= fLength
Vector[1] /= fLength
Vector[2] /= fLength
}
//----------------------------------------------------------------------------------------------
public RocketThink() {
new NUMBER_OF_ROCKETS = get_cvar_num("bazooka_sdcount")
new ANGULAR_VELOCITY = get_cvar_num("bazooka_sdrotate")
new Float:ROCKET_RADIUS = get_cvar_float("bazooka_sdradius")
new iCurrent, iCenterRocket, i
new Float:vOrigin[3], Float:vVelocity[3]
new Float:RotMatrix[3][3]
new Float:vEntOrig[3], Float:vOldEntOrig[3]
new Float:x, Float:y, Float:z, Float:theta
new Float:vAngles[3], Float:fNewVelocity[3]
new iTempEnt
fAngleBaz += ANGULAR_VELOCITY * DT
if (fAngleBaz > 2*PI)
fAngleBaz -= 2*PI
iCurrent = -1
while ((iCurrent = FindEntity(iCurrent, "bazooka_missile_ent")) > 0){
iCenterRocket = Entvars_Get_Int(iCurrent, EV_INT_iuser1)
if (iCenterRocket){
iTempEnt = -1
while ((iTempEnt = FindEntity(iTempEnt, "bazooka_missile_ent")) > 0){
if (iTempEnt == iCenterRocket) break
}
if (iTempEnt > 0){
Entvars_Get_Vector(iCenterRocket, EV_VEC_origin, vOrigin)
Entvars_Get_Vector(iCenterRocket, EV_VEC_velocity, vVelocity)
Entvars_Get_Vector(iCurrent, EV_VEC_origin, vOldEntOrig)
i = Entvars_Get_Int(iCurrent, EV_INT_iuser2)
RotMatrix[0][0]=vVelocity[0]
RotMatrix[0][1]=vVelocity[1]
RotMatrix[0][2]=vVelocity[2]
RotMatrix[1][0]=-vVelocity[1]
RotMatrix[1][1]=vVelocity[0]
RotMatrix[1][2]=0.0
SD_Normalise(RotMatrix[0])
SD_Normalise(RotMatrix[1])
RotMatrix[2][0]=((RotMatrix[0][1])*(RotMatrix[1][2]))-((RotMatrix[0][2])*(RotMatrix[1][1]))
RotMatrix[2][1]=((RotMatrix[0][2])*(RotMatrix[1][0]))-((RotMatrix[0][0])*(RotMatrix[1][2]))
RotMatrix[2][2]=((RotMatrix[0][0])*(RotMatrix[1][1]))-((RotMatrix[0][1])*(RotMatrix[1][0]))
theta = (float(i)/float(NUMBER_OF_ROCKETS))*2*PI+fAngleBaz
x = 0.0
#if !defined AMX98
y = floatcos(theta)*ROCKET_RADIUS
z = floatsin(theta)*ROCKET_RADIUS
#else
y = cos(theta)*ROCKET_RADIUS
z = sin(theta)*ROCKET_RADIUS
#endif
vEntOrig[0]=RotMatrix[0][0]*x+RotMatrix[1][0]*y+RotMatrix[2][0]*z
vEntOrig[1]=RotMatrix[0][1]*x+RotMatrix[1][1]*y+RotMatrix[2][1]*z
vEntOrig[2]=RotMatrix[0][2]*x+RotMatrix[1][2]*y+RotMatrix[2][2]*z
vEntOrig[0]+=vOrigin[0]
vEntOrig[1]+=vOrigin[1]
vEntOrig[2]+=vOrigin[2]
vEntOrig[0]+=vVelocity[0]*DT
vEntOrig[1]+=vVelocity[1]*DT
vEntOrig[2]+=vVelocity[2]*DT
CalculateVelocity(vOldEntOrig, vEntOrig, fNewVelocity)
Entvars_Set_Vector(iCurrent, EV_VEC_velocity, fNewVelocity)
VecToAngles(fNewVelocity, vAngles)
Entvars_Set_Vector(iCurrent, EV_VEC_angles, vAngles)
new Float:missile_health = Entvars_Get_Float(iCurrent, EV_FL_health)
if(missile_health < 10000.0)
vexd_pfntouch(iCurrent,0)
}
else {
Entvars_Set_Int(iCurrent, EV_INT_iuser1, 0)
}
}
}
}
//----------------------------------------------------------------------------------------------
public CalculateVelocity(Float:vOrigin[3], Float:vEnd[3], Float:vVelocity[3]){
vVelocity[0] = (vEnd[0] - vOrigin[0]) / DT
vVelocity[1] = (vEnd[1] - vOrigin[1]) / DT
vVelocity[2] = (vEnd[2] - vOrigin[2]) / DT
}
//----------------------------------------------------------------------------------------------
Last edited by yango; 09-02-2012 at 18:09.
|
|