Code:
//level thread doAmmoBomb();
//in init()
doAmmoBomb()
{
trigger = getEnt( "sd_bomb_pickup_trig", "targetname" );
if ( !isDefined( trigger ) )
{
maps\mp\_utility::error("No sd_bomb_pickup_trig trigger found in map.");
return;
}
visuals[0] = getEnt( "sd_bomb", "targetname" );
if ( !isDefined( visuals[0] ) )
{
maps\mp\_utility::error("No sd_bomb script_model found in map.");
return;
}
precacheModel( "prop_suitcase_bomb" );
level.bombZones = [];
bombZones = getEntArray( "bombzone", "targetname" );
for ( index = 0; index < bombZones.size; index++ )
{
trigger = bombZones[index];
visuals = getEntArray( bombZones[index].target, "targetname" );
bombZone = maps\mp\gametypes\_gameobjects::createUseObject( "allies", trigger, visuals, (0,0,64) );
bombZone maps\mp\gametypes\_gameobjects::allowUse( "friendly" );
bombZone maps\mp\gametypes\_gameobjects::setUseTime( 1.5 );
bombZone maps\mp\gametypes\_gameobjects::setUseText( "Getting ammo..." );
bombZone maps\mp\gametypes\_gameobjects::setUseHintText( "Hold ^3[{+activate}]^7 to get Ammo" );
label = bombZone maps\mp\gametypes\_gameobjects::getLabel();
bombZone.label = label;
bombZone maps\mp\gametypes\_gameobjects::set2DIcon( "friendly", "hud_ammo_refill_drop");
bombZone maps\mp\gametypes\_gameobjects::set3DIcon( "friendly", "hud_ammo_refill_drop" );
bombZone maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );
bombZone.onBeginUse = ::onBeginUse;
bombZone.onEndUse = ::onEndUse;
bombZone.onUse = ::onUsePlantObject;
bombZone.onCantUse = ::onCantUse;
bombZone.useWeapon = "briefcase_bomb_mp";
bombZone.visuals[0].killCamEnt = spawn( "script_model", bombZone.visuals[0].origin + (0,0,128) );
for ( i = 0; i < visuals.size; i++ )
{
if ( isDefined( visuals[i].script_exploder ) )
{
bombZone.exploderIndex = visuals[i].script_exploder;
break;
}
}
level.bombZones[level.bombZones.size] = bombZone;
bombZone.bombDefuseTrig = getent( visuals[0].target, "targetname" );
assert( isdefined( bombZone.bombDefuseTrig ) );
bombZone.bombDefuseTrig.origin += (0,0,-10000);
bombZone.bombDefuseTrig.label = label;
}
}
onUsePlantObject(player)
{
if ( !IsDefined( player ) )
return;
weaponlist = player GetWeaponsList();
for(i=0;i<weaponlist.size;i++)
{
weapon = weaponlist[i];
switch(weapon)
{
case "frag_grenade_mp":
case "sticky_grenade_mp":
case "hatchet_mp":
case "flash_grenade_mp":
case "concussion_grenade_mp":
case "tabun_gas_mp":
case "nightingale_mp":
case "willy_pete_mp":
player SetWeaponAmmoStock(weapon,999);
break;
default:
player GiveMaxAmmo(weapon);
break;
}
}
player iprintlnbold("Enjoy your ammo.");
}
onCantUse( player )
{
player iPrintLnBold( "You can't use this right now!" );
}
onEndUse( team, player, result )
{
if ( !IsDefined( player ) )
return;
}
onBeginUse( player )
{
}
Code:
//enable / disable ammo box
ammoBoxEnable(bool)
{
if(isDefined(level.bombZones))
{
for (i = 0; i < level.bombZones.size; i++ )
{
if(!bool)
level.bombZones[i] maps\mp\gametypes\_gameobjects::disableObject();
else
level.bombZones[i] maps\mp\gametypes\_gameobjects::enableObject();
}
}
}