コード例 #1
0
ファイル: mech.tech.do.c プロジェクト: gtaylor/btmux
int valid_ammo_mode(MECH * mech, int loc, int part, int let)
{
	int w, i;

	if(!IsAmmo(GetPartType(mech, loc, part)) || !let)
		return -1;
	let = toupper(let);
	w = Ammo2I(GetPartType(mech, loc, part));

	if(MechWeapons[w].special & NOSPA)
		return -1;

	for(i = 0; ammo_types[i].name; i++) {
		if(ammo_types[i].name != let)
			continue;
		if(ammo_types[i].rtype >= 0 &&
		   MechWeapons[w].type != ammo_types[i].rtype)
			continue;
		if(ammo_types[i].rspec &&
		   !(MechWeapons[w].special & ammo_types[i].rspec))
			continue;
		if(ammo_types[i].ntype >= 0 &&
		   MechWeapons[w].type == ammo_types[i].ntype)
			continue;
		if(ammo_types[i].nspec &&
		   (MechWeapons[w].special & ammo_types[i].nspec))
			continue;
		return ammo_types[i].aflag;
	}
	return -1;
}
コード例 #2
0
ファイル: baseitem.cpp プロジェクト: a1batross/Xash3D_ancient
void CItem::ItemFall ( void )
{
	SetNextThink( 0.1 );

	if ( pev->flags & FL_ONGROUND )
	{
		// clatter if we have an owner (i.e., dropped by someone)
		// don't clatter if the item is waiting to respawn (if it's waiting, it is invisible!)
		if ( !FNullEnt( pev->owner )) 
		{
			EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char *)FallSound(), 1, ATTN_NORM);
                    	ItemOnGround(); //do somewhat if needed
		}
		
		// lie flat
		pev->angles.x = 0;
		pev->angles.z = 0;

		pev->solid = SOLID_TRIGGER;

		if( IsAmmo( )) UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ));
		if( IsItem( )) UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ));
		else UTIL_AutoSetSize();
		
		UTIL_SetOrigin( this, pev->origin ); // link into world.

		SetTouch( ItemTouch );
		SetThink( NULL ); 
	}
}
コード例 #3
0
ファイル: baseitem.cpp プロジェクト: a1batross/Xash3D_ancient
float CItem::ItemRespawnTime( CItem *pItem )
{
	//makes different time to respawn for weapons and items
	float flRespawnTime;

	if (IsAmmo()) flRespawnTime = RESPAWN_TIME_30SEC;
	if (IsItem()) flRespawnTime = RESPAWN_TIME_120SEC;
	return gpGlobals->time + flRespawnTime;
}
コード例 #4
0
ファイル: item.cpp プロジェクト: zhaozw/pathogenandroid
float SubtractItem(CPlayer* p, int item, float amount)
{
	CHold* h = NULL;
	int i;
    
	for(i=0; i<p->items.size(); i++)
	{
		if(p->items[i].type != item)
			continue;
        
		h = &p->items[i];
		break;
	}
    
	if(h == NULL)
		return 0;
    
	if(h->amount < amount)
		amount = h->amount;
    
	h->amount -= amount;
    
	if(h->amount <= 0.0f)
	{
		p->items.erase( p->items.begin() + i );
        
		if(p->equipped > i)
			p->equipped--;
		else if(p->equipped == i)
			EquipAny(p);
	}
    
	if(p == &g_player[g_localP] && IsAmmo(item))
		RedoAmmo();
    
	return amount;
}
コード例 #5
0
static int check_for_scrappage(MECH * mech, int loc)
{
    int a, b;
    int ret = 1;

    if (SectIsDestroyed(mech, loc))
	return 1;

    if (SomeoneScrappingLoc(mech, loc)) {
	DAMAGE2(DETACH, loc);
	return 1;
    }
    for (a = 0; a < NUM_CRITICALS; a++) {
	if (!(b = GetPartType(mech, loc, a)))
	    continue;
	if (PartIsBroken(mech, loc, a))
	    continue;
	if (IsCrap(b))
	    continue;
	if (IsAmmo(b) && GetPartData(mech, loc, a)) {
	    DAMAGE3(UNLOAD, loc, a);
	    if (ret && !SomeoneRepairing(mech, loc, a))
		ret = 0;
	    continue;
	}
	DAMAGE3(IsWeapon(b) ? SCRAPG : SCRAPP, loc, a);
	if (ret && !SomeoneScrappingPart(mech, loc, a))
	    ret = 0;
	if (IsWeapon(b))
	    a += GetWeaponCrits(mech, Weapon2I(b)) - 1;
    }

    if (ret && !Invalid_Scrap_Path(mech, loc))
	DAMAGE2(DETACH, loc);

    return 0;
}
コード例 #6
0
ファイル: mech.tech.do.c プロジェクト: gtaylor/btmux
int FindAmmoType(MECH * mech, int loc, int part)
{
	int t = GetPartType(mech, loc, part);
	int m = GetPartAmmoMode(mech, loc, part);
	int base = -1;

	if(!IsAmmo(t))
		return t;
	t = Ammo2I(t);

	if(strstr(MechWeapons[t].name, "StreakSRM"))
		base = SSRM_AMMO;
	else if(strstr(MechWeapons[t].name, "StreakLRM"))
		base = SLRM_AMMO;
	else if(strstr(MechWeapons[t].name, "ELRM"))
		base = ELRM_AMMO;
	else if(strstr(MechWeapons[t].name, "LR_DFM"))
		base = LR_DFM_AMMO;
	else if(strstr(MechWeapons[t].name, "SR_DFM"))
		base = SR_DFM_AMMO;
	else if(strstr(MechWeapons[t].name, "LRM"))
		base = LRM_AMMO;
	else if(strstr(MechWeapons[t].name, "SRM"))
		base = SRM_AMMO;
	else if(strstr(MechWeapons[t].name, "MRM"))
		base = MRM_AMMO;

	if(!(m & AMMO_MODES)) {
		if(base < 0)
			return I2Ammo(t);
		else
			return Cargo(base);
	}

	if(m & LBX_MODE) {
		if(strstr(MechWeapons[t].name, "LB20"))
			base = LBX20_AMMO;
		else if(strstr(MechWeapons[t].name, "LB10"))
			base = LBX10_AMMO;
		else if(strstr(MechWeapons[t].name, "LB5"))
			base = LBX5_AMMO;
		else if(strstr(MechWeapons[t].name, "LB2"))
			base = LBX2_AMMO;
		if(base < 0)
			return I2Ammo(t);
		return Cargo(base);
	}

	if(m & AC_MODES) {
		if(m & AC_AP_MODE) {
			if(strstr(MechWeapons[t].name, "AC/2"))
				base = AC2_AP_AMMO;
			if(strstr(MechWeapons[t].name, "AC/5"))
				base = AC5_AP_AMMO;
			if(strstr(MechWeapons[t].name, "AC/10"))
				base = AC10_AP_AMMO;
			if(strstr(MechWeapons[t].name, "AC/20"))
				base = AC20_AP_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/2"))
				base = LAC2_AP_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/5"))
				base = LAC5_AP_AMMO;
		}

		if(m & AC_FLECHETTE_MODE) {
			if(strstr(MechWeapons[t].name, "AC/2"))
				base = AC2_FLECHETTE_AMMO;
			if(strstr(MechWeapons[t].name, "AC/5"))
				base = AC5_FLECHETTE_AMMO;
			if(strstr(MechWeapons[t].name, "AC/10"))
				base = AC10_FLECHETTE_AMMO;
			if(strstr(MechWeapons[t].name, "AC/20"))
				base = AC20_FLECHETTE_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/2"))
				base = LAC2_FLECHETTE_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/5"))
				base = LAC5_FLECHETTE_AMMO;
		}

		if(m & AC_INCENDIARY_MODE) {
			if(strstr(MechWeapons[t].name, "AC/2"))
				base = AC2_INCENDIARY_AMMO;
			if(strstr(MechWeapons[t].name, "AC/5"))
				base = AC5_INCENDIARY_AMMO;
			if(strstr(MechWeapons[t].name, "AC/10"))
				base = AC10_INCENDIARY_AMMO;
			if(strstr(MechWeapons[t].name, "AC/20"))
				base = AC20_INCENDIARY_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/2"))
				base = LAC2_INCENDIARY_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/5"))
				base = LAC5_INCENDIARY_AMMO;
		}

		if(m & AC_PRECISION_MODE) {
			if(strstr(MechWeapons[t].name, "AC/2"))
				base = AC2_PRECISION_AMMO;
			if(strstr(MechWeapons[t].name, "AC/5"))
				base = AC5_PRECISION_AMMO;
			if(strstr(MechWeapons[t].name, "AC/10"))
				base = AC10_PRECISION_AMMO;
			if(strstr(MechWeapons[t].name, "AC/20"))
				base = AC20_PRECISION_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/2"))
				base = LAC2_PRECISION_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/5"))
				base = LAC5_PRECISION_AMMO;
		}

		if(m & AC_CASELESS_MODE) {
			if(strstr(MechWeapons[t].name, "AC/2"))
				base = AC2_CASELESS_AMMO;
			if(strstr(MechWeapons[t].name, "AC/5"))
				base = AC5_CASELESS_AMMO;
			if(strstr(MechWeapons[t].name, "AC/10"))
				base = AC10_CASELESS_AMMO;
			if(strstr(MechWeapons[t].name, "AC/20"))
				base = AC20_CASELESS_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/2"))
				base = LAC2_CASELESS_AMMO;
			if(strstr(MechWeapons[t].name, "LightAC/5"))
				base = LAC5_CASELESS_AMMO;
		}
		if(base < 0)
			return I2Ammo(t);
		return Cargo(base);
	}

	if(m & INARC_EXPLO_MODE)
		return Cargo(INARC_EXPLO_AMMO);
	else if(m & INARC_HAYWIRE_MODE)
		return Cargo(INARC_HAYWIRE_AMMO);
	else if(m & INARC_ECM_MODE)
		return Cargo(INARC_ECM_AMMO);
	else if(m & INARC_NEMESIS_MODE)
		return Cargo(INARC_NEMESIS_AMMO);

	if(base < 0)
		return I2Ammo(t);
	if(m & NARC_MODE)
		return Cargo(base) + NARC_LRM_AMMO - LRM_AMMO;
	if(m & ARTEMIS_MODE)
		return Cargo(base) + ARTEMIS_LRM_AMMO - LRM_AMMO;
	if(m & SWARM_MODE)
		return Cargo(base) + SWARM_LRM_AMMO - LRM_AMMO;
	if(m & SWARM1_MODE)
		return Cargo(base) + SWARM1_LRM_AMMO - LRM_AMMO;
	if(m & INFERNO_MODE)
		return Cargo(base) + INFERNO_SRM_AMMO - SRM_AMMO;
	if(m & STINGER_MODE)
		return Cargo(base) + AMMO_LRM_STINGER - LRM_AMMO;
	if(m & SGUIDED_MODE)
	        return Cargo(base) + AMMO_LRM_SGUIDED - LRM_AMMO;
	return Cargo(base);
}
コード例 #7
0
static int check_for_damage(MECH * mech, int loc)
{
    int a, b, c, d;

    if (SectIsDestroyed(mech, loc)) {
	if (MechType(mech) != CLASS_BSUIT)
	    DAMAGE2(REATTACH, loc);
	else
	    DAMAGE2(REPLACESUIT, loc);
	return 0;
    }

    /*
       * Added by Kipsta
       * 8/4/99
     */

    if (SectIsFlooded(mech, loc)) {
	DAMAGE2(RESEAL, loc);
	return 0;
    }
    if ((a = GetSectInt(mech, loc)) != (b = GetSectOInt(mech, loc)))
	DAMAGE3(FIXINTERNAL, loc, (b - a));
    else {
	if ((a = GetSectArmor(mech, loc)) != (b =
		GetSectOArmor(mech, loc)))
	    DAMAGE3(FIXARMOR, loc, (b - a));
	if ((a = GetSectRArmor(mech, loc)) != (b =
		GetSectORArmor(mech, loc)))
	    DAMAGE3(FIXARMOR_R, loc, (b - a));
    }
    for (a = 0; a < NUM_CRITICALS; a++) {
	if (!(b = GetPartType(mech, loc, a)))
	    continue;
	if (IsAmmo(b) && !PartIsDestroyed(mech, loc, a) &&
	    (c = GetPartData(mech, loc, a)) != (d =
		FullAmmo(mech, loc, a)))
	    DAMAGE3(RELOAD, loc, a);
	if (!PartIsNonfunctional(mech, loc, a) &&
	    !PartTempNuke(mech, loc, a) && !PartIsDamaged(mech, loc, a))
	    continue;
	if (IsCrap(b))
	    continue;
	/* Destroyed / tempnuke'd part. Either case, it works for us :) */

	if (PartIsDamaged(mech, loc, a)) {
	    if (GetPartDamageFlags(mech, loc, a) & WEAP_DAM_EN_FOCUS)
		DAMAGE3(ENHCRIT_FOCUS, loc, a);
	    else if (GetPartDamageFlags(mech, loc,
		    a) & WEAP_DAM_EN_CRYSTAL)
		DAMAGE3(ENHCRIT_CRYSTAL, loc, a);
	    else if (GetPartDamageFlags(mech, loc,
		    a) & WEAP_DAM_BALL_BARREL)
		DAMAGE3(ENHCRIT_BARREL, loc, a);
	    else if (GetPartDamageFlags(mech, loc, a) & WEAP_DAM_BALL_AMMO)
		DAMAGE3(ENHCRIT_AMMOB, loc, a);
	    else if (GetPartDamageFlags(mech, loc,
		    a) & WEAP_DAM_MSL_RANGING)
		DAMAGE3(ENHCRIT_RANGING, loc, a);
	    else if (GetPartDamageFlags(mech, loc, a) & WEAP_DAM_MSL_AMMO)
		DAMAGE3(ENHCRIT_AMMOM, loc, a);
	    else
		DAMAGE3(ENHCRIT_MISC, loc, a);

	} else if (IsWeapon(b) && GetWeaponCrits(mech, Weapon2I(b)) > 4 &&
	    !PartIsDestroyed(mech, loc, a + 1))
	    DAMAGE3(REPAIRP_T, loc, a);
	else
	    DAMAGE3(IsWeapon(b) ? REPAIRG : REPAIRP, loc, a);

	if (IsWeapon(b))
	    a += GetWeaponCrits(mech, Weapon2I(b)) - 1;
    }
    return 1;
}