PHP Code:
public fm_Touch(ptr, ptd)
{
if ( !sh_is_active() ) return FMRES_IGNORED
if ( !pev_valid(ptr) ) return FMRES_IGNORED
static classname[32]
classname[0] = '^0'
pev(ptr, pev_classname, classname, 31)
// Lets block the picking up of a shield
if ( equal(classname, gPowerClass) ) {
new id = pev(ptr, pev_owner)
new Float:dRatio, Float:distanceBetween, damage
new Float:dmgRadius = get_pcvar_float(gPcvarRadius)
new maxDamage = get_pcvar_num(gPcvarMaxDamage)
new CsTeams:idTeam = cs_get_user_team(id)
new FFOn = sh_friendlyfire_on()
new Float:vicOrigin[3]
new Float:fl_vExplodeAt[3]
pev(ptr, pev_origin, fl_vExplodeAt)
for ( new victim = 1; victim <= gMaxPlayers; victim++ )
{
if ( !is_user_alive(victim) ) continue
if ( idTeam == cs_get_user_team(victim) && !FFOn && id != victim ) continue
pev(victim, pev_origin, vicOrigin)
distanceBetween = vector_distance(fl_vExplodeAt, vicOrigin)
if ( distanceBetween <= dmgRadius )
{
dRatio = distanceBetween / dmgRadius
damage = maxDamage - floatround(maxDamage * dRatio)
// Lessen damage taken by self
if (victim == id) damage = floatround(damage / 2.0)
if ( !damage ) damage = 1 // Incase damage cvar is really low cause something if within the radius
sh_extra_damage(victim, id, damage, "Kamehameha", _, SH_DMG_NORM, true, _, fl_vExplodeAt)
// Make them feel it
new Float:fl_vicVelocity[3]
fl_vicVelocity[0] = ((vicOrigin[0] - fl_vExplodeAt[0]) / distanceBetween) * 300.0
fl_vicVelocity[1] = ((vicOrigin[1] - fl_vExplodeAt[1]) / distanceBetween) * 300.0
fl_vicVelocity[2] = 150.0
set_pev(victim, pev_velocity, fl_vicVelocity)
sh_screen_shake(victim, 1.2, 1.2, 1.2)
}
}
// Make some Effects
new blastSize = floatround(dmgRadius / 12.0)
// Explosion Sprite
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GLOWSPRITE) //23
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[0])
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1])
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[2])
write_short(gSpriteExplosion) // model
write_byte(01) // life 0.x sec
write_byte(blastSize) // size
write_byte(255) // brightness
message_end()
// Explosion (smoke, sound/effects)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_EXPLOSION) //3
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[0])
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1])
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[2])
write_short(gSpriteSmoke) // model
write_byte(blastSize+5) // scale in 0.1's
write_byte(20) // framerate
write_byte(10) // flags
message_end()
// Create Burn Decals, if they are used
if ( get_pcvar_num(gPcvarDecals) ) {
// Change burn decal according to blast size
new decal = random_num(0,2)
if (blastSize > 18) {
//If radius >~ 216 use larger decals
decal += 3
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GUNSHOTDECAL) //109
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[0])
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1])
engfunc(EngFunc_WriteCoord, fl_vExplodeAt[2])
write_short(0) //?
write_byte(gBurnDecal[decal]) //decal
message_end()
}
// Stop the sounds
emit_sound(ptr, CHAN_STATIC, gSoundBeam, VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM)
emit_sound(id, CHAN_STATIC, gSoundRelease, VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ptr)
new Float:cooldown = get_pcvar_float(gPcvarCooldown)
if ( cooldown > 0.0 ) sh_set_cooldown(id, cooldown)
// Reset the Varible
gPowerID[id] = 0
gUsingPower[id] = false
// Switch back to previous weapon and reset speed...
if ( gLastWeapon[id] != CSW_KNIFE ) sh_switch_weapon(id, gLastWeapon[id])
else sh_reset_max_speed(id)
}
return FMRES_IGNORED
}