Senior Member
Join Date: Mar 2013
Location: Argentina
|
04-21-2013
, 15:44
[Solucionado] Bazoka no mata al team contrario.
|
#1
|
Hola, he buscado en todos los temas para ver si habia alguna solucion y nada. El plugins anda perfecto pero no mata al team contrario, pero eso si te mata a vos mismo :/
Alguno sabe como arreglarlo por favor? es para un sv comun.
Muchas gracias de ante mano.
Code:
/* AMX Mod X script
:: Bazooka ::
Commands:
amx_bazooka | spawn a bazooka in front of you (works in spectator mode too, admin only)
amx_bazooka_give <@all or name/id> <amount> | give someone a bazooka (admin only)
amx_bazooka_startarena <mode restrictions> <round restart 1|0> | start the bazooka arena (admin only)
amx_bazooka_endarena <set ammo> | specify new ammo for everyone and end bazooka arena (set to -1 to leave everyone's ammo alone, admin only)
Say buybazooka in chat to open a buy menu. (everyone)
Say bazookahelp in chat to open the help file. (everyone)
Cvars:
amx_bazooka_dropping :: can a player drop his bazooka?? (default: 1)
amx_bazooka_ammo :: how much ammo has the bazooka?? (default: 3)
amx_bazooka_arena :: If set to 1 every player will recieve a bazooka with unlimited ammo
at the start of the next round. While this mode is activated it requires
a direct hit to kill someone. It is also advisable to restrict the other modes.
amx_bazooka_cost :: how much does the bazooka cost to buy it? (default: 8000)
amx_bazooka_buyable :: is it possible to buy the bazooka? (default: 1)
amx_bazooka_damageradius :: How big the damage radius is (default: 250)
amx_bazooka_maxdamage :: when you are in the center, how much HP do you lose? (default: 150)
amx_bazooka_restrict :: resrict certain modes: a = Normal, b = Heat-Seeking, c = User-Guided, d = No restrictions
amx_bazooka_reloadtime :: how much time (in seconds) it takes to reload the bazooka (default: 2.5)
amx_bazooka_trailtime :: How long the bazooka trails stay in the air (best at 30)
amx_bazooka_velocity :: This only affects how fast the heat-seeking and normal rockets go (best at 700)
amx_bazooka_teamcolors :: set to 1 to use team colors (CT = blue, T = red) or set to 2 to have random colors
amx_bazooka_gib :: set to 1 to cause gib explosion if the damage is > 100 and also enough to kill the person
Special thanks to:
-=STN=- MaGe
KaOs
RadidEskimo
Freecode
EJL
JTP10181
PaintLancer
Kaddar
Vexd
twistedeuphoria
XxAvalanchexX
pimp daddy
Ronkkrop
More for making the original bazooka plugin
mike_cao for his awesome gore plugin
BAILOPAN
Notes:
1. From what i've tested on my server people seem to like team colors better than random colors.
2. I've bound some keys to bazooka arena like so:
bind "PGDN" "amx_bazooka_arena 0;amx_bazooka_maxdamage 150;amx_bazooka_damageradius 250;amx_bazooka_restrict 1;sv_gravity 800;amx_say Bazooka Arena OFF"
bind "PGUP" "amx_bazooka_arena 1;amx_bazooka_maxdamage 999999;amx_bazooka_damageradius 40;amx_bazooka_restrict 1;sv_gravity 150;amx_bazooka_give @all 1;amx_say Bazooka Arena ON;amx_say say 'bazookahelp' for more information on Bazookas"
3. When you have Bazooka arena enabled it's fun to change the reload times.
Skill mode: reloadtime is 2.5
Rapid Fire mode: reloadtime is 0
This has gotten good feedback on my test server.
4. people are intrigued by a bazooka in CS 1.6, advertise this in your server name.
*/
// Set this value to 1 if you are using Condition Zero
// I have NOT tested this plugin with CZ so I do not know if it will work
//this switch was part of Mike Cao's Gore plugin
//I believe it makes sure that the correct sprite indexes are used
#define CZERO 0
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <cstrike>
#include <amxmisc>
#include <entity_maths> //this has the function for the "heat-seeking" rockets
#define TE_EXPLOSION 3
#define TE_EXPLFLAG_NONE 0
#define TE_SMOKE 5
#define TE_BLOODSPRITE 115
#define TE_BLOODSTREAM 101
#define TE_MODEL 106
#define TE_WORLDDECAL 116
#define BA_NORMAL (1<<0) // "a"
#define BA_HEAT (1<<1) // "b"
#define BA_USER (1<<2) // "c"
#define SEQ_IDLE 0
#define SEQ_FIDGET 1
#define SEQ_RELOAD 2
#define SEQ_FIRE 3
#define BAZOOKA_MENUKEYS (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
new g_sModelIndexFireball, g_sModelIndexSmoke, rocketsmoke
new bool:CanShoot[32], Munni[32], mode[32], bool:allow_shooting, user_controll[32], bool:hasBazooka[32]
new mdl_gib_flesh, mdl_gib_head, mdl_gib_legbone, mdl_gib_lung, mdl_gib_meat, mdl_gib_spine, spr_blood_drop, spr_blood_spray
new gHealthIndex[33], bool:cantplantbomb, bool:cantswitch, iFlags, modetext[32]
new hand[33],newhand[33],bazookamenu,seq_animation[32]
public plugin_init() {
register_plugin("BazookaAdvanced", "1.3c", "Major Victory")
register_concmd("amx_bazooka", "drop_rpg", ADMIN_LEVEL_A)
register_concmd("amx_bazooka_give", "cmdBazooka_give", ADMIN_LEVEL_A, "<@all or name/id> <amount>")
register_concmd("amx_bazooka_startarena", "cmdBazooka_StartArena", ADMIN_LEVEL_A, "<mode restrictions> <restart time, 0 = no restart>")
register_concmd("amx_bazooka_endarena", "cmdBazooka_EndArena", ADMIN_LEVEL_A, "<set ammo>")
register_cvar("amx_bazooka_dropping", "1")// can a player drop a bazooka
register_cvar("amx_bazooka_ammo", "1")// how much ammo per bazooka
register_cvar("amx_bazooka_damageradius", "250") //NOTE: damagradius is not affected by walls
register_cvar("amx_bazooka_maxdamage", "150")
register_cvar("amx_bazooka_cost", "2500")// how much one bazooka costs
register_cvar("amx_bazooka_arena", "0")// requires direct hit to kill
register_cvar("amx_bazooka_buyable", "1")//disables/enables the buy menu
register_cvar("amx_bazooka_restrict", "bc") // a = Normal | b = Heat-Seeking | c = User-Guided | d = None
register_cvar("amx_bazooka_reloadtime", "3.1")// in seconds
register_cvar("amx_bazooka_trailtime", "30")// roughly 3 seconds
register_cvar("amx_bazooka_velocity", "700") //I don't know the units for this, just try numbers
register_cvar("amx_bazooka_teamcolors", "1")// 0 = white, 1 = team colors, 2 = random
register_cvar("amx_bazooka_gib", "1")// set to 1 for gib deaths (may cause lag on slower computers)
register_cvar("amx_bazooka_autohands", "1")// 1 = on, 0 = off
//autohands is experimental, it makes the bazooka appear in the correct hand by setting the client's cl_righthand cvar
//test cvars
register_cvar("amx_bazooka_menu4num", "7") //set ammo amount for menuitem 4
register_clcmd("say", "handle_say")
register_clcmd("say_team", "handle_say")
register_event("DeathMsg", "player_die", "a")
register_event("CurWeapon", "check_model", "be")
register_event("TextMsg", "bomb_msg", "b", "2=#C4_Plant_At_Bomb_Spot")
register_event("ResetHUD","event_respawn","be","1=1")
register_logevent("round_end", 2, "1=Round_End")
register_logevent("round_start", 2, "1=Round_Start")
register_logevent("bombplant",3,"2=Planted_The_Bomb")
register_clcmd("drop", "handle_drop")
register_forward(FM_PlayerPreThink, "player_bazooka")
register_forward(FM_SetModel, "forward_setmodel")
/***************************************/
//register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
/***************************************/
bazookamenu = menu_create("Bazooka Menu", "do_bazookamenu")
menu_additem(bazookamenu, "Buy Bazooka", "1", ADMIN_ALL)
menu_additem(bazookamenu, "Buy 2 Rockets", "2", ADMIN_ALL)
menu_additem(bazookamenu, "Buy 3 Rockets", "3", ADMIN_ALL)
menu_additem(bazookamenu, "Temp", "4", ADMIN_ALL)
/*Notes on Menu System:
bazookamenu is the id of our custom menusystem
by using menu_additem() I've added 3 entries to start with
later in the Showmenu_Bazooka() function below I use the cvar
amx_bazooka_menu4num to set the ammunition number in slot four,
format the slot four text, find slot four's id,
and then change the text in slot four
hopefully this can be refined to make a dynamic menu system for admins
*/
}
public plugin_precache() {
precache_model("models/rpgrocket.mdl")
precache_model("models/w_rpg.mdl")
precache_model("models/v_rpg.mdl")
precache_model("models/p_rpg.mdl")
precache_sound("weapons/rocketfire1.wav")
precache_sound("items/gunpickup4.wav")
precache_sound("weapons/nuke_fly.wav")// <-- this is the only non-game sound file, make sure you have it
precache_sound("weapons/dryfire1.wav")
spr_blood_drop = precache_model("sprites/blood.spr")
spr_blood_spray = precache_model("sprites/bloodspray.spr")
mdl_gib_flesh = precache_model("models/Fleshgibs.mdl")
mdl_gib_head = precache_model("models/GIB_Skull.mdl")
mdl_gib_legbone = precache_model("models/GIB_Legbone.mdl")
mdl_gib_lung = precache_model("models/GIB_Lung.mdl")
mdl_gib_meat = precache_model("models/GIB_B_Gib.mdl")
mdl_gib_spine = precache_model("models/GIB_B_Bone.mdl")
g_sModelIndexFireball = precache_model("sprites/zerogxplode.spr")
g_sModelIndexSmoke = precache_model("sprites/steam1.spr")
rocketsmoke = precache_model("sprites/smoke.spr")
}
/*****************************
WIP commands Section
******************************/
//Notes:
//I'm trying to improve on the old menu system by allowing to buy ammo
//maybe in the future I could add sell?
//BCost = bazooka price
//ACost = rocket price, which is half of Bcost, or Bcost/2
//Buy Bazooka
// 1. Bazooka (BCost)
// 2. Buy 1 Rocket (ACost)
// 3. Buy 2 Rockets (ACost*2)
// 4. Buy 4 Rockets (ACost*4)
// 5. Sell 1 Rocket (ACost*0.75) -- prevents money gain
// 6. Sell 2 Rockets ((ACost*0.75)*2) -- same here
// 0. Exit
public Showmenu_Bazooka(id) {
new menu_item4text[51], ammonum, menu_item4id
ammonum = get_cvar_num("amx_bazooka_menu4num") //get the ammonum for slot 4
format(menu_item4text, 50,"Buy %i Rockets", ammonum) //format text
menu_item4id = menu_find_id(bazookamenu, 0, MENU_KEY_4); //find the id for menuitem 4
menu_item_setname(bazookamenu, menu_item4id, menu_item4text); //set the text
menu_display(id,bazookamenu,0) //show the new menu
//btw using menu_additem() here causes the menu to get bigger everytime the menu is called
/*new MenuBody_b[256]
new len = format(MenuBody_b, 255, "\yBuy Item^n^n")
len = len + format(MenuBody_b[len], 255 - len, "\w1. Bazooka\R$%d^n", get_cvar_num("amx_bazooka_cost"))
len = len + format(MenuBody_b[len], 255 - len, "^n\w0. Exit^n")
register_menuid("Bazooka_Buymenu")
show_menu(id, BAZOOKA_MENUKEYS, MenuBody_b, -1, "Bazooka Menu")*/
menu_display(id,bazookamenu,0)
return PLUGIN_HANDLED
}
public do_bazookamenu(id, Menu, Item) {
new szCommand[3], Accesss, Callback, BCost, ACost
BCost = get_cvar_num("amx_bazooka_cost") // explained in notes section
ACost = BCost/2
menu_item_getinfo(Menu, Item, Accesss, szCommand, 2, _, _, Callback)
switch(szCommand[0]) {
case '-': {
return PLUGIN_HANDLED
}
case '1': {
if (cs_get_user_money(id) >= BCost && !hasBazooka[id]) {
give_item_bazooka(id,(Munni[id] + get_cvar_num("amx_bazooka_ammo")),1)
cs_set_user_money(id, cs_get_user_money(id) - BCost)
client_print(id, print_chat, "[Bazooka] You have successfully bought a bazooka!")
client_print(id, print_chat, "[Bazooka] What are you going to do now!?")
}
if (cs_get_user_money(id) < BCost) {
client_print(id, print_center, "You need $%i to buy this", BCost)
}
if (hasBazooka[id]) {
client_print(id, print_center, "You already have a bazooka")
}
}
case '2': {
if (cs_get_user_money(id) >= ACost*2 && hasBazooka[id]) {
Munni[id] += 2
cs_set_user_money(id, cs_get_user_money(id) - ACost*2)
client_print(id, print_chat, "[Bazooka] You now have %i Rockets", Munni[id])
}
if (cs_get_user_money(id) < ACost*2) {
client_print(id, print_center, "You need $%i to buy this", ACost*2)
}
if (!hasBazooka[id]) {
client_print(id, print_center, "You can't buy ammo for a gun you don't have")
}
}
case '3': {
if (cs_get_user_money(id) >= ACost*4 && hasBazooka[id]) {
Munni[id] += 4
cs_set_user_money(id, cs_get_user_money(id) - ACost*4)
client_print(id, print_chat, "[Bazooka] You now have %i Rockets", Munni[id])
}
if (cs_get_user_money(id) < ACost*4) {
client_print(id, print_center, "You need %i dollars to buy this", ACost*4)
}
if (!hasBazooka[id]) {
client_print(id, print_center, "You can't buy ammo for a gun you don't have")
}
}
case '4': {
new addnum = get_cvar_num("amx_bazooka_menu4num")
if (cs_get_user_money(id) >= ACost*addnum && hasBazooka[id]) {
Munni[id] += addnum
cs_set_user_money(id, cs_get_user_money(id) - ACost*addnum)
client_print(id, print_chat, "[Bazooka] You now have %i Rockets", Munni[id])
}
if (cs_get_user_money(id) < ACost*addnum) {
client_print(id, print_center, "You need %i dollars to buy this", ACost*4)
}
if (!hasBazooka[id]) {
client_print(id, print_center, "You can't buy ammo for a gun you don't have")
}
}
}
return PLUGIN_HANDLED
}
/*****************************
End of WIP Commands Section
******************************/
public bomb_msg(id) {
if (cs_get_user_plant(id) != 1)
client_print(id,print_center,"")
}
public bombplant() {
cantplantbomb = true //now noone can plant the bomb
}
public round_end() {
set_task(4.8, "round_prestart")
set_task(5.0, "player_spawn")
//set_task(5.2, "bazooka_arena")
//placing the bazooka_arena task here caused some timing issues
}
public round_prestart() {
allow_shooting = false
cantplantbomb = true
cantswitch = true
}
public round_start() {
allow_shooting = true
cantplantbomb = false
cantswitch = false
if (get_cvar_num("amx_bazooka_arena") == 1) {
set_task(0.1, "bazooka_arena")
//the bazooka_arena task gets more accurately here
}
}
//this gets rid of the backpack model for bomb carriers, i left it in for reference
/*public forward_setmodel(entity, model[]) {
if (!is_valid_ent(entity)) {
return FMRES_IGNORED
}
if (equal(model, "models/w_backpack.mdl")) {
client_print(0, print_center, "")
new ClassName[32]
entity_get_string(entity, EV_SZ_classname, ClassName, 31)
if (equal(ClassName, "weaponbox")) {
remove_entity(entity)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}*/
//this replaces the dropped bomb model with the rpg model
public forward_setmodel(entity , model[]) {
if(!is_valid_ent(entity)) {
return FMRES_IGNORED;
}
if(equali(model , "models/w_c4.mdl")) {
entity_set_model(entity , "models/w_rpg.mdl");
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public client_disconnect(id) {
/* Notes:
i now think that using switch_hands() here is too late to
put the player's cl_righthand cvar back to normal
I think i need to find an event that happens just before the player dc's
*/
ammo_hud(id, 0)
if (get_cvar_num("amx_bazooka_autohands") == 1) {
switch_hands(id,0)
}
Munni[id] = 0
user_controll[id] = 0
hasBazooka[id] = false
if ((cs_get_user_plant(id) == 1) || cantswitch) {
cs_set_user_plant(id,0,0)
cantswitch = false
//if this person had the bomb out and dc'ed then the other players can now access the bomb
}
}
public client_connect(id) {
CanShoot[id] = true
Munni[id] = 0
mode[id] = 1
modetext[id] = 1
hasBazooka[id] = false
//required information for the switch_hands() function
//go see the function for notes on its use
hand[id] = get_cvar_num("cl_righthand")
if (hand[id]==1) {
newhand[id] = 0
}
else if (hand[id]==0) {
newhand[id] = 1
}
}
public player_die(id) {
new victim
victim = read_data(2)
ammo_hud(victim, 0)
if (get_cvar_num("amx_bazooka_autohands") == 1) {
switch_hands(victim,0)
//set their "hands" back to normal
}
Munni[victim] = 0
user_controll[victim] = 0
hasBazooka[victim] = false
if ((cs_get_user_plant(victim) == 1) || cantswitch) {
cs_set_user_plant(victim,0,0)
cantswitch = false
//if they had c4 out and died, reenable c4 for other players
}
}
public player_spawn() {
new players[32], count
get_players(players, count)
for (new i = 0; i < count; i++) {
if (is_user_alive(players[i])) {
new v_oldmodel[64], p_oldmodel[64]
entity_get_string(players[i], EV_SZ_viewmodel, v_oldmodel, 63)
entity_get_string(players[i], EV_SZ_weaponmodel, p_oldmodel, 63)
if (equal(v_oldmodel, "models/v_rpg.mdl") || equal(p_oldmodel, "models/p_rpg.mdl")) {
if (!hasBazooka[players[i]]) {
new weaponid, clip, ammo
weaponid = get_user_weapon(players[i], clip, ammo)
new weaponname[64]
get_weaponname(weaponid, weaponname, 63)
new v_model[64], p_model[64]
format(v_model, 63, "%s", weaponname)
format(p_model, 63, "%s", weaponname)
replace(v_model, 63, "weapon_", "v_")
format(v_model, 63, "models/%s.mdl", v_model)
entity_set_string(players[i], EV_SZ_viewmodel, v_model)
replace(p_model, 63, "weapon_", "p_")
format(p_model, 63, "models/%s.mdl", p_model)
entity_set_string(players[i], EV_SZ_weaponmodel, p_model)
}
}
}
}
new TempRocket = find_ent_by_class(-1, "rpgrocket")
while (TempRocket > 0) {
remove_entity(TempRocket)
TempRocket = find_ent_by_class(TempRocket, "rpgrocket")
}
new TempRPG = find_ent_by_class(-1, "rpg_temp")
while (TempRPG > 0) {
remove_entity(TempRPG)
TempRPG = find_ent_by_class(TempRPG, "rpg_temp")
}
return PLUGIN_CONTINUE
}
public cmdBazooka_StartArena(id,level,cid) {
/*Notes:
client_print() functions with "//DEBUG INFO" directly before them
are just that, debug info, they can be removed or commented when testing is done
also this function could prolly stand to be cleaned up a bit
a bit meaning alot :P
*/
if (!cmd_access(id, level, cid, 3)) {
return PLUGIN_HANDLED
}
//DEBUG INFO
//client_print(id, print_chat, "[Bazooka] cmdBazooka_StartArena has been called")
new arg[6],arg2[2],argument2,players[32], count
read_argv(1,arg,5)
read_argv(2,arg2,1)
argument2 = str_to_num(arg2)
set_cvar_string("amx_bazooka_arena", "1")
console_cmd(id, "amx_bazooka_arena 1")
console_cmd(id, "amx_bazooka_restrict %s",arg)
set_task(0.1, "bazooka_arena")
get_players(players, count)
for (new i = 0; i < count; i++) {
//nice little warning to the players
console_cmd(players[i],"spk ^"attention.explosion system activated^"")
}
if (argument2 > 0) {
console_cmd(id, "sv_restartround %s",argument2)
}
return PLUGIN_HANDLED
}
public cmdBazooka_EndArena(id,level,cid) {
if (!cmd_access(id, level, cid, 2)) {
return PLUGIN_HANDLED
}
//DEBUG INFO
//client_print(id, print_chat, "[Bazooka] cmdBazooka_EndArena has been called")
new arg[5],argument1,players[32], count
read_argv(1,arg,4)
argument1 = str_to_num(arg)
console_cmd(id, "amx_bazooka_arena 0")
if (argument1 >= 0) {
get_players(players, count)
for (new i = 0; i < count; i++) {
Munni[players[i]] = argument1
ammo_hud(players[i], 0)
ammo_hud(players[i], 1)
//a double notice that Bazooka Arena is OFF
//it's real easy to miss a text announcement in the heat of battle
client_print(players[i], print_chat, "[Bazooka] Bazooka Arena has been turned OFF")
console_cmd(players[i],"spk ^"attention.explosion system deactivated^"")
}
}
return PLUGIN_HANDLED
}
/*Notes:
Around here i was trying to make the rpg animations work
seq_animation[id] sets the animation sequence for a specific id
the animation numbers for the bazooka are listed as constants at
the top and are as follows:
SEQ_IDLE 0
SEQ_FIDGET 1
SEQ_RELOAD 2
SEQ_FIRE 3
i don't remember how well i got animations to work,
but i remember that at best, you had to be holding the
fire button for the fire animation to work
*/
public rpg_reloaddone(data[]) {
CanShoot[data[0]] = true
seq_animation[data[0]] = SEQ_IDLE
}
public rpg_reloadstart(data[]) {
seq_animation[data[0]] = SEQ_RELOAD
}
public fire_rocket(id) {
ammo_hud(id, 0)
ammo_hud(id, 1)
//those two functions above effectively refresh the custom hud info for the bazooka
CanShoot[id] = false
seq_animation[id] = SEQ_FIRE
new data[1]
data[0] = id
new rtime = get_cvar_num("amx_bazooka_reloadtime")
//Note: since rtime must be a float i made the cvar a whole number for convienence
//but then i added 0.0 to make it a float for later
if (cs_get_user_plant(id) != 1){ //if they DON'T have the bomb out
set_task((rtime+0.0), "rpg_reloaddone", id+9477, data, 1) //when can i shoot again?
//set_task(0.0, "rpg_reloadstart", id+9478, data, 1) //start reload animation
if ((Munni[id] <= 0) && (get_cvar_num("amx_bazooka_arena") != 1)) {
//no ammo, do empty click
emit_sound(id, CHAN_WEAPON, "weapons/dryfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}
else {
//ammo, start up the math
//don't touch most of this unless you know your vectors and ents
new Float:StartOrigin[3], Float:Angle[3]
new PlayerOrigin[3]
get_user_origin(id, PlayerOrigin, 1)
StartOrigin[0] = float(PlayerOrigin[0])
StartOrigin[1] = float(PlayerOrigin[1])
StartOrigin[2] = float(PlayerOrigin[2])
entity_get_vector(id, EV_VEC_v_angle, Angle)
Angle[0] = Angle[0] * -1.0
new RocketEnt = create_entity("info_target")
entity_set_string(RocketEnt, EV_SZ_classname, "rpgrocket")
entity_set_model(RocketEnt, "models/rpgrocket.mdl")
entity_set_origin(RocketEnt, StartOrigin)
entity_set_vector(RocketEnt, EV_VEC_angles, Angle)
new Float:MinBox[3] = {-1.0, -1.0, -1.0}
new Float:MaxBox[3] = {1.0, 1.0, 1.0}
entity_set_vector(RocketEnt, EV_VEC_mins, MinBox)
entity_set_vector(RocketEnt, EV_VEC_maxs, MaxBox)
entity_set_int(RocketEnt, EV_INT_solid, 2)
entity_set_int(RocketEnt, EV_INT_movetype, 5)
entity_set_edict(RocketEnt, EV_ENT_owner, id)
new Float:Velocity[3]
new myvelocity = get_cvar_num("amx_bazooka_velocity") //custom velocity
VelocityByAim(id, myvelocity, Velocity)
entity_set_vector(RocketEnt, EV_VEC_velocity, Velocity)
emit_sound(RocketEnt, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(RocketEnt, CHAN_VOICE, "weapons/nuke_fly.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
if (get_cvar_num("amx_bazooka_arena") != 1) {
//if bazooka_arena is off then subtract from ammo
//and refresh the custom hud
ammo_hud(id, 0)
Munni[id]--
ammo_hud(id, 1)
}
//here we do the trail colors
new CsTeams:iTeam =cs_get_user_team(id)
new trailtime =get_cvar_num("amx_bazooka_trailtime")
new colorr =random_num(0,255)
new colorg =random_num(0,255)
new colorb =random_num(0,255)
new colora =100+random_num(0,155)
//i've never seen a black smoke trail in CS, are they possible?...
if (get_cvar_num("amx_bazooka_teamcolors") == 0){ // white
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(RocketEnt)
write_short(rocketsmoke)
write_byte(trailtime)
write_byte(3)
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(255)
message_end()
}
else if (get_cvar_num("amx_bazooka_teamcolors") == 1) {
switch(iTeam) {
case CS_TEAM_T: { //if team T color=red
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(RocketEnt)
write_short(rocketsmoke)
write_byte(trailtime)
write_byte(3)
write_byte(255)
write_byte(0)
write_byte(0)
write_byte(255)
message_end()
}
case CS_TEAM_CT: { // if team CT color=blue
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(RocketEnt)
write_short(rocketsmoke)
write_byte(trailtime)
write_byte(3)
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(255)
message_end()
}
}
}
else if (get_cvar_num("amx_bazooka_teamcolors") == 2){ // random colors anyone?
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(RocketEnt)
write_short(rocketsmoke)
write_byte(trailtime)
write_byte(3)
write_byte(colorr)
write_byte(colorg)
write_byte(colorb)
write_byte(colora)
message_end()
}
if (mode[id] == 2) {
//mmmmm heat-seeking
new info[1]
info[0] = RocketEnt
set_task(1.0, "find_and_follow", 0, info, 1)
}
else if (mode[id] == 3) {
//user-guided
entity_set_int(RocketEnt, EV_INT_rendermode, 1)
attach_view(id, RocketEnt)
user_controll[id] = RocketEnt
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public find_and_follow(info[]) {
new RocketEnt = info[0]
new Float:shortestDist = 10000.0
new nearestPlayer = 0
if (is_valid_ent(RocketEnt)) {
new players[32], count
get_players(players, count)
for (new i = 0; i < count; i++) {
if (is_user_alive(players[i]) && (entity_get_edict(RocketEnt, EV_ENT_owner) != players[i]) && (get_user_team(players[i]) != get_user_team(entity_get_edict(RocketEnt, EV_ENT_owner)))) {
new Float:PlayerOrigin[3], Float:RocketOrigin[3]
entity_get_vector(players[i], EV_VEC_origin, PlayerOrigin)
entity_get_vector(RocketEnt, EV_VEC_origin, RocketOrigin)
new Float:distance = vector_distance(PlayerOrigin, RocketOrigin)
if (distance <= shortestDist) {
shortestDist = distance
nearestPlayer = players[i]
}
}
}
}
if (nearestPlayer > 0) {
new data[2]
data[0] = RocketEnt
data[1] = nearestPlayer
set_task(0.1, "follow_and_catch", RocketEnt, data, 2, "b")
}
else {
pfn_touch(RocketEnt, 0)
}
}
public follow_and_catch(data[]) {
new RocketEnt = data[0]
new target = data[1]
new myvelocity = get_cvar_num("amx_bazooka_velocity")
if (is_user_alive(target) && is_valid_ent(RocketEnt)) {
entity_set_follow(RocketEnt, target, (myvelocity+0.0))
new Float:Velocity[3]
new Float:NewAngle[3]
entity_get_vector(RocketEnt, EV_VEC_velocity, Velocity)
vector_to_angle(Velocity, NewAngle)
entity_set_vector(RocketEnt, EV_VEC_angles, NewAngle)
}
else {
remove_task(RocketEnt)
new info[1]
info[0] = RocketEnt
set_task(0.1, "find_and_follow", 0, data, 1)
}
}
public pfn_touch(ptr, ptd) {
new ClassName[32]
new ClassNameptd[32]
//here i grab the classname of each item for debugging and advanced collisions later
if ((ptr > 0) && is_valid_ent(ptr)) {
entity_get_string(ptr, EV_SZ_classname, ClassName, 31)
}
if ((ptd > 0) && is_valid_ent(ptd)) {
entity_get_string(ptd, EV_SZ_classname, ClassNameptd, 31)
}
if (equal(ClassName, "rpgrocket")) {
remove_task(ptr)
new Float:EndOrigin[3]//x,y,z
entity_get_vector(ptr, EV_VEC_origin, EndOrigin)
message_begin( MSG_BROADCAST, SVC_TEMPENTITY) // Explosion
write_byte(TE_EXPLOSION)
write_coord(floatround(EndOrigin[0]))
write_coord(floatround(EndOrigin[1]))
write_coord(floatround(EndOrigin[2])+5)
write_short(g_sModelIndexFireball)
write_byte(random_num(0,20) + 20)
write_byte(12) // framerate
write_byte(TE_EXPLFLAG_NONE)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) // Smoke
write_byte(TE_SMOKE)
write_coord(floatround(EndOrigin[0]))
write_coord(floatround(EndOrigin[1]))
write_coord(floatround(EndOrigin[2])+15)
write_short(g_sModelIndexSmoke)
write_byte(60)
write_byte(10)
message_end()
/*message_begin(MSG_BROADCAST,SVC_TEMPENTITY) // Explosion Decal
write_byte(28) //grenade explotion mark
write_coord(floatround(EndOrigin[0]))
write_coord(floatround(EndOrigin[1]))
write_coord(floatround(EndOrigin[2]))
write_short(spr_blood_spray)
write_short(spr_blood_drop)
write_byte(229) // color index
write_byte(15) // size
message_end()*/
new maxdamage = get_cvar_num("amx_bazooka_maxdamage")
new damageradius = get_cvar_num("amx_bazooka_damageradius")
if (equal(ClassNameptd, "func_breakable")) {
//new Float:ptrhealth = entity_get_float(ptr,EV_FL_health);
//new Float:ptdhealth = entity_get_float(ptd,EV_FL_health);
//DEBUG INFO
//client_print(0, print_console, "Entity ptr health is: %i",ptrhealth)
//client_print(0, print_console, "Entity ptd health is: %i",ptdhealth)
//entity_set_float(ptr,EV_FL_health,100.0); //i don't remember why this is here
//the functions below break ANY breakables and kill the rocket
//and when i say ANY breakables i mean ANY breakables
//it will destroy even trigger only breakables, bad for mapmakers
force_use(ptr,ptd)
remove_task(ptr)
}
/*Notes: Here i tried to make it so that if a breakable entity was within the damage
radius it would recieve it's share of damage
this is very experimental as I couldn't get it to work after two or three days of tinkering
*/
/*if (equal(ClassNameptd, "func_breakable")) {
client_print(0, print_console, "got classname %s",ClassNameptd)
new Float:orig1[3], origin1[3],NonFloatEndOrigin[3]
entity_get_vector(ptd, EV_VEC_origin, orig1)
for(new a = 0; a < 3; a++) {
origin1[a] = floatround(orig1[a])
}
for(new a = 0; a < 3; a++) {
NonFloatEndOrigin[a] = floatround(EndOrigin[a])
}
new ptddistance = get_distance(origin1, NonFloatEndOrigin)
client_print(0, print_console, "got distance %i",ptddistance)
if (ptddistance <= damageradius) {
client_print(0, print_console, "is in damage radius")
new damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(ptddistance), float(damageradius))))
if (damage > 25) {
client_print(0, print_console, "damage > 25")
force_use(ptr,ptd)
remove_task(ptr)
}
else {
client_print(0, print_console, "damage < 25")
remove_task(ptr)
}
}
return PLUGIN_CONTINUE
}*/
new PlayerPos[3], distance, damage
for (new i = 1; i < 32; i++) {
if (is_user_alive(i) == 1) {
get_user_origin(i, PlayerPos)
new NonFloatEndOrigin[3]
for(new a = 0; a < 3; a++) {
NonFloatEndOrigin[a] = floatround(EndOrigin[a])
}
distance = get_distance(PlayerPos, NonFloatEndOrigin)
if (distance <= damageradius) { // Screenshake Radius
message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, i) // Shake Screen
write_short(1<<14)
write_short(1<<14)
write_short(1<<14)
message_end()
damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))))
new attacker = entity_get_edict(ptr, EV_ENT_owner)
if (!get_user_godmode(i)) {
if (get_user_team(attacker) != get_user_team(i)) {
if (damage < get_user_health(i)) {
set_user_health(i, get_user_health(i) - damage)
}
else {
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
user_kill(i, 1)
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg")) // Kill-Log oben rechts
write_byte(attacker) // Attacker
write_byte(i) // Victim
write_byte(0) // Headshot
write_string("bazooka")
message_end()
if (damage > 100 && get_cvar_num("amx_bazooka_gib") == 1) { //begin gibs and effects (made by mike_cao)
new iOrigin[3]
get_user_origin(i,iOrigin) // Effects
fx_trans(i,0)
fx_gib_explode(iOrigin,3)
fx_blood_large(iOrigin,5)
fx_blood_small(iOrigin,15)
iOrigin[2] = iOrigin[2]-20 // Hide body
set_user_origin(i,iOrigin)
} //end gibs and effects
set_user_frags(attacker, get_user_frags(attacker) + 1)
if (get_cvar_num("amx_bazooka_gib") == 1) {
client_print(attacker, print_center, "LOLERS! You just splattered that guy's guts everywhere!")
}
}
}
if (get_user_team(attacker) == get_user_team(i)) {
if (attacker == i) {
if (damage < get_user_health(i)) {
set_user_health(i, get_user_health(i) - damage)
}
else {
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
user_kill(i, 1)
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg")) // Kill-Log oben rechts
write_byte(attacker) // Attacker
write_byte(i) // Victim
write_byte(0) // Headshot
write_string("bazooka")
message_end()
if ((damage > 100) && get_cvar_num("amx_bazooka_gib") == 1) { //begin gibs and effects (made by mike_cao)
new iOrigin[3]
get_user_origin(i,iOrigin)// Effects
fx_trans(i,0)
fx_gib_explode(iOrigin,3)
fx_blood_large(iOrigin,5)
fx_blood_small(iOrigin,15)
iOrigin[2] = iOrigin[2]-20 // Hide body
set_user_origin(i,iOrigin)
} //end gibs and effects
set_user_frags(attacker, get_user_frags(attacker) - 1)
if (get_cvar_num("amx_bazooka_gib") == 1){
client_print(attacker, print_center, "Great! Now everyone knows what you had for supper!")
}
else {
client_print(attacker, print_center, "You do know this thing explodes right?")
}
}
}
else {
if (get_cvar_num("mp_friendlyfire")) {
if (damage < get_user_health(i)) {
set_user_health(i, get_user_health(i) - damage)
client_print(attacker, print_center, "You injured a teammate! Watch your aim!")
}
else {
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
user_kill(i, 1)
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg")) // Kill-Log oben rechts
write_byte(attacker) // Attacker write_byte(i) // Victim
write_byte(0) // Headshot
write_string("bazooka")
message_end()
if (damage > 100 && get_cvar_num("amx_bazooka_gib") == 1) { //begin gibs and effects (made by mike_cao)
new iOrigin[3]
get_user_origin(i,iOrigin)// Effects
fx_trans(i,0)
fx_gib_explode(iOrigin,3)
fx_blood_large(iOrigin,5)
fx_blood_small(iOrigin,15)
iOrigin[2] = iOrigin[2]-20 // Hide body
set_user_origin(i,iOrigin)
} //end gibs and effects
set_user_frags(attacker, get_user_frags(attacker) - 1)
if (get_cvar_num("amx_bazooka_gib") == 1){
client_print(attacker, print_center, "OMFG's!! You just splattered a teammate!")
}
else{
client_print(attacker, print_center, "LOL! That teammate is probably not too happy now!")
}
}
}
}
}
}
}
}
}
attach_view(entity_get_edict(ptr, EV_ENT_owner), entity_get_edict(ptr, EV_ENT_owner))
user_controll[entity_get_edict(ptr, EV_ENT_owner)] = 0
remove_entity(ptr)
}
if (equal(ClassName, "rpg") || equal(ClassName, "rpg_temp")) {
new Picker[32]
if ((ptd > 0) && is_valid_ent(ptd)) {
entity_get_string(ptd, EV_SZ_classname, Picker, 31)
}
if (equal(Picker, "player")) {
give_item_bazooka(ptd,(Munni[ptd] + entity_get_int(ptr, EV_INT_iuser1)),1)
client_print(ptd, print_chat, "[Bazooka] You have picked up a bazooka!")
remove_entity(ptr)
}
}
return PLUGIN_CONTINUE
}
public drop_rpg(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) {
return PLUGIN_HANDLED
}
new Float:PlayerOrigin[3], Float:End[3], Float:Return[3], Float:TraceDirection[3]
entity_get_vector(id, EV_VEC_origin, PlayerOrigin)
VelocityByAim(id, 64, TraceDirection)
End[0] = TraceDirection[0] + PlayerOrigin[0]
End[1] = TraceDirection[1] + PlayerOrigin[1]
End[2] = TraceDirection[2] + PlayerOrigin[2]
trace_line(id, PlayerOrigin, End, Return)
Return[2] = PlayerOrigin[2]
new RPG = create_entity("info_target")
entity_set_string(RPG, EV_SZ_classname, "rpg")
entity_set_model(RPG, "models/w_rpg.mdl")
entity_set_origin(RPG, Return)
new Float:MinBox[3] = {-16.0, -16.0, 0.0}
new Float:MaxBox[3] = {16.0, 16.0, 16.0}
entity_set_vector(RPG, EV_VEC_mins, MinBox)
entity_set_vector(RPG, EV_VEC_maxs, MaxBox)
entity_set_int(RPG, EV_INT_solid, 1)
entity_set_int(RPG, EV_INT_movetype, 6)
entity_set_int(RPG, EV_INT_iuser1, get_cvar_num("amx_bazooka_ammo"))
return PLUGIN_HANDLED
}
/*Notes:
DON'T SCREW WITH THE MODES. PERIOD!
It took me hours to figure out the logic for each action and make it work.
the modes as they are allow only one player at a time to access the c4
and will also force a player to move to the next mode if the one they are on is restricted
which can happen if the admin changes restrictions during gameplay
*/
public player_bazooka(id) {
if (is_user_alive(id)) {
new weaponid, clip, ammo
weaponid = get_user_weapon(id, clip, ammo)
if ((weaponid == CSW_C4) && hasBazooka[id]) {
set_animation(id,seq_animation[id])
new attack = get_user_button(id) & IN_ATTACK
new oldattack = get_user_oldbutton(id) & IN_ATTACK
new attack2 = get_user_button(id) & IN_ATTACK2
new oldattack2 = get_user_oldbutton(id) & IN_ATTACK2
new CsTeams:iTeam = cs_get_user_team(id)
if (attack && !oldattack && (cs_get_user_plant(id) != 1)) {
get_restrict_flags()
if (mode[id] == 1 && iFlags&BA_NORMAL) {
client_print(id, print_center, "You cannot fire a restricted mode")
client_cmd(id,"+attack2;wait;-attack2")
}
else if (mode[id] == 2 && iFlags&BA_HEAT) {
client_print(id, print_center, "You cannot fire a restricted mode")
client_cmd(id,"+attack2;wait;-attack2")
}
else if (mode[id] == 3 && iFlags&BA_USER) {
client_print(id, print_center, "You cannot fire a restricted mode")
client_cmd(id,"+attack2;wait;-attack2")
}
else if (mode[id] == 4 && iTeam&CS_TEAM_CT) {
client_print(id, print_center, "You cannot plant a bomb!")
client_cmd(id,"+attack2;wait;-attack2")
}
else {
if (CanShoot[id] && allow_shooting && (user_controll[id] == 0)) {
fire_rocket(id)
}
}
}
else if (attack2 && !oldattack2) {
check_model(id)
switch(mode[id]) {
case 1: {
get_restrict_flags()
if ((iFlags&BA_HEAT) != BA_HEAT) {
mode[id] = 2
modetext[id] = 2
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_WEAPON, "items/nvg_on.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Heat-Seeking Mode")
}
else if ((iFlags&BA_USER) != BA_USER) {
mode[id] = 3
modetext[id] = 3
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_WEAPON, "items/gunpickup4.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "User-Guided Mode")
}
else {
if (!cantplantbomb && !cantswitch && iTeam&CS_TEAM_T) {
cantswitch = true
mode[id] = 4
modetext[id] = 4
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,1,1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Switching to C4 Bomb")
}
else if (cantplantbomb || cantswitch || iTeam&CS_TEAM_CT){
mode[id] = 1
modetext[id] = 1
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "The other modes are restricted")
}
}
}
case 2: {
get_restrict_flags()
if ((iFlags&BA_USER) != BA_USER) {
mode[id] = 3
modetext[id] = 3
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_WEAPON, "items/gunpickup4.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "User-Guided Mode")
}
else if (iFlags&BA_USER && ((iFlags&BA_NORMAL) != BA_NORMAL)) {
if (!cantplantbomb && !cantswitch && iTeam&CS_TEAM_T) {
cantswitch = true
mode[id] = 4
modetext[id] = 4
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,1,1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Switching to C4 Bomb")
}
else if (cantplantbomb || cantswitch || iTeam&CS_TEAM_CT){
mode[id] = 1
modetext[id] = 1
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Normal Mode")
}
}
else {
mode[id] = 2
modetext[id] = 2
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "The other modes are restricted")
}
}
case 3: {
get_restrict_flags()
if ((iFlags&BA_NORMAL) != BA_NORMAL) {
if (!cantplantbomb && !cantswitch && iTeam&CS_TEAM_T) {
cantswitch = true
mode[id] = 4
modetext[id] = 4
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,1,1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Switching to C4 Bomb")
}
else if (cantplantbomb || cantswitch || iTeam&CS_TEAM_CT){
mode[id] = 1
modetext[id] = 1
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Normal Mode")
}
}
else if ((iFlags&BA_HEAT) != BA_HEAT){
mode[id] = 2
modetext[id] = 2
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_WEAPON, "items/nvg_on.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Heat-Seeking Mode")
}
else {
mode[id] = 3
modetext[id] = 3
ammo_hud(id, 0)
ammo_hud(id, 1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "The other modes are restricted")
}
}
case 4: {
get_restrict_flags()
if ((iFlags&BA_NORMAL) != BA_NORMAL) {
cantswitch = false
mode[id] = 1
modetext[id] = 1
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,0,0)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Switching to Bazooka")
}
else if ((iFlags&BA_HEAT) != BA_HEAT) {
cantswitch = false
mode[id] = 2
modetext[id] = 2
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,0,0)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_WEAPON, "items/nvg_on.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Heat-Seeking Mode")
}
else if ((iFlags&BA_USER) != BA_USER) {
cantswitch = false
mode[id] = 3
modetext[id] = 3
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,0,0)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_WEAPON, "items/gunpickup4.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "User-Guided Mode")
}
else {
cantswitch = true
mode[id] = 4
modetext[id] = 4
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,1,1)
check_model(id)
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "The other modes are restricted")
}
}
}
}
}
}
if (user_controll[id] > 0) {
new RocketEnt = user_controll[id]
if (is_valid_ent(RocketEnt)) {
new Float:Velocity[3]
VelocityByAim(id, 500, Velocity)
entity_set_vector(RocketEnt, EV_VEC_velocity, Velocity)
new Float:NewAngle[3]
entity_get_vector(id, EV_VEC_v_angle, NewAngle)
entity_set_vector(RocketEnt, EV_VEC_angles, NewAngle)
}
else {
attach_view(id, id)
}
}
return FMRES_IGNORED
}
/*Notes
in version 1.3c this function spawned both an rpg and a bomb upon dropping the bazooka,
in version 1.3d i cleaned it up and hopefully fixed this error
...i think i only cleaned it up, will test later...
*/
public handle_drop(id) {
new weaponid, clip, ammo
weaponid = get_user_weapon(id, clip, ammo)
if (weaponid == CSW_C4 && cs_set_user_plant(id,0,0)) {
if (get_cvar_num("amx_bazooka_dropping") == 1) {
drop_rpg_temp(id)
if (get_cvar_num("amx_bazooka_autohands") == 1) {
switch_hands(id,0)
}
}
else {
client_print(id, print_center, "This weapon cannot be dropped")
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public drop_rpg_temp(id) {
new Float:PlayerOrigin[3], Float:End[3], Float:Return[3], Float:TraceDirection[3], Float:Angles[3]
entity_get_vector(id, EV_VEC_origin, PlayerOrigin)
entity_get_vector(id, EV_VEC_angles, Angles)
VelocityByAim(id, 200, TraceDirection)
End[0] = TraceDirection[0] + PlayerOrigin[0]
End[1] = TraceDirection[1] + PlayerOrigin[1]
End[2] = TraceDirection[2] + PlayerOrigin[2]
trace_line(id, PlayerOrigin, End, Return)
Return[2] = PlayerOrigin[2]
new RPG = create_entity("info_target")
entity_set_string(RPG, EV_SZ_classname, "rpg_temp")
entity_set_model(RPG, "models/w_rpg.mdl")
entity_set_origin(RPG, Return)
Angles[0] = 0.0
Angles[2] = 0.0
entity_set_vector(RPG, EV_VEC_angles, Angles)
new Float:MinBox[3] = {-16.0, -16.0, 0.0}
new Float:MaxBox[3] = {16.0, 16.0, 16.0}
entity_set_vector(RPG, EV_VEC_mins, MinBox)
entity_set_vector(RPG, EV_VEC_maxs, MaxBox)
entity_set_int(RPG, EV_INT_solid, 1)
entity_set_int(RPG, EV_INT_movetype, 6)
entity_set_int(RPG, EV_INT_iuser1, Munni[id])
Munni[id] = 0
hasBazooka[id] = false
return PLUGIN_HANDLED
}
public handle_say(id) {
new command[32]
read_argv(1, command, 31)
if (equal(command, "buybazooka")) {
if (is_user_alive(id)) {
if (get_cvar_num("amx_bazooka_buyable") == 1) {
Showmenu_Bazooka(id)
}
else {
client_print(id, print_chat, "[Bazooka] The buymenu is disabled!")
}
}
else {
client_print(id, print_chat, "[Bazooka] You cannot buy a Bazooka while you are dead!")
}
}
if (equal(command, "bazookahelp"))
{
// Display Help File from amxx/configs/bazooka_help.htm
new szHelpFile[64], szCustomDir[32]
//i think get_customdir() has been depreciated, not sure though...
get_customdir( szCustomDir, 31 )
format( szHelpFile, 63, "%s/bazooka_help.htm", szCustomDir )
show_motd( id, szHelpFile, "Bazooka - Help" )
return PLUGIN_CONTINUE
}
return PLUGIN_HANDLED
}
public cmdBazooka_give(id, level, cid) {
if (!cmd_access(id, level, cid, 3)) {
return PLUGIN_HANDLED
}
new arg[32], arg2[8], name2[32], ammo,argument2
ammo=get_cvar_num("amx_bazooka_ammo")
read_argv(1,arg,31)
read_argv(2,arg2,7)
argument2 = str_to_num(arg2)
if ( equali(arg,"@all") )
{
new plist[32],pnum
get_players(plist,pnum,"a")
if (pnum==0)
{
console_print(id,"[Bazooka] This client is invalid")
return PLUGIN_HANDLED
}
for (new i=0; i<pnum; i++)
{
give_item_bazooka(plist[i],(argument2*ammo),1)
client_print(plist[i], print_chat, "[Bazooka] The Admin gave you a bazooka with %d rockets!",argument2*ammo)
client_print(plist[i], print_chat, "[Bazooka] Switch to the bomb weapon or weapon slot 5 to use it")
console_print(id,"[Bazooka] Gave all players bazookas with %d rockets",argument2*ammo)
}
}
else
{
get_user_name(id,name2,31)
new player = cmd_target(id,arg,7)
if (!player)
{
console_print(id,"[Bazooka] Give Bazooka Failed")
return PLUGIN_HANDLED
}
new name[32]
get_user_name(player,name,31)
give_item_bazooka(player,(argument2*ammo),1)
console_print(id,"[Bazooka] Gave %s %d Bazookas",name,argument2*ammo)
client_print(player, print_chat, "[Bazooka] The Admin gave you a bazooka with %d rockets!",argument2*ammo)
client_print(player, print_chat, "[Bazooka] Switch to the bomb weapon or weapon slot 5 to use it.")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public bazooka_arena(id) {
if (get_cvar_num("amx_bazooka_arena") == 1) {
//DEBUG INFO
//client_print(id, print_chat, "[Bazooka] bazooka_arena has been called")
//console_cmd(id ,"amx_bazooka_give @all 1")
console_cmd(id ,"amx_bazooka_damageradius 40")
console_cmd(id ,"amx_bazooka_maxdamage 999999")
new players[32], count
get_players(players, count)
for (new i = 0; i < count; i++) {
give_item_bazooka(players[i],1,1)
client_print(players[i], print_chat, "[Bazooka] Bazooka Arena is ON! say ^"bazookahelp^" for more info")
client_print(players[i], print_center, "Time to make things go BOOM!")
}
}
return PLUGIN_HANDLED
}
//this function is more internal than external, it makes giving a bazooka happen in one line instead of 15
public give_item_bazooka(id,ammo,sound) {
give_item(id, "weapon_c4") // give actual weapon
hasBazooka[id] = true // the plugin now knows they have a bazooka
Munni[id] = ammo //set ammunition
CanShoot[id] = true // they can shoot now
cs_set_user_plant(id,0,0) //they can't plant unless they switch to bomb
mode[id] = 1 //mode = normal
modetext[id] = 1
check_model(id) // refresh model
ammo_hud(id, 0)
ammo_hud(id, 1) // refresh hud info
if (sound) {
//audio notification
emit_sound(id, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
/*Notes:
This function is highly experimental too
It should allow the use of seq_animation[id] in place of the "anim" parameter
to set the current animation of a specific player.
The trick is getting the animation to cycle through the frames
and not stay on the first one in each animation
*/
set_animation(id, anim) {
set_pev(id, pev_weaponanim, anim)
message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id)
write_byte(anim)
write_byte(pev(id, pev_body))
message_end()
}
/*Notes:
This little functions switches the client's cl_righthand cvar
to make the bazooka appear in the correct hand
So far i've implemented it very well except for when a player disconnects
*/
switch_hands(id,mode) {
if (mode) {
client_cmd(id,"cl_righthand %i",newhand[id])
}
else {
client_cmd(id,"cl_righthand %i",hand[id])
}
}
//Yay custom hud!
ammo_hud(id, show) {
new AmmoHud[65],mode[20]
if (modetext[id] == 1) {
mode = "Bazooka"
}
else if (modetext[id] == 2) {
mode = "Heat-Seeking"
}
else if (modetext[id] == 3) {
mode = "User-Guided"
}
else if (modetext[id] == 4) {
mode = "C4"
}
if (get_cvar_num("amx_bazooka_arena") == 1) {
format(AmmoHud, 64, "Rockets: Infinite | Mode: %s",mode)
}
else {
format(AmmoHud, 64, "Rockets: %i | Mode: %s", Munni[id],mode)
}
if (show) {
message_begin(MSG_ONE, get_user_msgid("StatusText"), {0,0,0}, id)
write_byte(0)
write_string(AmmoHud)
message_end()
}
else {
message_begin(MSG_ONE, get_user_msgid("StatusText"), {0,0,0}, id)
write_byte(0)
write_string("")
message_end()
}
}
/*Notes:
I've seen this work on my computer 100% of the time,
but i've not been able to test it online or with multiple players
what this funtion does is check to see if the player has the bazooka weapon out
and then it changes the model accordingly, but if that weapon is not out then it
changes back to what it should be
This is also where switch_hands() is used a lot
*/
public check_model(id) {
new weaponid, clip, ammo
new CsTeams:iTeam = cs_get_user_team(id)
weaponid = get_user_weapon(id, clip, ammo)
if ((weaponid == CSW_C4) && ((cs_get_user_plant(id) != 1) || (mode[id] != 4))) {
if (get_cvar_num("amx_bazooka_autohands") == 1) {
switch_hands(id,1)
}
ammo_hud(id, 0)
ammo_hud(id, 1)
cs_set_user_plant(id,0,0)
entity_set_string(id, EV_SZ_viewmodel, "models/v_rpg.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_rpg.mdl")
}
else if ((weaponid == CSW_C4) && ((cs_get_user_plant(id) == 1) || (mode[id] == 4))) {
if (get_cvar_num("amx_bazooka_autohands") == 1) {
switch_hands(id,0)
}
ammo_hud(id, 0)
ammo_hud(id, 1)
if (iTeam&CS_TEAM_CT) {
cs_set_user_plant(id,0,0)
mode[id] = 1
modetext[id] = 1
entity_set_string(id, EV_SZ_viewmodel, "models/v_rpg.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_rpg.mdl")
}
else if (iTeam&CS_TEAM_T) {
cs_set_user_plant(id,1,1)
entity_set_string(id, EV_SZ_viewmodel, "models/v_c4.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_c4.mdl")
}
}
else if (weaponid != CSW_C4) {
if (get_cvar_num("amx_bazooka_autohands") == 1) {
switch_hands(id,0)
}
cs_set_user_plant(id,0,0)
mode[id] = 1
modetext[id] = 1
ammo_hud(id, 0)
}
return PLUGIN_HANDLED
}
//this little guy reads the flags given in the amx_bazooka_restrict cvar
get_restrict_flags() {
new sFlags[24]
get_cvar_string("amx_bazooka_restrict",sFlags,24)
iFlags = read_flags(sFlags)
}
//ok, everything past here is a direct copy/paste from Mike Cao's Gore Plugin
//with a few minor changes
//i had permission to use this code of course
/************************************************************
* GIB FUNCTIONS (made by mike_cao)
************************************************************/
public event_respawn(id) {
gHealthIndex[id] = get_user_health(id)
fx_trans(id,255)
return PLUGIN_CONTINUE
}
static fx_trans(player,amount)
{
set_user_rendering(player,kRenderFxNone,0,0,0,kRenderTransAlpha,amount)
return PLUGIN_CONTINUE
}
static fx_blood_small(origin[3],num)
{
// Blood decals
#if CZERO
static const blood_small[8] = {202,203,204,205,206,207,208,209}
#else
static const blood_small[7] = {190,191,192,193,194,195,197}
#endif
// Small splash
for (new j = 0; j < num; j++) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
write_coord(origin[0]+random_num(-100,100))
write_coord(origin[1]+random_num(-100,100))
write_coord(origin[2]-36)
write_byte(blood_small[random_num(0,6)]) // index
message_end()
}
}
static fx_blood_large(origin[3],num)
{
// Blood decals
#if CZERO
static const blood_large[2] = {216,217}
#else
static const blood_large[2] = {204,205}
#endif
// Large splash
for (new i = 0; i < num; i++) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
write_coord(origin[0]+random_num(-50,50))
write_coord(origin[1]+random_num(-50,50))
write_coord(origin[2]-36)
write_byte(blood_large[random_num(0,1)]) // index
message_end()
}
}
static fx_gib_explode(origin[3],num)
{
new flesh[3], x, y, z
flesh[0] = mdl_gib_flesh
flesh[1] = mdl_gib_meat
flesh[2] = mdl_gib_legbone
// Gib explosion
// Head
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_MODEL)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_coord(random_num(-100,100))
write_coord(random_num(-100,100))
write_coord(random_num(100,200))
write_angle(random_num(0,360))
write_short(mdl_gib_head)
write_byte(0) // bounce
write_byte(500) // life
message_end()
// Spine
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_MODEL)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_coord(random_num(-100,100))
write_coord(random_num(-100,100))
write_coord(random_num(100,200))
write_angle(random_num(0,360))
write_short(mdl_gib_spine)
write_byte(0) // bounce
write_byte(500) // life
message_end()
// Lung
for(new i = 0; i < random_num(1,2); i++) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_MODEL)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_coord(random_num(-100,100))
write_coord(random_num(-100,100))
write_coord(random_num(100,200))
write_angle(random_num(0,360))
write_short(mdl_gib_lung)
write_byte(0) // bounce
write_byte(500) // life
message_end()
}
// Parts, 10 times
for(new i = 0; i < 10; i++) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_MODEL)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_coord(random_num(-100,100))
write_coord(random_num(-100,100))
write_coord(random_num(100,200))
write_angle(random_num(0,360))
write_short(flesh[random_num(0,2)])
write_byte(0) // bounce
write_byte(500) // life
message_end()
}
// Blood
for(new i = 0; i < num; i++) {
x = random_num(-100,100)
y = random_num(-100,100)
z = random_num(0,100)
for(new j = 0; j < 3; j++) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
write_coord(origin[0]+(x*j))
write_coord(origin[1]+(y*j))
write_coord(origin[2]+(z*j))
write_short(spr_blood_spray)
write_short(spr_blood_drop)
write_byte(229) // color index
write_byte(15) // size
message_end()
}
}
}
/**********************************
Function Testing Section
***********************************/
/**********************************
End of Function Testing Sectionn
***********************************/
en el sv tengo el mp_friendlyfire en "0"
Last edited by twiister; 04-22-2013 at 14:16.
|
|