Senior Member
Join Date: Jul 2010
Location: Brasil
|
08-12-2010
, 19:06
Re: Bazooka
|
#61
|
WOOWW, got it! I'm so happy, even if it was just tidying up the bazooka, and I just edited it for my need, I'm happy!
Then post the code completely ready, and clean!
PHP Code:
//Bazooka
//Based on Missiles Launcher 3.8.2 (amx_ejl_missiles.sma) // by Eric Lidman & jtp10181
/* CVARS - copy and paste to shconfig.cfg
// ---START OF BAZOOKA CVARS---
//Bazooka bazooka_level 8 bazooka_buy 0 //Set to 1 to require missiles to be purchased
// //The following "COST" settings only apply if buying mode is ON //
bazooka_cost1 1000 //Common missile cost bazooka_cost2 3000 //Laser guided missile cost bazooka_cost3 3000 //Gun camera missile cost bazooka_cost4 2000 //Anti-missile shot bazooka_cost5 4000 //Heat seeking missile cost bazooka_cost6 4000 //Rope seeking missile cost bazooka_cost7 5000 //Swirling death missile cost
// //The following "AMMO" settings only apply if buying mode is OFF //
bazooka_ammo1 1 //Free Common missiles bazooka_ammo2 1 //Free Laser guided missiles bazooka_ammo3 1 //Free Gun camera missiles bazooka_ammo4 2 //Free Anti-missile shots bazooka_ammo5 1 //Free Heat seeking missiles bazooka_ammo6 1 //Free Rope seeking missiles bazooka_ammo7 1 //Free Swirling death missiles
//If set to 1, this cvar causes swirling death missile to use 7 missiles in the //player's missile inventory. It draws from all types of missiles instead of //it having its own indepedent inventory count. bazooka_ammo7ta 0
bazooka_speed 1000 //Sets the default speed of most missiles bazooka_rsspeed 1400 //Sets the speed of ropeseeking missiles bazooka_hsspeed 1100 //Sets the speed of heatseeking missiles bazooka_fuel 6.0 //Number of seconds a missile is driven before it falls to the ground out of fuel bazooka_sdfuel 2.0 //Number of seconds a swirling death missile is driven before it "mirvs" or breaks then falls to the ground out of fuel bazooka_sdspeed 750 //Sets the speed of swirling death missiles bazooka_sdcount 6 //Sets the number missiles in swirling death bazooka_sdrotate 6 //Sets the rotation speed of swirling death bazooka_sdradius 32 //Sets the radius of swirling death missiles bazooka_obeygravity 1 //Makes missile obey server gravity rules bazooka_damradius 240 //Max distance from the blast that damage will occur at bazooka_maxdamage 140 //Maximum Blast damage from explosion bazooka_radarbattery 100 //Sets the amount of time a player can use his anti-missile radar per round.
//This cvar limits the two types of missiles responsible for spawn rape, guncamera and //swirling death, from being fired until 15 seconds of a round has passed. Set cvar to 0 //to allow those missiles to be fired without being limited by round start bazooka_spawndelay 0
// ---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
client_cmd(id,"bazooka_missile")
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 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.") } 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) 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 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 } //---------------------------------------------------------------------------------------------- public 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 } //---------------------------------------------------------------------------------------------- /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par } */
__________________
|
|