//----------------------------------------------------------------------------- // Purpose: Fire a flare //----------------------------------------------------------------------------- CBaseEntity *CTFWeaponBaseGun::FireArrow( CTFPlayer *pPlayer, int iType ) { PlayWeaponShootSound(); #ifdef GAME_DLL Vector vecSrc; QAngle angForward; Vector vecOffset( 23.5f, 12.0f, -3.0f ); if ( pPlayer->GetFlags() & FL_DUCKING ) { vecOffset.z = 8.0f; } if ( IsWeapon( TF_WEAPON_COMPOUND_BOW ) ) { // Valve were apparently too lazy to fix the viewmodel and just flipped it through the code. vecOffset.y *= -1.0f; } GetProjectileFireSetup( pPlayer, vecOffset, &vecSrc, &angForward, false, true ); CTFProjectile_Arrow *pProjectile = CTFProjectile_Arrow::Create( this, vecSrc, angForward, GetProjectileSpeed(), GetProjectileGravity(), pPlayer, pPlayer, iType ); if ( pProjectile ) { pProjectile->SetCritical( IsCurrentAttackACrit() ); pProjectile->SetDamage( GetProjectileDamage() ); } return pProjectile; #endif return NULL; }
void CREARecord::CREASound::IsWeapon(bool value) { if(value) CSDT.value = eWeapon; else if(IsWeapon()) CSDT.value = eLeftFoot; }
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; }
void debug_setwbv(dbref player, void *data, char *buffer) { char *args[3]; int bv; int id, brand; DOCHECK(mech_parseattributes(buffer, args, 3) != 2, "Invalid arguments!"); DOCHECK(Readnum(bv, args[1]), "Invalid value!"); DOCHECK(bv <0, "BV needs to be >=0"); DOCHECK(!find_matching_vlong_part(args[0], NULL, &id, &brand), "That is no weapon!"); DOCHECK(!IsWeapon(id), "That is no weapon!"); MechWeapons[Weapon2I(id)].battlevalue = bv; notify_printf(player, "BV for %s set to %d.", MechWeapons[Weapon2I(id)].name, bv); }
void debug_setvrt(dbref player, void *data, char *buffer) { char *args[3]; int vrt; int id, brand; DOCHECK(mech_parseattributes(buffer, args, 3) != 2, "Invalid arguments!"); DOCHECK(Readnum(vrt, args[1]), "Invalid value!"); DOCHECK(vrt <= 0, "VRT needs to be >0"); DOCHECK(vrt > 127, "VRT can be at max 127"); DOCHECK(!find_matching_vlong_part(args[0], NULL, &id, &brand), "That is no weapon!"); DOCHECK(!IsWeapon(id), "That is no weapon!"); MechWeapons[Weapon2I(id)].vrt = vrt; notify_printf(player, "VRT for %s set to %d.", MechWeapons[Weapon2I(id)].name, vrt); log_error(LOG_WIZARD, "WIZ", "CHANGE", "VRT for %s set to %d by #%d", MechWeapons[Weapon2I(id)].name, vrt, player); }
int GetBrandIndex(int type) { if(type == -1) return COMPUTER_INDEX; if(type == -2) return RADIO_INDEX; if(IsWeapon(type)) if(type < I2Weapon(num_def_weapons)) { type = Weapon2I(type); if(MechWeapons[type].special & PCOMBAT) return -1; if(IsFlamer(type)) return FLAMMER_INDEX; if(IsEnergy(type)) return ENERGY_INDEX; if(IsAutocannon(type)) return AC_INDEX; if(IsMissile(type)) return MISSILE_INDEX; return -1; } return -1; }
int PageInBitmap (CBitmap *bmP, const char *bmName, int nIndex, int bD1, bool bHires) { CBitmap *altBmP = NULL; int nFile, nSize, nOffset, nFrames, nShrinkFactor, nBestShrinkFactor, bRedone = 0, bTGA; sbyte nFlags; bool bDefault = false; CFile cf, *cfP = &cf; char fn [6][FILENAME_LEN]; #if DBG if (!bmName) return 0; if ((nDbgTexture > 0) && (nIndex == nDbgTexture)) nDbgTexture = nDbgTexture; #endif if (bmP->Buffer ()) return 1; StopTime (); nShrinkFactor = 8 >> min (gameOpts->render.textures.nQuality, gameStates.render.nMaxTextureQuality); if (nShrinkFactor < 4) { if (nShrinkFactor == 1) nShrinkFactor = 2; // cap texture quality at 256x256 (x frame#) else if (IsPowerup (bmName) || IsWeapon (bmName)) // force downscaling of powerup hires textures nShrinkFactor <<= 1; } nSize = (int) bmP->FrameSize (); if (nIndex >= 0) GetFlagData (bmName, nIndex); #if DBG if (strstr (bmName, "metl139")) bmName = bmName; #endif if (gameStates.app.bNostalgia) gameOpts->render.textures.bUseHires [0] = 0; bTGA = 0; nFlags = (nIndex < 0) ? 0 : gameData.pig.tex.bitmapFlags [bD1][nIndex]; if (bmP->Texture ()) bmP->Texture ()->Release (); bmP->SetBPP (1); if ((*bmName && /*!gameStates.app.bDemoData &&*/ ((nIndex < 0) || IsCockpit (bmName) || bHires || gameOpts->render.textures.bUseHires [0])) && !(gameOpts->render.powerups.b3D && IsWeapon (bmName) && !gameStates.app.bHaveMod)) { #if 0 if ((nIndex >= 0) && ReadS3TC (gameData.pig.tex.altBitmaps [bD1] + nIndex, gameFolders.szTextureCacheDir [bD1], bmName)) { altBmP = gameData.pig.tex.altBitmaps [bD1] + nIndex; altBmP->nType = BM_TYPE_ALT; bmP->SetOverride (altBmP); BM_FRAMECOUNT (altBmP) = 1; nFlags &= ~BM_FLAG_RLE; nFlags |= BM_FLAG_TGA; bmP = altBmP; altBmP = NULL; } else #endif if (*gameFolders.szTextureDir [2]) { char szLevelFolder [FILENAME_LEN]; if (gameData.missions.nCurrentLevel < 0) sprintf (szLevelFolder, "slevel%02d", -gameData.missions.nCurrentLevel); else sprintf (szLevelFolder, "level%02d", gameData.missions.nCurrentLevel); sprintf (gameFolders.szTextureDir [3], "%s/%s", gameFolders.szTextureDir [2], szLevelFolder); sprintf (gameFolders.szTextureCacheDir [3], "%s/%s", gameFolders.szTextureCacheDir [2], szLevelFolder); } else *gameFolders.szTextureDir [3] = *gameFolders.szTextureCacheDir [3] = '\0'; MakeBitmapFilenames (bmName, gameFolders.szTextureDir [3], gameFolders.szTextureCacheDir [3], fn [1], fn [0], nShrinkFactor); MakeBitmapFilenames (bmName, gameFolders.szTextureDir [2], gameFolders.szTextureCacheDir [2], fn [3], fn [2], nShrinkFactor); MakeBitmapFilenames (bmName, gameFolders.szTextureDir [bD1], gameFolders.szTextureCacheDir [bD1], fn [5], fn [4], nShrinkFactor); if (0 <= (nFile = OpenBitmapFile (fn, cfP))) { cfP->Close (); PrintLog ("loading hires texture '%s' (quality: %d)\n", fn [nFile], min (gameOpts->render.textures.nQuality, gameStates.render.nMaxTextureQuality)); if (nFile < 2) //was level specific mod folder MakeTexSubFolders (gameFolders.szTextureCacheDir [3]); if (nIndex < 0) altBmP = &gameData.pig.tex.addonBitmaps [-nIndex - 1]; else altBmP = &gameData.pig.tex.altBitmaps [bD1][nIndex]; if (!ReadTGA (fn [nFile], "", altBmP)) { altBmP = NULL; if (!bDefault) cfP->Close (); throw (EX_OUT_OF_MEMORY); } else { bTGA = 1; if (strstr (fn [nFile], "omegblob#") && strstr (fn [nFile], "/mods/")) gameStates.render.bOmegaModded = 1; altBmP->SetType (BM_TYPE_ALT); bmP->SetOverride (altBmP); bmP = altBmP; bmP->DelFlags (BM_FLAG_RLE); nSize = bmP->Size (); nFrames = (bmP->Height () % bmP->Width ()) ? 1 : bmP->Height () / bmP->Width (); bmP->SetFrameCount (ubyte (nFrames)); nOffset = -1; if (nIndex >= 0) { nFlags = bmP->Flags (); if (bmP->Height () > bmP->Width ()) { tEffectClip *ecP = NULL; tWallClip *wcP; tVideoClip *vcP; while ((ecP = FindEffect (ecP, nIndex))) { //e->vc.nFrameCount = nFrames; ecP->flags |= EF_ALTFMT; //ecP->vClipInfo.flags |= WCF_ALTFMT; } if (!ecP) { if ((wcP = FindWallAnim (nIndex))) { //w->nFrameCount = nFrames; wcP->flags |= WCF_ALTFMT; } else if ((vcP = FindVClip (nIndex))) { //v->nFrameCount = nFrames; vcP->flags |= WCF_ALTFMT; } else { PrintLog (" couldn't find animation for '%s'\n", bmName); } } } } } } } if (!altBmP) { if (nIndex < 0) { StartTime (0); return 0; } cfP = cfPiggy + bD1; if (!cfP->File ()) PiggyInitPigFile (NULL); nOffset = bitmapOffsets [bD1][nIndex]; bDefault = true; } bRedone = 1; if ((nOffset >= 0) && cfP->Seek (nOffset, SEEK_SET)) { if (!bDefault) cfP->Close (); throw (EX_IO_ERROR); } #if 1//DBG bmP->SetName (bmName); #endif #if TEXTURE_COMPRESSION if (bmP->Compressed ()) UseBitmapCache (bmP, bmP->CompressedSize ()); else #endif { if (bTGA || bmP->CreateBuffer ()) UseBitmapCache (bmP, nSize); } if (!bmP->Buffer () || (bitmapCacheUsed > bitmapCacheSize)) { if (!bDefault) cfP->Close (); throw (EX_OUT_OF_MEMORY); } if (!bTGA && (nIndex >= 0)) bmP->SetFlags (nFlags); bmP->SetId (nIndex); #if DBG if (nIndex == nDbgTexture) nDbgTexture = nDbgTexture; #endif int i = ReadBitmap (bmP, nSize, cfP, bDefault, bD1 != 0, bHires); if (i) { if (i < 0) { if (!bDefault) cfP->Close (); throw (EX_IO_ERROR); } } else #if TEXTURE_COMPRESSION if (!bmP->Compressed ()) #endif { bmP->SetType (BM_TYPE_ALT); bmP->SetTranspType (-1); if (IsOpaqueDoor (nIndex)) { bmP->DelFlags (BM_FLAG_TRANSPARENT); bmP->TransparentFrames () [0] &= ~1; } #if TEXTURE_COMPRESSION if (CompressTGA (bmP)) bmP->SaveS3TC (gameFolders.szTextureCacheDir [(nFile < 2) ? 3 : (nFile < 4) ? 2 : bD1], bmName); else { #endif nBestShrinkFactor = BestShrinkFactor (bmP, nShrinkFactor); if ((nBestShrinkFactor > 1) && ShrinkTGA (bmP, nBestShrinkFactor, nBestShrinkFactor, 1)) { nSize /= (nBestShrinkFactor * nBestShrinkFactor); if (gameStates.app.bCacheTextures) { tTgaHeader h; memset (&h, 0, sizeof (h)); h.bits = bmP->BPP () * 8; h.width = bmP->Width (); h.height = bmP->Height (); h.imageType = 2; // nFile < 2: mod level texture folder // nFile < 4: mod texture folder // otherwise standard D1 or D2 texture folder SaveTGA (bmName, gameFolders.szTextureCacheDir [(nFile < 2) ? 3 : (nFile < 4) ? 2 : bD1], &h, bmP); } } } #if TEXTURE_COMPRESSION } #endif #if DBG nPrevIndex = nIndex; strcpy (szPrevBm, bmName); #endif tRgbColorf color; if (0 <= (bmP->AvgColor (&color))) bmP->SetAvgColorIndex (ubyte (bmP->Palette ()->ClosestColor (&color))); StartTime (0); if (!bDefault) cfP->Close (); return 1; }
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; }
void Glow::Run() { for (auto i = 0; i < g_GlowObjManager->m_GlowObjectDefinitions.Count(); i++) { auto& glowObject = g_GlowObjManager->m_GlowObjectDefinitions[i]; auto entity = reinterpret_cast<C_BasePlayer*>(glowObject.m_pEntity); glowObject.m_flAlpha = 50.0f; if (glowObject.IsUnused()) continue; if (!entity || entity->IsDormant()) continue; auto class_id = entity->GetClientClass()->m_ClassID; auto color = Color{}; switch (class_id) { case CCSPlayer: { auto is_enemy = entity->m_iTeamNum() != g_LocalPlayer->m_iTeamNum(); if (entity->HasC4() && is_enemy && g_Options.glow_c4_carrier) { color = g_Options.color_glow_c4_carrier; break; } if (!g_Options.glow_players || !entity->IsAlive()) continue; if (!is_enemy && g_Options.glow_enemies_only) continue; color = is_enemy ? g_Options.color_glow_enemy : g_Options.color_glow_ally; break; } case CChicken: if (!g_Options.glow_chickens) continue; entity->m_bShouldGlow() = true; color = g_Options.color_glow_chickens; break; case CBaseAnimating: if (!g_Options.glow_defuse_kits) continue; color = g_Options.color_glow_defuse; break; case CPlantedC4: if (!g_Options.glow_planted_c4) continue; color = g_Options.color_glow_planted_c4; break; case CHostage: if (!g_Options.glow_planted_c4) continue; color = g_Options.color_glow_planted_c4; default: { if (entity->IsWeapon()) { if (!g_Options.glow_weapons) continue; color = g_Options.color_glow_weapons; } } } switch (g_Options.GlowType) { case 0: glowObject.m_nGlowStyle = 0; break; case 1: glowObject.m_nGlowStyle = 2; break; case 2: glowObject.m_nGlowStyle = 1; break; } glowObject.m_flRed = color.r() / 255.0f; glowObject.m_flGreen = color.g() / 255.0f; glowObject.m_flBlue = color.b() / 255.0f; glowObject.m_flAlpha = color.a() / 255.0f; glowObject.m_bRenderWhenOccluded = true; glowObject.m_bRenderWhenUnoccluded = false; } }
func IsSecondaryWeapon() { return IsWeapon() && !IsPrimaryWeapon(); }