发一个很娱乐的-AWP开枪有闪电源码
本帖最后由 点通粉丝 于 2009-1-15 03:25 编辑此插件改变AWP成一个闪电枪
*/
#define VERSION "1.0"
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
new const lightning_sprite[] = "sprites/lgtning.spr"
new const sound_file[] = "weapons/electro5.wav"
new const Float:origin_offsets =
{
0.0,0.0,0.0,
0.0,0.0,32.0,
0.0,0.0,-32.0,
12.0,0.0,0.0,
-12.0,0.0,0.0,
0.0,12.0,0.0,
0.0,-12.0,0.0,
12.0,0.0,32.0,
-12.0,0.0,32.0,
0.0,12.0,32.0,
0.0,-12.0,32.0,
12.0,0.0,-32.0,
-12.0,0.0,-32.0,
0.0,12.0,-32.0,
0.0,-12.0,-32.0
}
new spriteindex
new DeathMsg
new clipammo
new bpammo
new bool:can_shoot
new enabled_pcvar
new damage_pcvar
new head_damage_pcvar
new reload_time_pcvar
new distance_pcvar
public plugin_init()
{
register_plugin("Awp -> Lightning Gun",VERSION,"GHW_Chronic")
register_forward(FM_PlayerPreThink,"Forward_Think")
enabled_pcvar = register_cvar("lg_awp_enabled","1")
damage_pcvar = register_cvar("lg_awp_damage","20.0")
head_damage_pcvar = register_cvar("lg_awp_hs_damage","400.0")
reload_time_pcvar = register_cvar("lg_awp_reload","1.0")
distance_pcvar = register_cvar("lg_awp_distance","40.0")
DeathMsg = get_user_msgid("DeathMsg")
}
public plugin_precache()
{
spriteindex = precache_model(lightning_sprite)
precache_sound(sound_file)
}
public client_connect(id)
{
can_shoot = true
}
public Forward_Think(id)
{
new clip, backpack
if(get_pcvar_num(enabled_pcvar) && is_user_alive(id) && get_user_weapon(id,clip,backpack)==CSW_AWP && (pev(id,pev_button) & IN_ATTACK))
{
//Don't allow real AWP to fire
set_pev(id,pev_button,pev(id,pev_button) - IN_ATTACK)
if(clip && can_shoot)
{
//Get Player's nozzle origin
//And Where he shot
new I_player_origin, I_end_origin
new Float:player_origin, Float:end_origin
pev(id,pev_origin,player_origin)
get_user_origin(id,I_player_origin,1)
get_user_origin(id,I_end_origin,3)
IVecFVec(I_end_origin,end_origin)
IVecFVec(I_player_origin,player_origin)
//Make a Lightning Beam between those 2 locations
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(0) //TE_BEAMPOINTS
write_coord(I_player_origin) // start position
write_coord(I_player_origin)
write_coord(I_player_origin)
write_coord(I_end_origin) // end position
write_coord(I_end_origin)
write_coord(I_end_origin)
write_short(spriteindex)
write_byte(1) // framestart
write_byte(1) // framerate
write_byte(2) // life in 0.1's
write_byte(40) // width
write_byte(0) // noise
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(200) // brightness
write_byte(0) // speed
message_end()
emit_sound(id,CHAN_VOICE,sound_file,VOL_NORM, ATTN_NORM,0,PITCH_NORM)
//Take 1 clip ammo away
//And remove all ammo temporarily so player cannot re-fire
clipammo = clip - 1
bpammo = backpack
new weapid = engfunc(EngFunc_FindEntityByString,-1,"classname","weapon_awp")
while(weapid && pev(weapid, pev_owner) != id)
{
weapid = engfunc(EngFunc_FindEntityByString,weapid,"classname","weapon_awp")
}
if(weapid)
{
cs_set_weapon_ammo(weapid,0)
if(clipammo)
{
set_hudmessage(255,0,0,0.85,0.85,0,6.0,get_pcvar_float(reload_time_pcvar))
show_hudmessage(id,"%d | %d",clipammo,bpammo)
can_shoot = false
cs_set_user_bpammo(id,CSW_AWP,0)
remove_task(id)
set_task(get_pcvar_float(reload_time_pcvar),"give_ammo_back",id)
}
}
//Possible targets to have been shot
new players, num
get_players(players,num,"h")
new Float:target_origin
new Float:target_origin2
new Float:hit
new aiment, bodypart
get_user_aiming(id,aiment,bodypart)
new CsTeams:id_team = cs_get_user_team(id)
for(new i=0;i<num;i++)
{
//Not self / same team
if(players!=id && cs_get_user_team(players)!=id_team)
{
pev(players,pev_origin,target_origin2)
//Loop through all offset origins
for(new current_offset=0;current_offset<15;current_offset++)
{
target_origin = target_origin2 + origin_offsets
target_origin = target_origin2 + origin_offsets
target_origin = target_origin2 + origin_offsets
//Is the target able to be hit by the player (or is there a wall or something between them)
engfunc(EngFunc_TraceLine,player_origin,target_origin,1,id,0)
get_tr2(0,TR_vecEndPos,hit)
if((hit==target_origin && hit==target_origin && hit==target_origin) || aiment==players)
{
//Calculate if in FOV (Because arctan calculations assume the lines are continuous, however they really only extend from player forward, not backward)
static Float:angles, Float:diff, Float:reciprocalsq, Float:norm, Float:dot, Float:fov
pev(id, pev_angles, angles)
engfunc(EngFunc_MakeVectors, angles)
global_get(glb_v_forward, angles)
angles = 0.0
diff = target_origin - player_origin
diff = target_origin - player_origin
diff = target_origin - player_origin
//diff = 0.0// - for 2D viewcone
reciprocalsq = 1.0 / floatsqroot(diff*diff + diff*diff + diff*diff)
norm = diff * reciprocalsq
norm = diff * reciprocalsq
norm = diff * reciprocalsq
dot = norm*angles + norm*angles + norm*angles
pev(id, pev_fov, fov)
if(dot >= floatcos(fov * 3.1415926535 / 360.0))
{
//Calculate if target is close enough to the lightning-rail to get hurt
new Float:slope
slope = (player_origin - end_origin) / (player_origin - end_origin)
slope = (player_origin - target_origin) / (player_origin - target_origin)
slope = (player_origin - end_origin) / (player_origin - end_origin)
slope = (player_origin - target_origin) / (player_origin - target_origin)
new Float:tan
new Float:sin
tan = floatatan(slope,degrees)
tan = floatatan(slope,degrees)
tan = floatabs(tan - tan)
sin = floatsin(tan,degrees)
tan = floatatan(slope,degrees)
tan = floatatan(slope,degrees)
tan = floatabs(tan - tan)
sin = floatsin(tan,degrees)
//If that position is close enough to the target for him to be hit by the lightning
if(sin * get_distance_f(target_origin,player_origin) <= get_pcvar_float(distance_pcvar) && sin * get_distance_f(target_origin,player_origin) <= get_pcvar_float(distance_pcvar))
{
new hs = 0
new old_msgblock = get_msg_block(DeathMsg)
set_msg_block(DeathMsg,BLOCK_ONCE)
//If id is not aiming at target's head
if(players!=aiment || bodypart!=1)
{
本帖最后由 点通粉丝 于 2009-1-15 03:26 编辑
//Make a Lightning Beam on the hit target
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(0) //TE_BEAMPOINTS
write_coord(floatround(target_origin) + 32) // start position
write_coord(floatround(target_origin) + 32)
write_coord(floatround(target_origin) + 32)
write_coord(floatround(target_origin) - 32) // end position
write_coord(floatround(target_origin) - 32)
write_coord(floatround(target_origin) - 32)
write_short(spriteindex)
write_byte(1) // framestart
write_byte(1) // framerate
write_byte(2) // life in 0.1's
write_byte(200) // width
write_byte(0) // noise
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(200) // brightness
write_byte(0) // speed
message_end()
fm_fakedamage(players,id,get_pcvar_float(damage_pcvar),DMG_BULLET)
}
else
{
hs = 1
fm_fakedamage(players,id,get_pcvar_float(head_damage_pcvar),DMG_BULLET)
}
set_msg_block(DeathMsg,old_msgblock)
//If player died produce death message
if(!is_user_alive(players))
{
make_deathmsg(id,players,hs,"awp")
}
}
}
break;
}
}
}
}
}
}
}
//From VEN
stock fm_fakedamage(victim,attacker, Float:takedmgdamage, damagetype)
{
new entity = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"trigger_hurt"))
new value
float_to_str(takedmgdamage * 2, value, 15)
set_kvd(0, KV_ClassName,"trigger_hurt")
set_kvd(0, KV_KeyName, "dmg")
set_kvd(0, KV_Value, value)
set_kvd(0, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue,entity,0)
num_to_str(damagetype, value, 15)
set_kvd(0, KV_ClassName,"trigger_hurt")
set_kvd(0, KV_KeyName, "damagetype")
set_kvd(0, KV_Value, value)
set_kvd(0, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue,entity,0)
set_kvd(0, KV_ClassName,"trigger_hurt")
set_kvd(0, KV_KeyName, "origin")
set_kvd(0, KV_Value, "8192 8192 8192")
set_kvd(0, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue,entity,0)
dllfunc(DLLFunc_Spawn,entity)
set_pev(entity,pev_classname,"Lightning")
set_pev(entity,pev_owner,attacker)
dllfunc(DLLFunc_Touch,entity,victim)
engfunc(EngFunc_RemoveEntity,entity)
return 1
}
public give_ammo_back(id)
{
cs_set_user_bpammo(id,CSW_AWP,bpammo)
new weapid = engfunc(EngFunc_FindEntityByString,-1,"classname","weapon_awp")
while(weapid && pev(weapid, pev_owner) != id)
{
weapid = engfunc(EngFunc_FindEntityByString,weapid,"classname","weapon_awp")
}
if(weapid)
{
cs_set_weapon_ammo(weapid,clipammo)
}
can_shoot = true
}
1# 点通粉丝
(如虚幻闪电枪)
CVARs :
lg_awp_enabled -启用/禁用插件( 1 =打开0 =关闭) (默认值: 1 )
lg_awp_damage -(默认值: 20.0 )
lg_awp_hs_damage -(默认值: 400.0 )
lg_awp_reload -(秒) (默认值: 1.0 )
lg_awp_distance -(默认值: 40.0 ) 这源码太长.所以分作两段发上来
这插件在cs1.5上测试的时侯.用AWP开第二枪的时侯死机
不知点解呢....???
望高手改一改..五该晒
*/////////////
cs1.6未测试过.五知效果是五是也一样呢
完1.6的人请自行恻试一下啦 在jim_yang 的解答下CS1.5可以使用啦
你可以试试把cs_set_user_bpammo(id, CSW_AWP, ?)字样的地方替换成
set_pdata_int(id, 381, ?)
这样就能在1.5下用了,不过1.6又不能用了。
1.6里用set_pdata_int(id, 377, ?)
如果你想两个版同时能用,要加入对游戏版本的判断,然后分别使用两种方法。
设置一个全局变量offset_awp
if(1.5)
offset_awp = 381
else
offset_awp = 377
set_pdata_int(id, offset_awp, ?) 哦.我知点解我编译来编译去都编译五到啦.原来是要用utf-8格式来编译的
唉..搞了我两天总算弄明白啦..
这个可用在1.5啦 收到不错。。。 加油,。。。。 不错啊,我在CZ1.6中试过,好用的,但是AWP的威力下降不少,击中一枪只有20-30点血 这.....利用闪电攻击人吗...有点.... 呵呵!这个不错!!!!!!
页:
[1]