Please search next time.
PHP Code:
/*
To do:
T = needs testing
X = done
- = cancelled
[X] damageable entities that get hit take full damage
[T] make rockets not collide with other team rockets?
[T] make rockets not collide with non-solid entities?
[T] fix error log generated on invalid touched entity
[T] increase range in EngFunc_FindEntityInSphere
[T] make rockets destroy any damageable entity from other teams
[T] ignore cases where damage <= 0.0 instead of checking for distance
[T] make sure rockets don't destroy each other in case they're same team rockets
[T] emessage instead of message for death for more compatibility with other plugins
[T] rocket class name
[T] remove entities by class name
[T] ftFMEntityOriginGet model check
[T] user rpg class name on death message
[T] separate touched entity damage code
[T] make sure the player takes the full damage, then kill him
[T] only kill the player if he actually died from the rocket damage
[T] add support for damage modification by external sources
[T] get_user_team instead of cs_get_user_team
[T] fix crash related to when touching a trigger_multiple(or any other solid_trigger?) entity
[ ] see why it is happening
[T] float velocity_by_aim
[ ] map entities can have studio models too...
[-] only kill the player if the remaining hp is 1.0, otherwise restore old hp
[ ] cache as many things as possible and see if it increases touch rate
[ ] explode rocket after X time if it doesn't hit anything
[ ]
*/
#include <amxmodx>
//#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <cs_ham_bots_api>
#include <bitsums>
#include <D7Debug>
enum
{
g_iIDModHL,
g_iIDModCS,
g_iIDModDOD
}
new g_iBsHasBazooka, g_iBsCanShoot, g_iBsConnected, g_iBsAlive, g_iIDPCVarSvMaxVelocity;
const g_iIDEntityRocketPev = pev_iuser4;
const g_iIDEntityRocket = 7575;
new const g_szClassNameRocket[] = "D7RPG";
new const g_szEntityRocketModel[] = "models/rpgrocket.mdl";
new const ROCKET_SOUND[] = "weapons/rocketfire1.wav";
new g_iIDCacheSpriteRocketTrail, explosion, white;
new CVar_RocketDelay, CVar_RocketSpeed,
CVar_RocketDmg, CVar_Dmg_range;
new g_iMaxPlayers, g_iIDMsgDeath, g_iIDMod;
public plugin_precache()
{
precache_model(g_szEntityRocketModel)
g_iIDCacheSpriteRocketTrail = precache_model("sprites/smoke.spr");
explosion = precache_model("sprites/zerogxplode.spr")
white = precache_model("sprites/white.spr")
precache_sound(ROCKET_SOUND)
}
public plugin_init()
{
register_plugin("D7 API RPG", "0.2.0", "D i 5 7 i n c T")
RegisterHam(Ham_Spawn, "player", "fwHamSpawnPlayer", 1)
RegisterHamBots(Ham_Spawn, "fwHamSpawnPlayer", 1)
//RegisterHam(Ham_TakeDamage, "player", "fwHamTakeDamagePlayerPre")
//RegisterHamBots(Ham_TakeDamage, "fwHamTakeDamagePlayerPre")
//RegisterHam(Ham_TakeDamage, "player", "fwHamTakeDamagePlayer", 1)
//RegisterHamBots(Ham_TakeDamage, "fwHamTakeDamagePlayer", 1)
RegisterHam(Ham_Killed, "player", "fwHamKilledPlayerPre")
RegisterHamBots(Ham_Killed, "fwHamKilledPlayerPre")
register_forward(FM_Touch, "fwFmTouch", 1)
register_forward(FM_PlayerPreThink, "fwFmPlayerPreThink", 1)
register_clcmd("say /b", "fwClCmdSayB")
g_iIDPCVarSvMaxVelocity = get_cvar_pointer("sv_maxvelocity");
CVar_RocketDelay = register_cvar("D7RPGDelay", "0.1")
CVar_RocketSpeed = register_cvar("D7RPGSpeed", "970")
CVar_RocketDmg = register_cvar("D7RPGDamage", "5")
CVar_Dmg_range = register_cvar("D7RPGDamageRadius", "240")
g_iMaxPlayers = get_maxplayers();
g_iIDMsgDeath = get_user_msgid("DeathMsg");
//register_message(g_iIDMsgDeath, "fwMsgDeathPre")
new szModName[32];
get_modname(szModName, charsmax(szModName));
if (equali(szModName, "cstrike") || equali(szModName, "czero") || equali(szModName, "csv15") || equali(szModName, "cs13"))
g_iIDMod = g_iIDModCS;
else if (equali(szModName, "dod"))
g_iIDMod = g_iIDModDOD;
else
g_iIDMod = g_iIDModHL;
}
/*
// After fwHamKilledPlayerPre
// Before fwHamKilledPlayer
public fwMsgDeathPre(const iIDMsg, const iMsgDest, const iIDEnt)
{
new iIDAttacker = get_msg_arg_int(1),
iIDVictim = get_msg_arg_int(2);
ftD7Log(_, _, "[fwMsgDeathPre] iIDAttacker: %d. iIDVictim: %d.", iIDAttacker, iIDVictim)
}*/
ftEntityRocketRemove(const iIDOwner = 0)
{
new iIDEntity = -1;
//while ((iIDEntity = engfunc(EngFunc_FindEntityInSphere, iIDEntity, Float:{ 0.0, 0.0, 0.0 }, 99999.0)) != 0)
while ((iIDEntity = engfunc(EngFunc_FindEntityByString, iIDEntity, "classname", g_szClassNameRocket)) != 0)
{
if (!pev_valid(iIDEntity)
//|| pev(iIDEntity, g_iIDEntityRocketPev) != g_iIDEntityRocket
|| iIDOwner && iIDOwner != pev(iIDEntity, pev_owner))
continue;
engfunc(EngFunc_RemoveEntity, iIDEntity)
}
}
public client_putinserver(iID)
{
bitsum_add(g_iBsConnected, iID)
}
public client_disconnect(iID)
{
ftEntityRocketRemove(iID)
remove_task(iID)
bitsum_del(g_iBsHasBazooka, iID)
bitsum_del(g_iBsCanShoot, iID)
bitsum_del(g_iBsConnected, iID)
bitsum_del(g_iBsAlive, iID)
}
public fwHamSpawnPlayer(const iID)
{
//remove_task(iID)
//bitsum_del(g_iBsHasBazooka, iID)
//bitsum_del(g_iBsCanShoot, iID)
if (!is_user_alive(iID))
return;
bitsum_add(g_iBsAlive, iID)
}
public fwHamKilledPlayerPre(const iID)
{
remove_task(iID)
bitsum_del(g_iBsHasBazooka, iID)
bitsum_del(g_iBsCanShoot, iID)
bitsum_del(g_iBsAlive, iID)
}
public fwClCmdSayB(const iID)
{
if (!bitsum_get(g_iBsHasBazooka, iID))
{
bitsum_add(g_iBsHasBazooka, iID)
fwTaskCanShoot(iID)
}
else
{
ftEntityRocketRemove(iID)
remove_task(iID)
bitsum_del(g_iBsHasBazooka, iID)
bitsum_del(g_iBsCanShoot, iID)
}
}
/*
new g_iBsDeath;
public fwHamTakeDamagePlayerPre(const iIDEntity, const iIDInflictor, const iIDAttacker, Float:fDamage, const iBsDamageType)
{
if (iBsDamageType != DMG_BLAST)
{
ftD7Log(_, _, "[fwHamTakeDamagePlayerPre] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Damage type is not DMG_BLAST.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (GetHamReturnStatus() == HAM_SUPERCEDE)
{
ftD7Log(_, _, "[fwHamTakeDamagePlayerPre] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Damage has been blocked.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (!pev_valid(iIDInflictor))
{
ftD7Log(_, _, "[fwHamTakeDamagePlayerPre] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Inflictor is invalid.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (pev(iIDInflictor, g_iIDEntityRocketPev) != g_iIDEntityRocket)
{
ftD7Log(_, _, "[fwHamTakeDamagePlayerPre] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Inflictor is not a rocket.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (get_user_health(iIDEntity) - floatround(fDamage, floatround_floor) > 0)
{
ftD7Log(_, _, "[fwHamTakeDamagePlayerPre] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Health: %d. Damage: %d. NOT a kill.", iIDEntity, iIDInflictor, iIDAttacker, get_user_health(iIDEntity), floatround(fDamage, floatround_floor))
return;
}
//ftD7Log(_, _, "[fwHamTakeDamagePlayerPre] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Health: %d. Damage: %d. KILL.", iIDEntity, iIDInflictor, iIDAttacker, get_user_health(iIDEntity), floatround(fDamage, floatround_floor))
bitsum_add(g_iBsDeath, iIDEntity)
set_pev(iIDEntity, pev_health, fDamage + 1.0)
}
public fwHamTakeDamagePlayer(const iIDEntity, const iIDInflictor, const iIDAttacker, Float:fDamage, const iBsDamageType)
{
if (iBsDamageType != DMG_BLAST)
{
//ftD7Log(_, _, "[fwHamTakeDamagePlayer] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Damage type is not DMG_BLAST.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (GetHamReturnStatus() == HAM_SUPERCEDE)
{
//ftD7Log(_, _, "[fwHamTakeDamagePlayer] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Damage has been blocked.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (!pev_valid(iIDInflictor))
{
//ftD7Log(_, _, "[fwHamTakeDamagePlayer] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Inflictor is invalid.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (pev(iIDInflictor, g_iIDEntityRocketPev) != g_iIDEntityRocket)
{
//ftD7Log(_, _, "[fwHamTakeDamagePlayer] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Inflictor is not a rocket.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
else if (!bitsum_get(g_iBsDeath, iIDEntity))
{
//ftD7Log(_, _, "[fwHamTakeDamagePlayer] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. NOT a kill.", iIDEntity, iIDInflictor, iIDAttacker)
return;
}
ftD7Log(_, _, "[fwHamTakeDamagePlayer] iIDEntity: %d. iIDInflictor: %d. iIDAttacker: %d. Health: %d. Damage: %d. KILL.", iIDEntity, iIDInflictor, iIDAttacker, get_user_health(iIDEntity), floatround(fDamage, floatround_floor))
new iTemp = get_msg_block(g_iIDMsgDeath);
set_msg_block(g_iIDMsgDeath, BLOCK_ONCE)
ExecuteHamB(Ham_Killed, iIDEntity, iIDAttacker, 2)
set_msg_block(g_iIDMsgDeath, iTemp)
ftMsgDeathSend(iIDAttacker, iIDEntity, g_szClassNameRocket, _, iIDInflictor)
}*/
// Credits to VEN
stock ftFMEntityOriginGet(const iIDEntity, Float:fVecTemp[3])
{
new szModel[2];
pev(iIDEntity, pev_model, szModel, charsmax(szModel))
if (szModel[0] == '*')
{
pev(iIDEntity, pev_mins, fVecTemp)
static Float:fVecTemp2[3];
pev(iIDEntity, pev_maxs, fVecTemp2);
fVecTemp[0] += fVecTemp2[0];
fVecTemp[1] += fVecTemp2[1];
fVecTemp[2] += fVecTemp2[2];
fVecTemp[0] *= 0.5;
fVecTemp[1] *= 0.5;
fVecTemp[2] *= 0.5;
return;
}
pev(iIDEntity, pev_origin, fVecTemp)
}
ftMsgDeathSend(const iIDAttacker, const iIDVictim, const szNameWeapon[] = "", const bool:bHeadShot = false, const iIDInflictor = 0)
{
message_begin(MSG_ALL, g_iIDMsgDeath)
write_byte(iIDAttacker)
write_byte(iIDVictim)
if (g_iIDMod == g_iIDModCS)
{
write_byte(bHeadShot) //headshot
write_string(szNameWeapon)
}
else if (g_iIDMod == g_iIDModHL)
{
write_string(szNameWeapon)
}
else if (g_iIDMod == g_iIDModDOD)
{
write_byte(iIDInflictor) //weaponid
}
message_end()
}
public fwFmTouch(iIDEntityToucher, iIDEntityTouched)
{
new iIDEntityRocket;
if (pev_valid(iIDEntityToucher) && pev(iIDEntityToucher, g_iIDEntityRocketPev) == g_iIDEntityRocket)
iIDEntityRocket = iIDEntityToucher;
else if (pev_valid(iIDEntityTouched) && pev(iIDEntityTouched, g_iIDEntityRocketPev) == g_iIDEntityRocket)
{
iIDEntityRocket = iIDEntityTouched;
iIDEntityTouched = iIDEntityToucher;
iIDEntityToucher = iIDEntityRocket;
}
else
return;
new iIDEntityRocketOwner = pev(iIDEntityRocket, pev_owner);
if (iIDEntityTouched == iIDEntityRocketOwner)
return;
new iEntityRocketOwnerTeam = get_user_team(iIDEntityRocketOwner),
iIDEntityOtherOwner, Float:fCVarDamage = get_pcvar_float(CVar_RocketDmg),
Float:fHealth, iTemp, Float:fDamage;
static szEntityClassName[32];
// Pass through dead/same team players and team entities
if (1 <= iIDEntityTouched <= g_iMaxPlayers)
{
if (!bitsum_get(g_iBsAlive, iIDEntityTouched) || bitsum_get(g_iBsConnected, iIDEntityTouched) && iEntityRocketOwnerTeam == get_user_team(iIDEntityTouched))
{
ftD7Log(_, _, "[fwFmTouch] Touched entity is an either dead or a connected and on the same team player as the rocket owner. Ignoring.")
return;
}
if (fCVarDamage > 0.0)
{
pev(iIDEntityTouched, pev_health, fHealth)
set_pev(iIDEntityTouched, pev_health, 10000000.0)
ExecuteHamB(Ham_TakeDamage, iIDEntityTouched, iIDEntityRocket, iIDEntityRocketOwner, fCVarDamage, DMG_BLAST)
fDamage = 10000000.0 - get_user_health(iIDEntityTouched);
ftD7Log(_, _, "[fwFmTouch] fHealth: %f. fDamage: %f.", fHealth, fDamage)
if (fHealth > fDamage)
{
//if (fHealth < 1.0)
//{
// ftD7Log(_, _, "[fwFmTouch] Player in explosion range has health between 0 and 1. fHealth: %f.", fHealth)
//}
fHealth -= fDamage;
set_pev(iIDEntityTouched, pev_health, fHealth)
}
else
{
ftD7Log(_, _, "[fwFmTouch] Player hit should be dead. Executing Ham_Killed with custom death message.")
//set_pev(iIDEntityTouched, pev_health, 1.0)
//ExecuteHam(Ham_Spawn, iIDEntityTouched)
//engfunc(EngFunc_SetOrigin, iIDEntityTouched, fVecOriginEntityInSphere)
iTemp = get_msg_block(g_iIDMsgDeath);
set_msg_block(g_iIDMsgDeath, BLOCK_ONCE)
ExecuteHamB(Ham_Killed, iIDEntityTouched, iIDEntityRocketOwner, 2)
set_msg_block(g_iIDMsgDeath, iTemp)
ftMsgDeathSend(iIDEntityRocketOwner, iIDEntityTouched, g_szClassNameRocket, _, iIDEntityRocket)
}
}
}
else if (pev_valid(iIDEntityTouched))
{
if (pev(iIDEntityTouched, pev_solid) <= SOLID_TRIGGER)
return;
iIDEntityOtherOwner = pev(iIDEntityTouched, pev_owner);
if ((1 <= iIDEntityOtherOwner <= g_iMaxPlayers) && bitsum_get(g_iBsConnected, iIDEntityOtherOwner) && iEntityRocketOwnerTeam == get_user_team(iIDEntityOtherOwner))
return;
if (fCVarDamage > 0.0)
{
pev(iIDEntityTouched, pev_health, fHealth)
//ftD7Log(_, _, "[fwFmTouch] iIDEntityRocket: %d. iIDEntityTouched: %d. Damage: %f. Health: %f.",
//iIDEntityRocket, iIDEntityTouched, fCVarDamage, fHealth)
if (fHealth > 0.0)
{
pev(iIDEntityTouched, pev_takedamage, fDamage)
if (fDamage != 0.0)
{
ExecuteHamB(Ham_TakeDamage, iIDEntityTouched, iIDEntityRocket, iIDEntityRocketOwner, fCVarDamage, DMG_BLAST)
}
else
{
pev(iIDEntityTouched, pev_classname, szEntityClassName, charsmax(szEntityClassName))
if (equali(szEntityClassName, "func_breakable"))
ExecuteHamB(Ham_TakeDamage, iIDEntityTouched, iIDEntityRocket, iIDEntityRocketOwner, fCVarDamage, DMG_BLAST)
}
}
}
pev(iIDEntityTouched, pev_classname, szEntityClassName, charsmax(szEntityClassName))
ftD7Log(_, _, "[fwFmTouch] iIDEntityToucher: %d. iIDEntityTouched: %d. iIDEntityRocket: %d. Touched class name: ^"%s^".", iIDEntityToucher, iIDEntityTouched, iIDEntityRocket, szEntityClassName)
}
static Float:fVecOrigin[3], Float:fVecOriginEntityInSphere[3];
pev(iIDEntityRocket, pev_origin, fVecOrigin)
new iIDEntityInSphere = -1, Float:fCVarRadius = get_pcvar_float(CVar_Dmg_range);
//ftD7Log(_, _, "[fwFmTouch] iIDEntityRocket: %d. fVecOrigin: %f, %f, %f.", iIDEntityRocket, fVecOrigin[0], fVecOrigin[1], fVecOrigin[2])
while ((iIDEntityInSphere = engfunc(EngFunc_FindEntityInSphere, iIDEntityInSphere, fVecOrigin, fCVarRadius)) != 0)
{
if (iIDEntityInSphere == iIDEntityRocket
|| iIDEntityInSphere == iIDEntityRocketOwner
|| iIDEntityInSphere == iIDEntityTouched)
continue;
//pev(iIDEntityInSphere, pev_classname, szEntityClassName, charsmax(szEntityClassName))
//ftD7Log(_, _, "[fwFmTouch] iIDEntityInSphere: %d. Class name: ^"%s^".", iIDEntityInSphere, szEntityClassName)
if (1 <= iIDEntityInSphere <= g_iMaxPlayers)
{
if (!bitsum_get(g_iBsAlive, iIDEntityInSphere)
|| iEntityRocketOwnerTeam == get_user_team(iIDEntityInSphere))
continue;
pev(iIDEntityInSphere, pev_origin, fVecOriginEntityInSphere)
fDamage = fCVarDamage - (fCVarDamage / fCVarRadius * get_distance_f(fVecOrigin, fVecOriginEntityInSphere));
//ftD7Log(_, _, "[fwFmTouch] iIDEntityRocket: %d. iIDEntityInSphere: %d. fVecOriginEntityInSphere: %f, %f, %f. Damage: %f.",
//iIDEntityRocket, iIDEntityInSphere, fVecOriginEntityInSphere[0], fVecOriginEntityInSphere[1], fVecOriginEntityInSphere[2], fDamage)
//ftD7Log(_, _, "[fwFmTouch] iIDEntityRocket: %d. iIDEntityInSphere: %d. Damage: %f.",
//iIDEntityRocket, iIDEntityInSphere, fDamage)
if (fDamage < 1.0)
continue;
/*
engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_LIGHTNING)
engfunc(EngFunc_WriteCoord, fVecOrigin[0])
engfunc(EngFunc_WriteCoord, fVecOrigin[1])
engfunc(EngFunc_WriteCoord, fVecOrigin[2])
engfunc(EngFunc_WriteCoord, fVecOriginEntityInSphere[0])
engfunc(EngFunc_WriteCoord, fVecOriginEntityInSphere[1])
engfunc(EngFunc_WriteCoord, fVecOriginEntityInSphere[2])
write_byte(25) //life in 0.1's
write_byte(25) //width in 0.1's
write_byte(0) //amplitude in 0.01's
write_short(g_iIDCacheSpriteRocketTrail) //sprite model index
message_end()*/
pev(iIDEntityInSphere, pev_health, fHealth)
set_pev(iIDEntityInSphere, pev_health, 10000000.0)
ExecuteHamB(Ham_TakeDamage, iIDEntityInSphere, iIDEntityRocket, iIDEntityRocketOwner, fDamage, DMG_BLAST)
fDamage = 10000000.0 - get_user_health(iIDEntityInSphere);
ftD7Log(_, _, "[fwFmTouch] fHealth: %f. fDamage: %f.", fHealth, fDamage)
if (fHealth > fDamage)
{
//if (fHealth < 1.0)
//{
// ftD7Log(_, _, "[fwFmTouch] Player in explosion range has health between 0 and 1. fHealth: %f.", fHealth)
//}
fHealth -= fDamage;
set_pev(iIDEntityInSphere, pev_health, fHealth)
continue;
}
ftD7Log(_, _, "[fwFmTouch] Player in explosion range should be dead. Executing Ham_Killed with custom death message.")
//set_pev(iIDEntityInSphere, pev_health, 1.0)
//ExecuteHam(Ham_Spawn, iIDEntityInSphere)
//engfunc(EngFunc_SetOrigin, iIDEntityInSphere, fVecOriginEntityInSphere)
iTemp = get_msg_block(g_iIDMsgDeath);
set_msg_block(g_iIDMsgDeath, BLOCK_ONCE)
ExecuteHamB(Ham_Killed, iIDEntityInSphere, iIDEntityRocketOwner, 2)
set_msg_block(g_iIDMsgDeath, iTemp)
ftMsgDeathSend(iIDEntityRocketOwner, iIDEntityInSphere, g_szClassNameRocket, _, iIDEntityRocket)
}
else if (pev_valid(iIDEntityInSphere))
{
pev(iIDEntityInSphere, pev_health, fHealth)
if (fHealth <= 0.0)
continue;
iIDEntityOtherOwner = pev(iIDEntityInSphere, pev_owner);
if ((1 <= iIDEntityOtherOwner <= g_iMaxPlayers) && bitsum_get(g_iBsConnected, iIDEntityOtherOwner) && iEntityRocketOwnerTeam == get_user_team(iIDEntityOtherOwner))
continue;
pev(iIDEntityInSphere, pev_takedamage, fDamage)
if (fDamage == 0.0)
{
pev(iIDEntityInSphere, pev_classname, szEntityClassName, charsmax(szEntityClassName))
if (!equali(szEntityClassName, "func_breakable"))
continue;
}
ftFMEntityOriginGet(iIDEntityInSphere, fVecOriginEntityInSphere)
//pev(iIDEntityInSphere, pev_origin, fVecOriginEntityInSphere)
fDamage = fCVarDamage - (fCVarDamage / fCVarRadius * get_distance_f(fVecOrigin, fVecOriginEntityInSphere));
//ftD7Log(_, _, "[fwFmTouch] iIDEntityRocket: %d. iIDEntityInSphere: %d. fVecOriginEntityInSphere: %f, %f, %f. Damage: %f.",
//iIDEntityRocket, iIDEntityInSphere, fVecOriginEntityInSphere[0], fVecOriginEntityInSphere[1], fVecOriginEntityInSphere[2], fDamage)
if (fDamage <= 0.0)
continue;
ftD7Log(_, _, "[fwFmTouch] iIDEntityRocket: %d. iIDEntityInSphere: %d. Damage: %f. Health: %f.",
iIDEntityRocket, iIDEntityInSphere, fDamage, fHealth)
/*
engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_LIGHTNING)
engfunc(EngFunc_WriteCoord, fVecOrigin[0])
engfunc(EngFunc_WriteCoord, fVecOrigin[1])
engfunc(EngFunc_WriteCoord, fVecOrigin[2])
engfunc(EngFunc_WriteCoord, fVecOriginEntityInSphere[0])
engfunc(EngFunc_WriteCoord, fVecOriginEntityInSphere[1])
engfunc(EngFunc_WriteCoord, fVecOriginEntityInSphere[2])
write_byte(25) //life in 0.1's
write_byte(25) //width in 0.1's
write_byte(0) //amplitude in 0.01's
write_short(g_iIDCacheSpriteRocketTrail) //sprite model index
message_end()*/
ExecuteHamB(Ham_TakeDamage, iIDEntityInSphere, iIDEntityRocket, iIDEntityRocketOwner, fDamage, DMG_BLAST)
}
}
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_EXPLOSION)
engfunc(EngFunc_WriteCoord, fVecOrigin[0])
engfunc(EngFunc_WriteCoord, fVecOrigin[1])
engfunc(EngFunc_WriteCoord, fVecOrigin[2])
write_short(explosion)
write_byte(30)
write_byte(15)
write_byte(0)
message_end()
/*
// Smallest ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y
engfunc(EngFunc_WriteCoord, fVecOrigin[2]) // z
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x axis
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y axis
engfunc(EngFunc_WriteCoord, fVecOrigin[2] + (fCVarRadius * 2) - (fCVarRadius * 2 / 3)) // z axis 385.0
write_short(white) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(4) // life
write_byte(72) // width
write_byte(0) // noise
write_byte(255) // red
write_byte(255) // green 100
write_byte(255) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()
// Medium ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y
engfunc(EngFunc_WriteCoord, fVecOrigin[2]) // z
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x axis
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y axis
engfunc(EngFunc_WriteCoord, fVecOrigin[2] + (fCVarRadius * 2) - (fCVarRadius * 2 / 6)) // z axis
write_short(white) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(4) // life
write_byte(72) // width
write_byte(0) // noise
write_byte(255) // red
write_byte(255) // green 100
write_byte(255) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()
*/
// Largest ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fVecOrigin, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y
engfunc(EngFunc_WriteCoord, fVecOrigin[2]) // z
engfunc(EngFunc_WriteCoord, fVecOrigin[0]) // x axis
engfunc(EngFunc_WriteCoord, fVecOrigin[1]) // y axis
engfunc(EngFunc_WriteCoord, fVecOrigin[2] + (fCVarRadius * 2)) // z axis
write_short(white) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(4) // life
write_byte(72) // width
write_byte(0) // noise
write_byte(255) // red
write_byte(255) // green 100
write_byte(255) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()
engfunc(EngFunc_RemoveEntity, iIDEntityRocket)
}
ftFmVelocityByAim(const iID, const Float:fAmount, Float:fVecTemp[3])
{
pev(iID, pev_v_angle, fVecTemp)
angle_vector(fVecTemp, ANGLEVECTOR_FORWARD, fVecTemp)
fVecTemp[0] *= fAmount;
fVecTemp[1] *= fAmount;
fVecTemp[2] *= fAmount;
}
public fwFmPlayerPreThink(iID)
{
//ftD7Log(_, iID, "[client_PreThink] iID: %d.", iID)
if (!bitsum_get(g_iBsHasBazooka, iID) || !bitsum_get(g_iBsCanShoot, iID))
{
//ftD7Log(_, iID, "[client_PreThink] No bazooka/can't shoot.")
return;
}
new iBsButtons = pev(iID, pev_button);
if (!(iBsButtons & IN_ATTACK2))
{
//ftD7Log(_, iID, "[client_PreThink] Not holding buttons.")
return;
}
set_pev(iID, pev_button, (iBsButtons & ~IN_ATTACK2))
static iIDAllocString;
if(!iIDAllocString)
{
//ftD7Log(_, iID, "[client_PreThink] String not allocated. Allocating.")
iIDAllocString = engfunc(EngFunc_AllocString, "info_target"); // alloc string once per load
}
new iIDEntity = engfunc(EngFunc_CreateNamedEntity, iIDAllocString);
if (!pev_valid(iIDEntity))
{
//ftD7Log(_, iID, "[client_PreThink] Entity failed to create!")
return;
}
set_pev(iIDEntity, pev_classname, g_szClassNameRocket)
set_pev(iIDEntity, g_iIDEntityRocketPev, g_iIDEntityRocket)
set_pev(iIDEntity, pev_owner, iID)
static Float:fVecTemp[3];
pev(iID, pev_v_angle, fVecTemp)
fVecTemp[0] *= -1;
set_pev(iIDEntity, pev_angles, fVecTemp)
set_pev(iIDEntity, pev_solid, SOLID_TRIGGER)
set_pev(iIDEntity, pev_movetype, MOVETYPE_FLY)
new Float:fEntMaxVelocity = get_pcvar_float(g_iIDPCVarSvMaxVelocity);
ftFmVelocityByAim(iID, floatclamp(get_pcvar_float(CVar_RocketSpeed), -fEntMaxVelocity, fEntMaxVelocity), fVecTemp)
set_pev(iIDEntity, pev_velocity, fVecTemp)
set_pev(iIDEntity, pev_effects, (pev(iIDEntity, pev_effects) | EF_LIGHT))
static Float:fVecTemp2[3];
pev(iID, pev_origin, fVecTemp)
pev(iID, pev_view_ofs, fVecTemp2)
fVecTemp[0] += fVecTemp2[0];
fVecTemp[1] += fVecTemp2[1];
fVecTemp[2] += fVecTemp2[2];
engfunc(EngFunc_SetOrigin, iIDEntity, fVecTemp)
engfunc(EngFunc_SetModel, iIDEntity, g_szEntityRocketModel)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMFOLLOW);
write_short(iIDEntity);
write_short(g_iIDCacheSpriteRocketTrail);
write_byte(11);
write_byte(5);
write_byte(191);
write_byte(191);
write_byte(191);
write_byte(random_num(150, 240));
message_end();
emit_sound(iIDEntity, CHAN_WEAPON, ROCKET_SOUND, 1.0, ATTN_NORM, 0, PITCH_NORM)
bitsum_del(g_iBsCanShoot, iID)
set_task(get_pcvar_float(CVar_RocketDelay), "fwTaskCanShoot", iID)
}
public fwTaskCanShoot(const iID)
{
bitsum_add(g_iBsCanShoot, iID)
client_print(iID, print_center, "Your can now shoot the next rocket!")
}