RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
lub w Diablo "Damage(id)"
kiedy bijemy w głowę?
Oraz proszę o przerobienie tego pluginu i dorzucenie do niego, ze błyskawicy nie można użyć, jeżeli graczy dzieli zbyt duży dystans.
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <hamsandwich>
#define PLUGIN "Blyskawica"
#define VERSION "1.0"
#define AUTHOR "R3X"
new const gszSound[] = "ambience/thunder_clap.wav";
new g_iMaxPlayers;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("blysk", "cmdBlyskawica");
g_iMaxPlayers = get_maxplayers();
}
public cmdBlyskawica(id){
new ofiara, body;
get_user_aiming(id, ofiara, body);
if(is_user_alive(ofiara)){
puscBlyskawice(id, ofiara, 100.0, 0.5);
}
return PLUGIN_HANDLED;
}
new sprite;
public plugin_precache(){
sprite = precache_model("sprites/lgtning.spr");
precache_sound(gszSound);
}
/**
* from war3ft/effects.inl
*/
stock Create_TE_BEAMENTS(startEntity, endEntity, iSprite, startFrame, frameRate, life, width, noise, red, green, blue, alpha, speed){
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte( TE_BEAMENTS )
write_short( startEntity ) // start entity
write_short( endEntity ) // end entity
write_short( iSprite ) // model
write_byte( startFrame ) // starting frame
write_byte( frameRate ) // frame rate
write_byte( life ) // life
write_byte( width ) // line width
write_byte( noise ) // noise amplitude
write_byte( red ) // red
write_byte( green ) // green
write_byte( blue ) // blue
write_byte( alpha ) // brightness
write_byte( speed ) // scroll speed
message_end()
}
puscBlyskawice(id, ofiara, Float:fObrazenia = 100.0, Float:fCzas = 1.0){
//Obrazenia
new ent = create_entity("info_target");
entity_set_string(ent, EV_SZ_classname, "blyskawica");
ExecuteHamB(Ham_TakeDamage, ofiara, ent, id, fObrazenia, DMG_SHOCK);
//Piorun
Create_TE_BEAMENTS(id, ofiara, sprite, 0, 10, floatround(fCzas*10), 150, 5, 200, 200, 200, 200, 10);
//Dzwiek
emit_sound(id, CHAN_WEAPON, gszSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
new i;
while((i = findClosestPlayer(id, 100.0)))
{
ExecuteHamB(Ham_TakeDamage, ofiara, ent, id, fObrazenia, DMG_SHOCK);
//Piorun
Create_TE_BEAMENTS(ofiara, i, sprite, 0, 10, floatround(fCzas*10), 150, 5, 200, 200, 200, 200, 10);
//Dzwiek
emit_sound(i, CHAN_WEAPON, gszSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
remove_entity(ent);
}
findClosestPlayer(id, Float:dist)
{
new bestPlayer, Float:bestDist = dist, Float:fDist;
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(!is_user_alive(i))
continue;
if(get_user_team(id) == get_user_team(i))
continue;
if((fDist = entity_range(id, i)) > bestDist)
continue;
bestPlayer = i;
bestDist = fDist;
}
return bestPlayer;
}