xuqiang52133
|
分享:
▼
x0
|
[1.6][插件] 坦克插件实体出现问题。变身的时候卡在地下了,而且炮弹发射的时候爆炸在原地,炮弹打不出去。求高手帮忙。谢谢了,
这个是坦克插件。坦克插件实体出现问题。变身的时候卡在地下了,而且炮弹发射的时候爆炸在原地,炮弹打不出去。求高手帮忙。谢谢了。 有源码。。。。。。。。。。。。。。。。谢谢
希望关注一下我这个文章。谢谢
#include <amxmodx> #include <fakemeta> #include <fun> #include <engine> #include <HamSandwich> #include <CSModTank_Native> //#include <CSMod_Core>
#define HEAD_POSITION 8 #define DESIRED_DISTANCE 0 // Change this to whatever.
#define TASK_ROCKET 6740100 #define TASK_BOMB 6760200 #define MaxWeaponCarray 12
// 坦克最大行进速度 new Float:g_TankSpeed = 200.0
new g_TankMDL[] = "models/player/tankII/tankII.mdl" new g_TankMDL2[] = "models/tank2.mdl"
new Float:g_TankMaxHP=1000.0 new Float:g_TankMaxAR=512.0
new TankEnt[33] new bool:BuyTankDone[33] new g_WeaponBack[33][MaxWeaponCarray][64]
//new laserbeam new smoke,boom new bool:wait_rocket[33], bool:wait_bomb[33]
#define BAR_SIZE 20 new gBar[] = "¤¤¤¤¤¤¤¤¤¤"
new bool:LoadStatus[33] = false new Float:Damage_L = 50.0 new Float:Damage_R = 200.0 new Float:Damage_S = 300.0 new Float:Radius_R = 300.0 new Float:Radius_S = 300.0
public plugin_init() { register_plugin("CrazyTanker", "1.0.1121", "Cool.Cat")
register_forward( FM_PlayerPreThink, "Forward_PreThink" ) register_forward(FM_PlayerPreThink, "Forward_PreThink_Post", 1) register_event("CurWeapon", "SwitchWeapon", "be", "1=1") register_event("DeathMsg", "death_event", "a") register_event("ResetHUD", "resethud_event", "be")
register_think("CSMod_Tank","Tank_Think") RegisterHam(Ham_Killed,"info_target","TargetKilled") register_clcmd("buy_tank", "BuyTank") // register_clcmd("ViewLess", "ViewLess") // register_clcmd("ViewAdd", "ViewAdd") }
//public client_connect(id) //{ // WriteCSID(id,"中文CSID测试通过~") //}
public plugin_precache() { precache_model(g_TankMDL) precache_model(g_TankMDL2) precache_model("models/rpgrocket.mdl") precache_model("models/shell.mdl") //laserbeam = precache_model("sprites/laserbeam.spr") smoke = precache_model("sprites/smoke.spr") boom = precache_model("sprites/zerogxplode.spr") precache_sound("vox/_period.wav") precache_sound("weapons/rocketfire1.wav") precache_sound("weapons/m249-1.wav") precache_sound("CSMod/ap_rotor2.wav") register_cvar("Damage_L","50.0") register_cvar("Damage_R","200.0") register_cvar("Damage_S","300.0") register_cvar("Radius_R","300.0") register_cvar("Radius_S","300.0") }
public plugin_natives() { register_native("HumanBuyTank", "BuyTank",1) register_native("SetTankDamage", "_SetTankDamage") register_native("SetTankRadius","_SetTankRadius") }
public _SetTankDamage(Float:pDamage_L,Float:pDamage_R,Float:pDamage_S) { Damage_L = pDamage_L Damage_R = pDamage_R Damage_S = pDamage_S set_cvar_float("Damage_L",Damage_L) set_cvar_float("Damage_R",Damage_R) set_cvar_float("Damage_S",Damage_S) }
public _SetTankRadius(Float:pRadius_R,Float:pRadius_S) { Radius_R = pRadius_R Radius_S = pRadius_S
set_cvar_float("Radius_R",Radius_R) set_cvar_float("Radius_S",Radius_S) }
public client_putinserver(id) { set_task(30.0, "bind_key", id,"",0,"b") return PLUGIN_CONTINUE }
public bind_key(id) { client_cmd(id, "bind p buy_tank") switch (random_num(0,3)) { case 0: client_color(id, id, "^x04【提示】^x01按 ^x03P^x01 键购买坦克") case 1: client_color(id, id, "^x04【提示】^x01按 ^x03R^x01 键实施坦克自爆") case 2: client_color(id, id, "^x04【提示】^x01更多特色插件,请访问 ^x04www.CSMod.com^x01 游戏社区") case 3: client_color(id, id, "^x04【提示】^x01坦克操作:^x04左键^x01 使用机枪,^x04右键^x01 发射导弹") } }
public client_color(playerid,colorid,msg[]) { message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid) write_byte(colorid) write_string(msg) message_end() }
public client_disconnect(id) { if (is_valid_ent(TankEnt[id]) && id==pev(TankEnt[id],pev_owner)) { set_user_footsteps(id,0) set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255) emit_sound(TankEnt[id], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) remove_entity(TankEnt[id]) TankEnt[id]=0 } wait_rocket[id] = false wait_bomb[id] = false LoadStatus[id] = false BuyTankDone[id] = false for (new p=0;p<MaxWeaponCarray;p++) copy(g_WeaponBack[id][p],63,"") }
public resethud_event(id) { if (is_valid_ent(TankEnt[id]) && id==pev(TankEnt[id],pev_owner)) { set_user_footsteps(id,0) set_pev(id,pev_gravity,0.0) set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255) emit_sound(TankEnt[id], CHAN_WEAPON, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) remove_entity(TankEnt[id]) TankEnt[id]=0 SendBack(id) give_item(id,"weapon_knife") engclient_cmd(id,"weapon_knife") set_user_godmode(id,0) } BuyTankDone[id] = false }
stock LoadPlayerLists(id,csid[]) { new a,pos = 0 new getinfo[33] new INI_path[256] = "addons\amxmodx\configs\TankUsers.ini" LoadStatus[id] = false if (file_exists(INI_path)) { while(read_file(INI_path,pos++,getinfo,32,a)) { if (getinfo[0]==';' || getinfo[0]=='*' || (getinfo[0]=='/' && getinfo[1]=='*')) continue // break
if (equali(getinfo,csid)) LoadStatus[id] = true } } else server_print("'%s' Not Exists!",INI_path) }
public BuyTank(id) { if(!is_user_alive(id)) { client_print(id, print_chat, "【坦克大战】 死亡状态无法驾驶坦克.") return PLUGIN_HANDLED } if(is_valid_ent(TankEnt[id]) && pev(TankEnt[id],pev_owner)>0 && pev(TankEnt[id],pev_owner)<33) { client_print(id, print_chat, "【坦克大战】 你已经购买坦克了.") return PLUGIN_HANDLED } if (get_user_team(id)!=1 && get_user_team(id)!=2) { client_print(id,print_chat,"【坦克大战】观察者无法购买坦克!") return PLUGIN_HANDLED } if (BuyTankDone[id]) { client_print(id,print_chat,"【坦克大战】本局你已经购买过坦克了!") return PLUGIN_HANDLED } if (TankEnt[id]) client_print(id,print_chat,"【坦克大战】你正在驾驶坦克!") else { BuyTankDone[id] = true new csid[32] get_user_name(id,csid,31) LoadPlayerLists(id,csid) // if (!LoadStatus[id]) // { // client_print(id,print_center,"对不起,你没有购买坦克的权限,请联系管理员购买!") // return PLUGIN_HANDLED // } BackWid(id) strip_user_weapons(id) // 自己第一视角看到的 set_pev(id, pev_viewmodel2, g_TankMDL2)
new data[1] data[0] = id set_task(0.1,"Create_Tank",0,data,1) set_pev(id,pev_maxspeed,g_TankSpeed) new name[32] get_user_name(id,name,31) client_print(id,print_chat,"【坦克大战】%s 购买了一辆坦克",name) } return PLUGIN_HANDLED }
public Create_Tank(data[]) { new id = data[0]
TankEnt[id] = create_entity("info_target") if(TankEnt[id] > 0) { entity_set_string(TankEnt[id], EV_SZ_classname, "CSMod_Tank") static Float:p_mins[3] , Float:p_maxs[3] p_mins = Float:{ -64.0,-64.0, -64.0 } p_maxs = Float:{ 64.0, 64.0, 64.0 } engfunc(EngFunc_SetSize, TankEnt[id], p_mins, p_maxs) set_pev(TankEnt[id], pev_mins, p_mins) set_pev(TankEnt[id], pev_maxs, p_maxs ) new Float:origin[3] new Float:angles[3] entity_get_vector(id, EV_VEC_origin, origin) entity_get_vector(id, EV_VEC_v_angle, angles) new Float:dist_origin[3] VelocityByAim(id, 100, dist_origin)
origin[0] -= dist_origin[0] origin[1] -= dist_origin[1] origin[2] += 50.0
entity_set_int(TankEnt[id], EV_INT_movetype, MOVETYPE_NOCLIP) entity_set_vector(TankEnt[id], EV_VEC_angles, angles) entity_set_origin(TankEnt[id], origin) entity_set_int(TankEnt[id], EV_INT_sequence, 1) entity_set_float(TankEnt[id],EV_FL_animtime,2.0) entity_set_float(TankEnt[id],EV_FL_framerate,1.0) entity_set_float(TankEnt[id], EV_FL_scale, 1.0)
set_task(0.01,"Show_Tank",0,data,1) } }
public Show_Tank(data[]) { new id = data[0] new Float:gSizeMin[] = {-32.0, -32.0, -4.0} new Float:gSizeMax[] = {32.0, 32.0, 4.0} // // entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE) // entity_set_vector(ent, EV_VEC_angles, vAngles) // entity_set_origin(ent, FLorigin) // // DispatchSpawn(ent) // // entity_set_model(ent, g_TankMDL) // entity_set_int(ent, EV_INT_solid, SOLID_BBOX) // entity_set_size(ent, gSizeMin, gSizeMax) entity_set_model(TankEnt[id], g_TankMDL) entity_set_int(TankEnt[id], EV_INT_solid, SOLID_BBOX) entity_set_size(TankEnt[id], Float:{-32.0, -32.0, -4.0}, Float:{32.0, 32.0, 4.0})
entity_set_edict(TankEnt[id], EV_ENT_owner, id) entity_set_float(TankEnt[id], EV_FL_takedamage, DAMAGE_AIM) entity_set_float(TankEnt[id], EV_FL_health, g_TankMaxHP) entity_set_float(TankEnt[id], EV_FL_armorvalue, g_TankMaxAR) set_rendering(TankEnt[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 255)
entity_set_float(TankEnt[id],EV_FL_nextthink,halflife_time() + 0.001) set_user_footsteps(id,1) set_user_godmode(id,1) set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,0) //entity_set_int(id, EV_INT_solid, SOLID_NOT) emit_sound(TankEnt[id], CHAN_VOICE, "CSMod/ap_rotor2.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) }
public client_PreThink(id) { if(is_user_alive(id)) { if (is_valid_ent(TankEnt[id])) { if (pev(TankEnt[id],pev_owner)!=id) { return PLUGIN_CONTINUE } new button = get_user_button(id) new Float:forigin[3],Float:angles[3], Float:velocity[3] entity_get_vector(TankEnt[id], EV_VEC_origin, forigin) entity_get_vector(TankEnt[id], EV_VEC_v_angle, angles) if(button & IN_ATTACK) { if (get_gametime() - entity_get_float(TankEnt[id], EV_FL_fuser2) < 0.1) return PLUGIN_CONTINUE entity_set_float(TankEnt[id], EV_FL_fuser2, get_gametime()) emit_sound(TankEnt[id], CHAN_WEAPON, "weapons/m249-1.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) new ent = create_entity("info_target") if(ent > 0) { entity_set_string(ent, EV_SZ_classname, "Tank_Bullet") entity_set_model(ent, "models/shell.mdl") entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0}) entity_set_origin(ent, forigin) entity_set_vector(ent, EV_VEC_angles, angles) entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER) entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY) entity_set_edict(ent, EV_ENT_owner, id) VelocityByAim(id, 1000, velocity) entity_set_vector(ent, EV_VEC_velocity, velocity) message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_BEAMFOLLOW) write_short(ent) write_short(smoke) write_byte(2) write_byte(1) write_byte(232) write_byte(166) write_byte(0) write_byte(128) message_end() } } if(button & IN_ATTACK2 && !wait_rocket[id]) { new ent = create_entity("info_target") if(ent > 0) { entity_set_string(ent, EV_SZ_classname, "Tank_Rocket") entity_set_model(ent, "models/rpgrocket.mdl") entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0}) entity_set_origin(ent, forigin) entity_set_vector(ent, EV_VEC_angles, angles) entity_set_int(ent, EV_INT_effects, 64) entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER) entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY) entity_set_edict(ent, EV_ENT_owner, id) VelocityByAim(id, 1000, velocity) velocity[2] += 100.0; entity_set_vector(ent, EV_VEC_velocity, velocity) message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_BEAMFOLLOW) write_short(ent) write_short(smoke) write_byte(25) write_byte(1) write_byte(255) write_byte(255) write_byte(255) write_byte(128) message_end() message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_BEAMFOLLOW) write_short(ent) write_short(smoke) write_byte(40) write_byte(4) write_byte(255) write_byte(0) write_byte(0) write_byte(128) message_end() emit_sound(ent, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) //emit_sound(ent, CHAN_VOICE, "weapons/rocket1.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) } wait_rocket[id] = true set_task(2.0, "reset_rocket", id+TASK_ROCKET) } if(button & IN_RELOAD && !wait_bomb[id]) { new ent = create_entity("info_target") if(ent > 0) { entity_set_string(ent, EV_SZ_classname, "Tank_Bomb") entity_set_model(ent, "models/rpgrocket.mdl") entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0}) entity_set_origin(ent, forigin) entity_set_vector(ent, EV_VEC_angles, angles) entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER) entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS) entity_set_edict(ent, EV_ENT_owner, id) } wait_bomb[id] = true set_task(4.0, "reset_bomb", id+TASK_BOMB) }
// // 红外线标准 // new Float:end_origin[3],Float:aim_origin[3] // VelocityByAim(id, 9999, velocity) // end_origin[0] = forigin[0] + velocity[0] // end_origin[1] = forigin[1] + velocity[1] // end_origin[2] = forigin[2] + velocity[2] // trace_line(0, forigin, end_origin, aim_origin) // message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0,0,0}, id) // write_byte(1) // write_short(TankEnt[id]) // write_coord(floatround(aim_origin[0])) // write_coord(floatround(aim_origin[1])) // write_coord(floatround(aim_origin[2])) // write_short(laserbeam) // write_byte(1) // write_byte(1) // write_byte(1) // write_byte(8) // write_byte(0) // write_byte(255) // write_byte(0) // write_byte(0) // write_byte(128) // write_byte(0) // message_end() new health_percent = floatround(entity_get_float(TankEnt[id], EV_FL_health) * 100 / g_TankMaxHP) set_hudmessage( 255 - health_percent * 2, health_percent * 2, 0, -2.0, 0.76, 0, 1.0, 1.0, 0.0, 0.0, 4 ) show_hudmessage( id, "坦克HP: %i AR:%i^n%s", floatround(entity_get_float(TankEnt[id], EV_FL_health)),floatround(entity_get_float(TankEnt[id], EV_FL_armorvalue)),gBar[ min( BAR_SIZE-1, BAR_SIZE - floatround((health_percent / 100.0) * BAR_SIZE)) ]) } } return PLUGIN_CONTINUE }
public reset_rocket(id) { wait_rocket[id-TASK_ROCKET] = false }
public reset_bomb(id) { wait_bomb[id-TASK_BOMB] = false }
public Tank_Think(TankID) { if (is_valid_ent(TankID)) { new id = pev(TankID,pev_owner) if( !is_user_alive(id)) { remove_entity(TankEnt[id]) return PLUGIN_CONTINUE } else { new Float:origin[3] entity_get_vector( id, EV_VEC_origin, origin ) entity_set_origin( TankID, origin ) new Float:v_angle[3] entity_get_vector( id, EV_VEC_v_angle, v_angle ) v_angle[0] = 0.0 v_angle[2] = 0.0 entity_set_vector( TankID, EV_VEC_angles, v_angle )
entity_set_float(TankID,EV_FL_nextthink,halflife_time() + 0.001) } } return PLUGIN_HANDLED }
//public ViewLess(id) //{ // new Float:ofs[3] // pev(id, pev_view_ofs, ofs) // ofs[2] -= 8.0 // set_pev(id, pev_view_ofs, ofs) // return 1 //} // //public ViewAdd(id) //{ // new Float:ofs[3] // pev(id, pev_view_ofs, ofs) // ofs[2] += 8.0 // set_pev(id, pev_view_ofs, ofs) // return 1 //}
public death_event() { new id = read_data(2) if (is_valid_ent(TankEnt[id]) && id==pev(TankEnt[id],pev_owner)) { new id = pev(TankEnt[id],pev_owner) set_user_footsteps(id,0) set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255) emit_sound(TankEnt[id], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) remove_entity(TankEnt[id]) TankEnt[id]=0 set_user_godmode(id,0) } }
stock TurnWeaponString(wid,rdata[],rlen) { switch (wid) { case 0:copy(rdata,rlen,"weapon_knife") case 17:copy(rdata,rlen,"weapon_glock18") case 16:copy(rdata,rlen,"weapon_usp") case 1:copy(rdata,rlen,"weapon_p228") case 26:copy(rdata,rlen,"weapon_deagle") case 10:copy(rdata,rlen,"weapon_elite") case 11:copy(rdata,rlen,"weapon_fiveseven") case 21:copy(rdata,rlen,"weapon_m3") case 5:copy(rdata,rlen,"weapon_xm1014") case 7:copy(rdata,rlen,"weapon_mac10") case 23:copy(rdata,rlen,"weapon_tmp") case 19:copy(rdata,rlen,"weapon_mp5navy") case 12:copy(rdata,rlen,"weapon_ump45") case 30:copy(rdata,rlen,"weapon_p90") case 14:copy(rdata,rlen,"weapon_galil") case 15:copy(rdata,rlen,"weapon_famas") case 28:copy(rdata,rlen,"weapon_ak47") case 3:copy(rdata,rlen,"weapon_scout") case 22:copy(rdata,rlen,"weapon_m4a1") case 27:copy(rdata,rlen,"weapon_sg552") case 8:copy(rdata,rlen,"weapon_aug") case 13:copy(rdata,rlen,"weapon_sg550") case 18:copy(rdata,rlen,"weapon_awp") case 24:copy(rdata,rlen,"weapon_g3sg1") case 20:copy(rdata,rlen,"weapon_m249") } }
stock SendBack(id) { new rdata[64] for (new p=0;p<MaxWeaponCarray;p++) { copy(rdata,63,"") TurnWeaponString(str_to_num(g_WeaponBack[id][p]),rdata,63) //server_print("%d->%s",str_to_num(g_WeaponBack[id][p]),rdata) give_item(id,rdata) } }
stock BackWid(id) { new Weapons[32],weapon[32] new numWeapons = 0 get_user_weapons(id, Weapons, numWeapons) for (new j=0; j<MaxWeaponCarray; j++) { copy(g_WeaponBack[id][j],63,"") } for (new j=0; j<numWeapons; j++) { format(weapon,31,"%d",Weapons[j])
copy(g_WeaponBack[id][j],63,weapon) } }
public SwitchWeapon(id) { if ( !BuyTankDone[id] ) BuyTank(id);
if(TankEnt[id] && pev_valid(TankEnt[id])) { if (pev(TankEnt[id],pev_owner)==id) { set_pev(id,pev_viewmodel2, g_TankMDL2) set_pev(id,pev_maxspeed,g_TankSpeed) } } return PLUGIN_CONTINUE }
public Forward_PreThink(id) { if (is_user_alive(id)) { if (is_valid_ent(TankEnt[id])) { if (TankEnt[id] && id==pev(TankEnt[id],pev_owner)) { if (pev(id, pev_button) & IN_DUCK) { set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons) | IN_DUCK) return FMRES_HANDLED } if (pev(id, pev_button) & IN_JUMP) { set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons) | IN_JUMP) //ExecuteHamB(Ham_Player_Jump, id) return FMRES_HANDLED } // else // { // set_pev(id,pev_gravity,800.0) // } } } } return FMRES_IGNORED }
public Forward_PreThink_Post(id) { if (is_user_alive(id)) { if (is_valid_ent(TankEnt[id])) { if (TankEnt[id] && id==pev(TankEnt[id],pev_owner)) { if (pev(id, pev_button) & IN_DUCK) { set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons) | IN_DUCK) return FMRES_IGNORED } if (pev(id, pev_button) & IN_JUMP) { set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons) | IN_JUMP) //ExecuteHamB(Ham_Player_Jump, id) return FMRES_IGNORED } else { set_pev(id,pev_gravity,800.0) } } } } return FMRES_HANDLED }
public pfn_touch(entity1, entity2) { if(entity1 > 0 && is_valid_ent(entity1)) { new classname[32] entity_get_string(entity1, EV_SZ_classname, classname, 31) new classname2[32] if(entity2 > 0 && is_valid_ent(entity2)) { entity_get_string(entity2, EV_SZ_classname, classname2, 31) } new attacker = entity_get_edict(entity1, EV_ENT_owner) if((equal(classname, "Tank_Rocket") || equal(classname, "Tank_Bomb")) && (entity2 == 0 || equal(classname2, "player") || equal(classname2, "CSMod_Tank") || equal(classname2, "Tank_Rocket") || equal(classname2, "func_breakable") || equal(classname2, "func_pushable")) ) { if(entity2 > 0) { new tid = entity_get_edict(entity2, EV_ENT_owner) if(attacker == tid) { return PLUGIN_CONTINUE } else if (tid>0 && tid<33) { new name1[32] new name2[32] get_user_name(attacker,name1,31) get_user_name(tid,name2,31)
if (get_user_team(attacker) != get_user_team(tid)) { if (random_num(0,1)) client_print(0, print_chat, "【坦克大战】 %s 踩到狗屎运,自爆的坦克炸到了敌人 %s ...",name1,name2) else client_print(0, print_chat, "【坦克大战】 %s 眼睛长屁股上了,竟然撞到了敌人 %s 正在自爆的坦克上 ...",name2,name1) } } } new Float:explosion[3] entity_get_vector(entity1, EV_VEC_origin, explosion) // 右键 if (equal(classname, "Tank_Rocket")) HL_RadiusDamage(0,explosion,attacker,0,Damage_R,Radius_R) // R键 else if (equal(classname, "Tank_Bomb")) HL_RadiusDamage(1,explosion,attacker,0,Damage_S,Radius_S) message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(3) write_coord(floatround(explosion[0])) write_coord(floatround(explosion[1])) write_coord(floatround(explosion[2])) write_short(boom) write_byte(50) write_byte(15) write_byte(0) message_end() emit_sound(entity1, CHAN_WEAPON, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM) remove_entity(entity1) } else if(equal(classname, "Tank_Bullet")) { if(equal(classname2, "player") || equal(classname2, "CSMod_Tank") || equal(classname2, "func_breakable") || equal(classname2, "func_pushable")) { if(entity2 > 0) { if(attacker == entity_get_edict(entity2, EV_ENT_owner)) return PLUGIN_CONTINUE
new ateam=get_user_team(attacker) new oteam=get_user_team(entity2)
if(equal(classname2, "func_breakable") || equal(classname2, "func_pushable")) { force_use(entity2, attacker) } else if (ateam!=oteam) { new Float:origin[3] entity_get_vector(entity2, EV_VEC_origin, origin)
if (pev(entity2,pev_health)<=Damage_L) ExecuteHamB(Ham_Killed, entity2, attacker, 0) else fakedamage(entity2, "Tank_Gun", Damage_L, DMG_BULLET) } } } remove_entity(entity1) } } return PLUGIN_CONTINUE }
public HL_RadiusDamage(DamageType, Float:vecSrc[3], pevAttacker, pevInflictor, Float:flDamage, Float:flRadius/*, iClassIgnore, bitsDamageType*/ ) { new pEntity; new tr; new Float:flAdjustedDamage, Float:falloff; new Float:vecSpot[3]; // NEW new Float:vecAbsMin[3], Float:vecAbsMax[3], Float:vecAdjust[3], Float:vecEndPos[3], Float:flFraction, iWaterLevel, i; if( flRadius ) falloff = flDamage / flRadius; else falloff = 1.0; new bInWater = (engfunc( EngFunc_PointContents, vecSrc ) == CONTENTS_WATER); vecSrc[2] += 1;// in case grenade is lying on the ground // iterate on all entities in the vicinity. while ((pEntity = engfunc( EngFunc_FindEntityInSphere, pEntity, vecSrc, flRadius )) != 0) { if ( pev( pEntity, pev_takedamage ) != DAMAGE_NO ) { iWaterLevel = pev( pEntity, pev_waterlevel ); // NEW // blasts don't travel into or out of water if (bInWater && iWaterLevel == 0) continue; if (!bInWater && iWaterLevel == 3) continue; // OLD: vecSpot = pEntity->BodyTarget( vecSrc ); -- NEW: pev( pEntity, pev_absmin, vecAbsMin ); pev( pEntity, pev_absmax, vecAbsMax ); for( i = 0; i < 3; i++ ) vecSpot = ( vecAbsMin + vecAbsMax ) * 0.5; engfunc( EngFunc_TraceLine, vecSrc, vecSpot, DONT_IGNORE_MONSTERS, pevInflictor, tr ); get_tr2( tr, TR_flFraction, flFraction ); // NEW get_tr2( tr, TR_vecEndPos, vecEndPos ); // NEW if ( flFraction == 1.0 || get_tr2( tr, TR_pHit ) == pEntity ) { // the explosion can 'see' this entity, so hurt them! if ( get_tr2( tr, TraceResult:TR_StartSolid ) ) { // if we're stuck inside them, fixup the position and distance vecEndPos = vecSrc; flFraction = 0.0; } // decrease damage for an ent that's farther from the bomb. // OLD: flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length() * falloff; -- NEW: for( i = 0; i < 3; i++ ) vecAdjust = vecSrc - vecEndPos; flAdjustedDamage = floatsqroot(vecAdjust[0]*vecAdjust[0] + vecAdjust[1]*vecAdjust[1] + vecAdjust[2]*vecAdjust[2]) * falloff; flAdjustedDamage = flDamage - flAdjustedDamage if ( flAdjustedDamage < 0.0 ) { flAdjustedDamage = 0.0 } new vname[32] entity_get_string(pEntity, EV_SZ_classname, vname, 31) if (equali(vname,"player")) { new oid = pEntity new oteam = get_user_team(oid) new ateam = get_user_team(pevAttacker)
//server_print("oteam=%d,ateam=%d",oteam,ateam)
if (oteam!=ateam) { if (pev(oid,pev_health)<=flAdjustedDamage) ExecuteHamB(Ham_Killed, oid, pevAttacker, 4) else take_damage( pEntity, pevInflictor, flAdjustedDamage ) } } else if (equali(vname,"CSMod_Tank")) { new oid = pev(pEntity,pev_owner) new oteam = get_user_team(oid) new ateam = get_user_team(pevAttacker) if (oid==pevAttacker) { if (DamageType==1) { new tank_hp = floatround(entity_get_float(pEntity, EV_FL_health)) if (tank_hp<=flAdjustedDamage) { new oid = pev(pEntity,pev_owner) new oname[32] get_user_name(oid,oname,31) client_print(0, print_chat, "【坦克大战】 %s 愚蠢的引爆了坦克,结束了自己的生命 ...",oname) ExecuteHamB(Ham_Killed, pevAttacker, pevAttacker, 4) } else take_damage( pEntity, pevInflictor, flAdjustedDamage ) } } else if (oteam!=ateam) { new tank_hp = floatround(entity_get_float(pEntity, EV_FL_health)) if (tank_hp<flAdjustedDamage) { new oid = pev(pEntity,pev_owner) new oname[32] get_user_name(oid,oname,31) new aname[32] get_user_name(pevAttacker,aname,31) client_print(0, print_chat, "【坦克大战】 %s 击毁了 %s 的坦克!!! ...",aname,oname) ExecuteHamB(Ham_Killed, oid, pevAttacker, 4) } else take_damage( pEntity, pevInflictor, flAdjustedDamage ) } } } } } }
public take_damage( victim, attacker, Float:damage ) { fakedamage(victim,"weapon_grenade",damage,DMG_BLAST) }
public TargetKilled(this,idattacker, shouldgib) { if (is_user_connected(idattacker)) { if(!pev_valid(this)) return HAM_IGNORED new tid = pev(this,pev_owner) if (!is_user_connected(tid)) return HAM_IGNORED
ExecuteHamB(Ham_Killed, tid, idattacker, 4) } return HAM_HANDLED }
|