public zp_grenade_postframe(id, grenade, grenadetype, activegrenade, bZombie)
{
if (bZombie)
return;
if (grenadetype == GRENADETYPE)
{
if (g_iGrenadeID == activegrenade)
{
static Float:flGameTime, bitsOldButtons;
flGameTime = get_gametime();
bitsOldButtons = get_entvar(id, var_oldbuttons);
static iEntity; iEntity = get_ced(grenade, ced_int, ceCustom_BarricadeIndex);
if (is_nullent(iEntity) || !FClassnameIs(iEntity, szMineClassName) || get_ced(grenade, ced_int, ceCustom_Barricade_Weapon_Key) != get_ced(iEntity, ced_int, ced_global_entity_key))
{
iEntity = CreateMine(id, grenade);
if (is_nullent(iEntity))
{
return;
}
}
set_ced(grenade, ced_int, ceCustom_BarricadeIndex, iEntity);
set_ced(iEntity, ced_int, ceCustom_BarricadeWeaponIndex, grenade);
new Float:flDistance = floatclamp(get_ced(iEntity, ced_float, ceCustom_BarricadeDistance), 30.0, 100.0);
new Float:flOrigin[3], Float:flAngles[3], Float:flVec[3];
get_entvar(id, var_origin, flOrigin);
get_entvar(id, var_v_angle, flAngles);
angle_vector(flAngles, ANGLEVECTOR_FORWARD, flVec);
flOrigin[0] += flVec[0] * flDistance;
flOrigin[1] += flVec[1] * flDistance;
flOrigin[2] += flVec[2] * flDistance;
set_entvar(iEntity, var_origin, flOrigin);
get_entvar(id, var_angles, flAngles);
flAngles[0] = 0.0;
set_entvar(iEntity, var_angles, flAngles);
if (!engfunc(EngFunc_WalkMove, iEntity, 0.0, 0.0, WALKMOVE_NORMAL))
{
set_ced(iEntity, ced_int, ceCustom_BarricadeState, CANT_BE_PLACED);
rg_set_ent_render(iEntity, kRenderFxGlowShell, 200, 0, 0, kRenderTransAdd, 15);
}
else
{
set_ced(iEntity, ced_int, ceCustom_BarricadeState, CAN_BE_PLACED);
rg_set_ent_render(iEntity, kRenderFxGlowShell, 235, 224, 14, kRenderTransAdd, 15);
}
if (bitsOldButtons & IN_USE)
{
if (bitsOldButtons & IN_ATTACK)
{
set_ced(iEntity, ced_float, ceCustom_BarricadeDistance, flDistance + 0.4);
}
else if (bitsOldButtons & IN_ATTACK2)
{
set_ced(iEntity, ced_float, ceCustom_BarricadeDistance, flDistance - 0.4);
}
}
else if (bitsOldButtons & IN_ATTACK)
{
if (get_ced(iEntity, ced_int, ceCustom_BarricadeState) == CAN_BE_PLACED)
{
set_ced(iEntity, ced_int, ceCustom_BarricadeState, PLACED);
engfunc(EngFunc_SetSize, iEntity, flMinSize, flMaxSize);
//new Float:flHealth;
//flHealth = get_ced(grenade, ced_string, ced_grenade_str_BarricadeHealth);
//set_entvar(iEntity, var_health, flHealth == 0.0 ? BARRICADE_HEALTH : flHealth);
for (new i = ArraySize(g_aBarricadesHPInBackPack) - 1; i>=0; i--)
{
if (ArrayGetCell(g_aBarricadesHPInBackPackOwner, i) == id)
{
set_entvar(iEntity, var_health, Float:ArrayGetCell(g_aBarricadesHPInBackPack, i));
ArrayDeleteItem(g_aBarricadesHPInBackPack, i);
ArrayDeleteItem(g_aBarricadesHPInBackPackOwner, i--);
break;
}
}
set_entvar(iEntity, var_nextthink, flGameTime + 0.01);
SetThink(iEntity, "fw_ThinkBarricade");
set_entvar(iEntity, var_solid, SOLID_BBOX);
zp_grenade_set_ammo(id, grenade, activegrenade, -1);
rg_set_ent_render(iEntity);
set_ced(grenade, ced_int, ceCustom_BarricadeIndex, 0);
ArrayPushCell(g_aBarricades, iEntity);
ArrayPushCell(g_aBarricadesKey, zp_register_entity_key(iEntity));
zp_traceitem_add(iEntity);
zp_tracelogos_add(iEntity);
}
}
set_member(grenade, m_Weapon_flNextSecondaryAttack, 1.0);
set_member(grenade, m_Weapon_flNextSecondaryAttack, 1.0);
set_member(grenade, m_Weapon_flTimeWeaponIdle, 1.0);
}
}
}