|
楼主 |
发表于 2008-8-18 17:54:33
|
显示全部楼层
来自 中国–湖北–十堰
回复: 关于users.ini的问题,希望高手指点!
/*
Bazooka v0.99 , by KinSprite , 11/29,2006
【管理员命令】 —— 放火箭筒
amx_bazooka
【玩家命令】—— 购买火箭筒
buy_bazooka
buy_rpg
buy_bzk
say /buy_bazooka
say /buy_rpg
say /buy_bzk
【参数变量】
amx_bazooka_time "5.0" //火箭弹最多飞行时间, 默认 5.0 秒
amx_bazooka_drop "1" //火箭筒是否可丢弃,默认为1,1/0
amx_bazooka_num "4" //最多可存在火箭筒的数量,默认为4
amx_bazooka_ammo "2" //火箭筒的炮弹量,默认为2
amx_bazooka_damageradius "1000" //炮弹的杀伤范围,默认1000
amx_bazooka_maxdamage "150" //炮弹的最大伤害生命值,默认150
amx_bazooka_price "10000" //火箭筒的价格,默认10000$
amx_bazooka_ammoprice "1000" //火箭筒炮弹价格,默认1000$一发
amx_bazooka_reloadtime "4.0" //火箭筒重装炮弹的时间,默认4秒
amx_bazooka_velocity "800" //火箭弹速度, 默认800
amx_bazooka_normal "0" //火箭筒使用普通模式, 默认0
amx_bazooka_heatskdelay "1.0" //热寻导延时,默认 1.0 秒
amx_bazooka_trailtime "30" //火箭弹拖尾时间, 默认30 (大概3秒)
amx_bazooka_teamcolors "1" //火箭弹拖尾颜色, 默认 1 --使用团队颜色
amx_bazooka_arena "0" //火箭筒竞技场, 默认 0 ; 为1时, 火箭弹不减
amx_pazooka_buytime "1" //火箭筒\火箭弹必需在购物时间内购买
amx_bazooka_buyzone "1" //火箭筒\火箭弹必需在购物区中购买
amx_bazooka_adminsuper "0" //有免疫权限管理员不限制使用高级功能
Thanks : More & nwb13
*/
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <cstrike>
#include <amxmisc>
#define PER_VELOCITY_USER_GUIDED 0.65
#define ARENA_DAMAGERADIUS 72
#define ICON_SHOWTIME 3.0
#define ICON_SPRITE "item_longjump"
#define COLOR_R 0
#define COLOR_G 150
#define COLOR_B 0
#define BZK_CLASSNAME "super_bazooka"
enum { IconHide, IconShow, IconFlash };
enum { bzk_droped = 1, bzk_rocket};
new explosion, smoke, white
new g_bazooka_nums
new gWpnUsed[33]
new bool:CanShoot[33]
new bool:buy_in_time
new bool:have_bazooka[33]
new bool:in_freezetime
new Munni[33]
new mode[33]
new user_controll[33]
new g_msgDeathMsg
new gmsgScoreInfo
new g_msgStatusIcon
new rocketsmoke
new g_bazooka_time
new g_bazooka_drop
new g_bazooka_num
new g_bazooka_ammo
new g_bazooka_damageradius
new g_bazooka_maxdamage
new g_bazooka_price
new g_bazooka_ammoprice
new g_bazooka_reloadtime
new g_bazooka_velocity
new g_bazooka_normal
new g_bazooka_heatskdelay
new g_bazooka_trailtime
new g_bazooka_teamcolors
new g_bazooka_arena
new g_bazooka_buytime
new g_bazooka_buyzone
new g_bazooka_adminsuper
new g_bazooka_adminunlimitammo
new g_shield
public plugin_init() {
register_plugin("Bazooka", "v0.99", "KinSprite")
register_dictionary("bazooka.txt")
register_clcmd("amx_bazooka", "drop_rpg", ADMIN_KICK, " - Drop A bazooka in front of you.")
register_concmd("amx_bazooka_startarena", "start_bazooka_arena", ADMIN_KICK, " - Start bazooka arena.")
register_concmd("amx_bazooka_endarena", "end_bazooka_arena", ADMIN_KICK, " - Start bazooka arena.")
g_bazooka_time = register_cvar("amx_bazooka_time", "5.0")
g_bazooka_drop = register_cvar("amx_bazooka_drop", "1")
g_bazooka_num = register_cvar("amx_bazooka_num", "4")
g_bazooka_ammo = register_cvar("amx_bazooka_ammo", "2")
g_bazooka_damageradius = register_cvar("amx_bazooka_damageradius", "1000")
g_bazooka_maxdamage = register_cvar("amx_bazooka_maxdamage", "150")
g_bazooka_price = register_cvar("amx_bazooka_price", "10000")
g_bazooka_ammoprice = register_cvar("amx_bazooka_ammoprice", "1000")
g_bazooka_reloadtime = register_cvar("amx_bazooka_reloadtime", "4.0")
g_bazooka_velocity = register_cvar("amx_bazooka_velocity", "800")
g_bazooka_normal = register_cvar("amx_bazooka_normal", "0")
g_bazooka_heatskdelay = register_cvar("amx_bazooka_heatskdelay", "1.0")
g_bazooka_trailtime = register_cvar("amx_bazooka_trailtime", "30") // roughly 3 seconds
g_bazooka_teamcolors = register_cvar("amx_bazooka_teamcolors", "1") // set to 1 for team colored trails
g_bazooka_arena = register_cvar("amx_bazooka_arena", "0") // requires direct hit to kill
g_bazooka_buytime = register_cvar("amx_bazooka_buytime", "1") // requires buy bazooka or shell in buytime
g_bazooka_buyzone = register_cvar("amx_bazooka_buyzone", "1") // requires buy bazooka or shell at buyzone
g_bazooka_adminsuper = register_cvar("amx_bazooka_adminsuper", "0")
g_bazooka_adminunlimitammo = register_cvar("amx_bazooka_adminunlimitammo", "0")
register_clcmd("buy_bazooka", "buy_bazooka", 0, " - Buy a bazooka (RPG)")
register_clcmd("buy_bzk", "buy_bazooka", 0, " - Buy a bazooka (RPG)")
register_clcmd("buy_rpg", "buy_bazooka", 0, " - Buy a bazooka (RPG)")
register_clcmd("say","check_say")
register_clcmd("say_team","check_say")
register_clcmd("buyammo1","buy_bazooka_ammo")
register_event("Damage", "on_Damage", "b", "2!0") // check killed by C4 bomb
register_event("DeathMsg", "player_die", "a")
register_event("RoundTime", "new_round", "bc") // time change
register_event("CurWeapon", "change_weapon", "be", "1=1")
register_event("ResetHUD", "player_spawn", "b")
register_event("WeapPickup","check_model","b")
register_event("TextMsg","on_RoundRestart","a","2&#Game_will_restart_in")
register_touch(BZK_CLASSNAME, "*", "bzk_touch")
register_logevent("freezetimecomplete", 2, "1=Round_Start") // freezetime complete
register_logevent("EndRound",2,"0=World triggered","1=Round_End")
register_clcmd("drop", "handle_drop")
g_msgDeathMsg = get_user_msgid("DeathMsg")
gmsgScoreInfo = get_user_msgid("ScoreInfo")
g_msgStatusIcon = get_user_msgid("StatusIcon")
g_shield = file_exists("models/p_shield.mdl") & file_exists("models/w_shield.mdl")
}
public plugin_precache() {
precache_model("models/rpgrocket.mdl")
precache_model("models/w_rpg.mdl")
precache_model("models/w_rpgt.mdl")
precache_model("models/v_rpg.mdl")
precache_model("models/p_rpg.mdl")
precache_sound("weapons/rocketfire1.wav")
precache_sound("weapons/nuke_fly.wav")
precache_sound("weapons/mortarhit.wav")
precache_sound("weapons/dryfire_rifle.wav")
precache_sound("common/wpn_select.wav")
precache_sound("items/ammopickup1.wav")
precache_sound("items/gunpickup3.wav")
precache_sound("items/gunpickup4.wav")
precache_sound("items/nvg_on.wav")
explosion = precache_model("sprites/fexplo.spr")
smoke = precache_model("sprites/steam1.spr")
white = precache_model("sprites/white.spr")
rocketsmoke = precache_model("sprites/smoke.spr")
}
public check_say(id) {
new said[32]
read_args(said,31)
if (equali(said, "^"/buy_bazooka^"")
|| equali(said, "^"/buy_bzk^"")
|| equali(said, "^"/buy_rpg^"")
|| equali(said, "^"buy_bazooka^"")
|| equali(said, "^"buy_bzk^"")
|| equali(said, "^"buy_rpg^""))
buy_bazooka(id)
return PLUGIN_CONTINUE
}
public buy_bazooka(id){
if (have_bazooka[id]){
client_print(id,print_chat,"%L", id, "HAVE_BAZOOKA")
return PLUGIN_HANDLED
}
if (!is_user_alive(id)){
client_print(id,print_chat,"%L", id, "CANT_BUY_RPG")
return PLUGIN_HANDLED
}
if (get_pcvar_num(g_bazooka_buyzone))
if (!cs_get_user_buyzone(id)){
client_print(id,print_chat,"%L", id, "NOT_AT_BUYZONE")
return PLUGIN_HANDLED
}
if (!buy_in_time){
client_print(id,print_chat,"%L", id, "NOT_BUY_TIME")
return PLUGIN_HANDLED
}
new user_money = cs_get_user_money(id)
new bazooka_price = get_pcvar_num(g_bazooka_price)
if (user_money >= bazooka_price)
{
if (g_bazooka_nums >= get_pcvar_num(g_bazooka_num) && !get_pcvar_num(g_bazooka_arena)) {
client_print(id,print_chat,"%L", id, "NO_MORE_BAZOOKA")
return PLUGIN_HANDLED
}
cs_set_user_money(id, user_money - bazooka_price)
player_get_bozooka(id)
new name[32]
get_user_name(id,name,31)
client_print(0, print_chat, "%L", LANG_PLAYER, "BUY_BAZOOKA", name)
}else{
client_print(id, print_chat, "%L", id, "LACK_MONEY" ,get_pcvar_num(g_bazooka_price))
}
return PLUGIN_HANDLED
}
public player_get_bozooka(id) {
Create_StatusIcon(id, IconShow, ICON_SPRITE, COLOR_R, COLOR_G, COLOR_B)
set_task(ICON_SHOWTIME, "Clear_Icons", id)
g_bazooka_nums++
have_bazooka[id] = true
CanShoot[id] = true
new ammo = get_pcvar_num(g_bazooka_ammo)
if (ammo > 2) // 初始最多给两枚火箭弹
ammo = 2
Munni[id] = ammo
check_model(id)
mode[id] = 0
user_controll[id] = 0
client_print(id, print_chat, "%L", id, "PRESS_KEY")
emit_sound(id, CHAN_WEAPON, "items/gunpickup3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
public buy_bazooka_ammo(id){
if (!is_user_connected(id) || !is_user_alive(id) || !have_bazooka[id])
return PLUGIN_CONTINUE
if (Munni[id] >= get_pcvar_num(g_bazooka_ammo))
return PLUGIN_CONTINUE
if (get_pcvar_num(g_bazooka_buyzone))
if (!cs_get_user_buyzone(id)){
client_print(id, print_chat, "%L", id, "NOT_AT_BUYZONE_SHELL")
return PLUGIN_CONTINUE
}
if (!buy_in_time){
client_print(id,print_chat,"%L" , id, "NOT_BUY_TIME")
return PLUGIN_CONTINUE
}
//engclient_cmd(id,"primammo")
//engclient_cmd(id,"buyammo1")
new user_money = cs_get_user_money(id)
new bazooka_ammoprice = get_pcvar_num(g_bazooka_ammoprice)
if (user_money >= bazooka_ammoprice)
{
if (!buy_in_time)
return PLUGIN_CONTINUE
Create_StatusIcon(id, IconFlash, ICON_SPRITE, COLOR_R, COLOR_G, COLOR_B)
if ( task_exists(id) )
remove_task(id)
set_task(1.5, "Clear_Icons", id)
Munni[id]++
cs_set_user_money(id,user_money - bazooka_ammoprice)
new weaponid, clip, ammo
weaponid = get_user_weapon(id, clip, ammo)
if (weaponid == CSW_KNIFE)
ammo_hud(id, 1)
emit_sound(id, CHAN_WEAPON, "items/ammopickup1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
return PLUGIN_CONTINUE
}
public fire_rocket(id) {
if (Munni[id] <= 0) {
client_print(id,print_center, "%L", id, "NO_MORE_SHELL")
emit_sound(id, CHAN_WEAPON, "weapons/dryfire_rifle.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}
if (!CanShoot[id] && Munni[id] > 0){
client_print(id, print_center, "%L", id, "STILL_LOADING")
return PLUGIN_HANDLED
}
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, BZK_CLASSNAME)
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)
entity_set_int(RocketEnt, EV_INT_team, bzk_rocket)
new Float:Velocity[3]
new myvelocity = get_pcvar_num(g_bazooka_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)
new CsTeams:iTeam =cs_get_user_team(id)
new trailtime =get_pcvar_num(g_bazooka_trailtime)
new colorr =random_num(0,255)
new colorg =random_num(0,255)
new colorb =random_num(0,255)
if (get_pcvar_num(g_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 { // 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(255)
message_end()
}
if ((get_pcvar_num(g_bazooka_normal) || get_pcvar_num(g_bazooka_arena)) && !has_bazooka_adminsuper(id))
{
if (mode[id] != 0)
return_normalmode(id)
}
else
{
if (mode[id] == 1) { // 热寻导模式
new info[1]
info[0] = RocketEnt
set_task(get_pcvar_float(g_bazooka_heatskdelay), "find_and_follow", 0, info, 1)
}
else if (mode[id] == 2) { // 用户导航模式
entity_set_int(RocketEnt, EV_INT_rendermode, 1)
attach_view(id, RocketEnt)
user_controll[id] = RocketEnt
}
}
if (get_pcvar_num(g_bazooka_arena) != 1 && !(has_bazooka_adminsuper(id) && get_pcvar_num(g_bazooka_adminunlimitammo))) {
Munni[id]--
}
CanShoot[id] = false
if (Munni[id] == 0)
client_print(id,print_center,"%L", id, "NO_MORE_SHELL")
else
client_print(id,print_center,"%L", id,"STILL_LOADING")
new data[1]
data[0] = id
set_task(has_bazooka_adminsuper(id) ? 0.5 * get_pcvar_float(g_bazooka_reloadtime) : get_pcvar_float(g_bazooka_reloadtime), "bazooka_reload", id+9477, data, 1)
ammo_hud(id, 0)
data[0] = RocketEnt
set_task(has_bazooka_adminsuper(id) ? 1.5 * get_pcvar_float(g_bazooka_time) : get_pcvar_float(g_bazooka_time), "detonate_rocket", id+8356, data, 1)
return PLUGIN_HANDLED
}
public bazooka_reload(data[]) {
if (is_user_alive(data[0]) && have_bazooka[data[0]]){
if (Munni[data[0]] != 0)
client_print(data[0],print_center,"%L", data[0], "FINISH_LOADING")
CanShoot[data[0]] = true
ammo_hud(data[0], 1)
}
}
public detonate_rocket(data[]) {
if (is_valid_ent(data[0]))
bzk_touch(data[0], 0)
}
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, owner, owner_team
get_players(players, count)
owner = entity_get_edict(RocketEnt, EV_ENT_owner)
owner_team = get_user_team(owner)
for (new i = 0; i < count; i++) {
if (is_user_alive(players) && owner != players && get_user_team(players) != owner_team) {
new Float:PlayerOrigin[3], Float:RocketOrigin[3]
entity_get_vector(players, 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
}
}
}
}
if (nearestPlayer > 0) {
new data[2]
data[0] = RocketEnt
data[1] = nearestPlayer
set_task(0.1, "follow_and_catch", RocketEnt, data, 2, "b")
}
else {
bzk_touch(RocketEnt, 0)
}
}
public follow_and_catch(data[]) {
new RocketEnt = data[0]
new target = data[1]
new myvelocity = get_pcvar_num(g_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 bzk_touch(ptr, ptd) {
if (!is_valid_ent(ptr))
return PLUGIN_CONTINUE
new bzk_type = entity_get_int(ptr, EV_INT_team)
if (bzk_type == bzk_rocket) { // bazooka_rocket
new Float:EndOrigin[3]
entity_get_vector(ptr, EV_VEC_origin, EndOrigin)
new iOrigin[3]
FVecIVec(EndOrigin,iOrigin)
emit_sound(ptr, CHAN_WEAPON, "weapons/mortarhit.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(ptr, CHAN_VOICE, "weapons/mortarhit.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) // Feuerball 火球
write_byte(17)
write_coord(iOrigin[0])
write_coord(iOrigin[1])
write_coord(iOrigin[2] + 128)
write_short(explosion)
write_byte(60)
write_byte(255)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) // Rauchwolke 烟云效果
write_byte(5)
write_coord(iOrigin[0])
write_coord(iOrigin[1])
write_coord(iOrigin[2] + 256)
write_short(smoke)
write_byte(125)
write_byte(5)
message_end()
new maxdamage = get_pcvar_num(g_bazooka_maxdamage)
new damageradius = get_pcvar_num(g_bazooka_arena) ? ARENA_DAMAGERADIUS : get_pcvar_num(g_bazooka_damageradius)
new friendlyfire = get_cvar_num("mp_friendlyfire")
new PlayerPos[3], distance, damage
new num
new players[32]
new victim
new frikillsum = 0
new attacker = entity_get_edict(ptr, EV_ENT_owner)
new attacker_team = get_user_team(attacker)
get_players(players, num, "a")
for (new j = 0; j < num; j++) {
victim = players[j]
get_user_origin(victim, PlayerPos)
distance = get_distance(PlayerPos, iOrigin)
if (distance <= damageradius) { // Schadensradius
message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, victim) // Schteln 屏幕抖动效果
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))))
if (get_user_godmode(victim))
continue
new newHealth = get_user_health(victim) - damage
if (newHealth <= 0) {
if (attacker == victim ) {
if (!friendlyfire && has_bazooka_adminsuper(victim))
continue
user_kill(victim, 1)
continue
}
else if (attacker_team == get_user_team(victim)) {
if ( !friendlyfire )
continue
frikillsum ++
client_print(attacker, print_chat, "%L", attacker, "KILL_TEAMMATE")
}
set_msg_block(g_msgDeathMsg, BLOCK_ONCE)
set_user_health(victim, newHealth)
message_begin(MSG_ALL, g_msgDeathMsg, {0, 0, 0} ,0)
write_byte(attacker)
write_byte(victim)
write_byte(0)
write_string("bazooka")
message_end()
update_info(attacker, victim)
}
else {
if ( attacker_team == get_user_team(victim) && attacker != victim)
{
if ( !friendlyfire )
continue
client_print(attacker, print_chat, "%L", attacker,"INJURE_TEAMMATE")
}
if (attacker == victim && !friendlyfire && has_bazooka_adminsuper(victim))
continue
set_user_health(victim, newHealth)
}
}
}
if (frikillsum > 0){
server_cmd("amx_pcheater #%i %i", get_user_userid(attacker), (frikillsum * 2))
server_exec()
}
message_begin(MSG_ALL, SVC_TEMPENTITY, iOrigin)
write_byte(21)
write_coord(iOrigin[0])
write_coord(iOrigin[1])
write_coord(iOrigin[2])
write_coord(iOrigin[0])
write_coord(iOrigin[1])
write_coord(iOrigin[2]+damageradius)
write_short(white)
write_byte(0)
write_byte(1)
write_byte(6)
write_byte(8)
write_byte(1)
write_byte(255)
write_byte(255)
write_byte(192)
write_byte(128)
write_byte(5)
message_end()
new classname2[32]
if ((ptd > 0) && is_valid_ent(ptd)){
entity_get_string(ptd,EV_SZ_classname,classname2,31)
if(equal(classname2,"func_breakable"))
force_use(ptr,ptd)
}
attach_view(attacker, attacker)
user_controll[attacker] = 0
if (task_exists(attacker + 8356))
remove_task(attacker + 8356)
remove_entity(ptr)
}
else if (bzk_type == bzk_droped) { // bazooka_droped
new Picker[32]
if (is_valid_ent(ptd)) {
entity_get_string(ptd, EV_SZ_classname, Picker, 31)
}
if (equal(Picker, "player") ) {
if(!have_bazooka[ptd])
{
Munni[ptd] = entity_get_int(ptr, EV_INT_iuser1)
CanShoot[ptd] = true
have_bazooka[ptd] = true
Create_StatusIcon(ptd, IconShow, ICON_SPRITE, COLOR_R, COLOR_G, COLOR_B)
set_task(ICON_SHOWTIME, "Clear_Icons", ptd)
remove_entity(ptr)
client_print(ptd, print_center, "%L", ptd, "PICK_UP")
client_print(ptd, print_chat, "%L", ptd, "PRESS_KEY")
mode[ptd] = 0
user_controll[ptd] = 0
emit_sound(ptd, CHAN_WEAPON, "items/gunpickup3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
check_model(ptd)
}
}
}
return PLUGIN_CONTINUE
}
update_info(killer_id, victim_id)
{
new victim_frags, killer_frags, victim_deaths, killer_deaths, victim_team, killer_team
new killer_money = cs_get_user_money(killer_id)
victim_team = get_user_team(victim_id)
killer_team = get_user_team(killer_id)
if (killer_team != victim_team){
killer_frags = get_user_frags(killer_id) + 1
killer_money = killer_money + 300
}
else {
killer_frags = get_user_frags(killer_id) - 1
killer_money = killer_money - 300
}
if (killer_money > 16000)
killer_money = 16000
if (killer_money < 0)
killer_money = 0
cs_set_user_money(killer_id, killer_money)
victim_frags = get_user_frags(victim_id) + 1
victim_deaths = get_user_deaths(victim_id)
killer_deaths = get_user_deaths(killer_id)
set_user_frags(victim_id, victim_frags)
set_user_frags(killer_id, killer_frags )
Create_ScoreInfo(victim_id, victim_frags, victim_deaths, 0, victim_team)
Create_ScoreInfo(killer_id, killer_frags, killer_deaths, 0, killer_team)
}
Create_ScoreInfo(id, frags, deaths, playerClass, team ) {
message_begin(MSG_ALL,gmsgScoreInfo)
write_byte(id)
write_short(frags)
write_short(deaths)
write_short(playerClass)
write_short(team)
message_end()
}
public drop_rpg(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) {
return PLUGIN_HANDLED
}
if(g_bazooka_nums >= get_pcvar_num(g_bazooka_num) && !get_pcvar_num(g_bazooka_arena)){
client_print(id,print_chat,"%L", id, "TO_LIMIT", g_bazooka_nums)
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, BZK_CLASSNAME)
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)
new ammo = get_pcvar_num(g_bazooka_ammo)
if (ammo > 2) // 初始最多给两枚火箭弹
ammo = 2
entity_set_int(RPG, EV_INT_iuser1, ammo)
entity_set_int(RPG, EV_INT_team, bzk_droped)
g_bazooka_nums++
return PLUGIN_HANDLED
}
public start_bazooka_arena(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) {
return PLUGIN_HANDLED
}
set_pcvar_num(g_bazooka_arena, 1)
new players[32], plNum, i
get_players(players, plNum, "a")
for (; i < plNum; ++i) {
if (!have_bazooka[players])
player_get_bozooka(players)
}
return PLUGIN_HANDLED
}
public end_bazooka_arena(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) {
return PLUGIN_HANDLED
}
set_pcvar_num(g_bazooka_arena, 0)
new players[32], plNum, i
get_players(players, plNum, "a")
for (; i < plNum; ++i) {
if (have_bazooka[players]) {
have_bazooka[players] = false
check_model(players)
}
}
return PLUGIN_HANDLED
}
public return_normalmode(id)
{
mode[id] = 0
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "%L", id, "NORMAL_MODE")
ammo_hud(id, 1)
}
public client_PreThink(id)
{
if (is_user_alive(id) && have_bazooka[id])
{
new weaponid, clip, ammo
weaponid = get_user_weapon(id, clip, ammo)
if (weaponid == CSW_KNIFE)
{
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
if (attack && !oldattack)
{
if (CanShoot[id]) {
fire_rocket(id)
}
}
else if (attack2 && !oldattack2)
{
if ((get_pcvar_num(g_bazooka_normal) || get_pcvar_num(g_bazooka_arena)) && !has_bazooka_adminsuper(id))
{
if (mode[id] != 0)
return_normalmode(id)
}
else
{
switch(mode[id])
{
case 0:
{
mode[id] = 1
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, "%L", id, "HEAT_SEEK_MODE")
}
case 1:
{
mode[id] = 2
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, "%L", id, "USER_GUIDED_MODE")
}
case 2:
{
mode[id] = 0
emit_sound(id, CHAN_ITEM, "common/wpn_select.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "%L", id, "NORMAL_MODE")
}
}
}
ammo_hud(id, 1)
}
if (user_controll[id] > 0) // 用户导航
{
new RocketEnt = user_controll[id]
if (is_valid_ent(RocketEnt)) {
new Float:Velocity[3]
new myvelocity = floatround(PER_VELOCITY_USER_GUIDED * get_pcvar_num(g_bazooka_velocity))
VelocityByAim(id, myvelocity, 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 {
user_controll[id] = 0
attach_view(id, id)
}
}
}
else
{
if (user_controll[id] > 0)
{
user_controll[id] = 0
attach_view(id, id)
}
}
}
return FMRES_IGNORED
}
public change_weapon(id) {
new iWpnNum = read_data(2)
if (iWpnNum != gWpnUsed[id]) {
gWpnUsed[id] = iWpnNum
check_model(id)
}
return PLUGIN_CONTINUE
}
public player_spawn(id) {
if (get_pcvar_num(g_bazooka_arena) && !have_bazooka[id])
player_get_bozooka(id)
set_task(0.1, "check_model", id)
return PLUGIN_CONTINUE
}
public check_model(id) {
if (!is_user_alive(id))
return PLUGIN_CONTINUE
new weaponid, clip, ammo
weaponid = get_user_weapon(id, clip, ammo)
if (weaponid == CSW_KNIFE && have_bazooka[id]) {
ammo_hud(id, 1)
entity_set_string(id, EV_SZ_viewmodel, "models/v_rpg.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_rpg.mdl")
emit_sound(id, CHAN_WEAPON, "items/gunpickup3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
if ( !CanShoot[id] ){
new data[1]
data[0] = id
set_task(get_pcvar_float(g_bazooka_reloadtime), "bazooka_reload", id+9477, data, 1)
}
}
else {
new with_shield
if (g_shield) {
if (cs_get_user_shield(id))
with_shield = 1
}
switch (weaponid) {
case CSW_HEGRENADE: {
if (with_shield) {
entity_set_string(id, EV_SZ_viewmodel, "models/shield/v_shield_hegrenade.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/shield/p_shield_hegrenade.mdl")
}
else {
entity_set_string(id, EV_SZ_viewmodel, "models/v_hegrenade.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_hegrenade.mdl")
}
}
case CSW_FLASHBANG: {
if (with_shield) {
entity_set_string(id, EV_SZ_viewmodel, "models/shield/v_shield_flashbang.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/shield/p_shield_flashbang.mdl")
}
else {
entity_set_string(id, EV_SZ_viewmodel, "models/v_flashbang.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_flashbang.mdl")
}
}
case CSW_SMOKEGRENADE: {
if (with_shield) {
entity_set_string(id, EV_SZ_viewmodel, "models/shield/v_shield_smokegrenade.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/shield/p_shield_smokegrenade.mdl")
}
else {
entity_set_string(id, EV_SZ_viewmodel, "models/v_smokegrenade.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_smokegrenade.mdl")
}
}
case CSW_C4: {
entity_set_string(id, EV_SZ_viewmodel, "models/v_c4.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_c4.mdl")
}
case CSW_KNIFE: {
if (with_shield) {
entity_set_string(id, EV_SZ_viewmodel, "models/shield/v_shield_knife.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/shield/p_shield_knife.mdl")
}
else {
entity_set_string(id, EV_SZ_viewmodel, "models/v_knife.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_knife.mdl")
}
}
}
if (have_bazooka[id])
ammo_hud(id, 0)
if (task_exists(id+9477)){
remove_task(id+9477)
client_print(id,print_center,"")
}
}
return PLUGIN_CONTINUE
}
public client_connect(id) {
have_bazooka[id] = false
CanShoot[id] = false
Munni[id] = 0
mode[id] = 0
user_controll[id] = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id) {
if (have_bazooka[id])
g_bazooka_nums--
return PLUGIN_CONTINUE
}
ammo_hud(id, show) {
new AmmoHud[64]
switch (mode[id])
{
case 0: format(AmmoHud, 63, "%L", id, "STATUS_NORMAL" , Munni[id])
case 1: format(AmmoHud, 63, "%L", id, "STATUS_HEAT_SEEKING" , Munni[id])
case 2: format(AmmoHud, 63, "%L", id, "STATUS_USER_GUIDED" , Munni[id])
}
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()
}
}
public player_die() {
new victim
victim = read_data(2)
ammo_hud(victim, 0)
if (have_bazooka[victim] && !get_pcvar_num(g_bazooka_arena))
drop_rpg_from_player(victim)
}
public on_RoundRestart(){
if (task_exists(9476))
remove_task(9476)
for(new i=0; i<33; i++)
{
have_bazooka = false
CanShoot = false
}
in_freezetime = true
return PLUGIN_CONTINUE
}
public cant_buy(){
buy_in_time = false
}
public new_round() {
if ((read_data(1) == (get_cvar_num("mp_freezetime"))) && in_freezetime)
{
if (task_exists(9476))
remove_task(9476)
buy_in_time = true
g_bazooka_nums = 0
new TempRPG = find_ent_by_class(-1, BZK_CLASSNAME)
while (is_valid_ent(TempRPG)) {
remove_entity(TempRPG)
TempRPG = find_ent_by_class(TempRPG, BZK_CLASSNAME)
}
new pln,plid[32]
get_players(plid,pln,"")
for (new i=0; i < pln; i++){
if (task_exists(plid + 8356))
remove_task(plid + 8356)
if (have_bazooka[plid])
g_bazooka_nums++
}
}
return PLUGIN_CONTINUE
}
public freezetimecomplete()
{
buy_in_time = true
in_freezetime = false
if (get_pcvar_num(g_bazooka_buytime))
set_task(get_cvar_float("mp_buytime")*60.0,"cant_buy",9476)
for (new i=1; i<33; i++)
{
if (have_bazooka)
CanShoot = true
}
}
public EndRound()
{
set_task(4.8, "round_prestart")
}
public round_prestart() {
in_freezetime = true
for (new i=1; i<33; i++)
{
CanShoot = false
}
}
public handle_drop(id) {
new weaponid, clip, ammo
weaponid = get_user_weapon(id, clip, ammo)
if (weaponid == CSW_KNIFE && have_bazooka[id]) {
if (get_pcvar_num(g_bazooka_drop) == 1) {
if (user_controll[id] > 0)
{
user_controll[id] = 0
attach_view(id, id)
}
drop_rpg_from_player(id)
}
else {
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
public drop_rpg_from_player(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, 96, 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, BZK_CLASSNAME)
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])
entity_set_int(RPG, EV_INT_team, bzk_droped)
Munni[id] = 0
have_bazooka[id] = false
entity_set_string(id, EV_SZ_viewmodel, "models/v_knife.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_knife.mdl")
ammo_hud(id, 0)
return PLUGIN_CONTINUE
}
public on_Damage(victim){
if ( victim < 1 || victim > 32 )
return PLUGIN_CONTINUE
if (!have_bazooka[victim] || get_pcvar_num(g_bazooka_arena))
return PLUGIN_CONTINUE
new wpnindex = 0, hitplace = 0, attacker = get_user_attacker(victim,wpnindex,hitplace)
new damage = read_data(2)
call_damage(victim, attacker, damage, wpnindex, hitplace)
return PLUGIN_CONTINUE
}
public call_damage(victim, attacker, damage, wpnindex, hitplace){
new inflictor = entity_get_edict(victim, EV_ENT_dmg_inflictor)
// Check to see if the damage was from the bomb
if(wpnindex != 4 && attacker != victim && inflictor > 0 ){
if ( is_valid_ent ( inflictor ) )
{
new szClassName[64]
entity_get_string(inflictor, EV_SZ_classname, szClassName, 63)
// Technically I don't think we need to check the classname, but just in case
if ( equali(szClassName, "grenade") || equali(szClassName, "env_explosion") ){
// We need to call the death function manually b/c DeathMsg isn't broadcasted when the bomb explodes and kills someone
if (get_user_health(victim) - damage < 0 ){
drop_rpg_from_player(victim)
}
}
}
}
return PLUGIN_CONTINUE
}
public Clear_Icons(id) {
Create_StatusIcon(id, IconHide, ICON_SPRITE, 0, 0, 0)
}
stock entity_set_follow(entity, target, Float:speed) {
if (!is_valid_ent(entity) || !is_valid_ent(target)) return 0
new Float:entity_origin[3], Float:target_origin[3]
entity_get_vector(entity, EV_VEC_origin, entity_origin)
entity_get_vector(target, EV_VEC_origin, target_origin)
new Float:diff[3]
diff[0] = target_origin[0] - entity_origin[0]
diff[1] = target_origin[1] - entity_origin[1]
diff[2] = target_origin[2] - entity_origin[2]
new Float:length = floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))
new Float:Velocity[3]
Velocity[0] = diff[0] * (speed / length)
Velocity[1] = diff[1] * (speed / length)
Velocity[2] = diff[2] * (speed / length)
entity_set_vector(entity, EV_VEC_velocity, Velocity)
return 1
}
stock Create_StatusIcon(id, status, sprite[], red, green, blue){
message_begin( MSG_ONE, g_msgStatusIcon , {0,0,0}, id )
write_byte( status ) // status 0 - hide, 1 - show, 2 - flash
write_string( sprite ) // sprite name >>"dmg_rad","item_longjump","dmg_shock","item_healthkit","dmg_heat","suit_full","cross","dmg_gas"
write_byte( red ) // red
write_byte( green ) // green
write_byte( blue ) // blue
message_end()
}
stock has_bazooka_adminsuper(id) {
return get_user_flags(id) & ADMIN_IMMUNITY && get_pcvar_num(g_bazooka_adminsuper)
} |
|