void BubbleOut(int32_t tx, int32_t ty) { // No bubbles from nowhere if (!GBackSemiSolid(tx, ty)) return; // User-defined smoke level int32_t SmokeLevel = GetSmokeLevel(); // Enough bubbles out there already if (Game.Objects.ObjectCount(C4Id("FXU1")) >= SmokeLevel) return; // Create bubble Game.CreateObject(C4Id("FXU1"), NULL, NO_OWNER, tx, ty); }
void C4GraphicsOverlay::Read(const char **ppInput) { // deprecated assert(false && "C4GraphicsOverlay::Read: deprecated"); #if 0 const char *szReadFrom = *ppInput; // defaults eMode = MODE_None; pSourceGfx = NULL; *Action=0; dwBlitMode = 0; iPhase = 0; iID=0; // read ID SCopyUntil(szReadFrom, OSTR, ',', C4MaxName); szReadFrom += strlen(OSTR); if (*szReadFrom) ++szReadFrom; sscanf(OSTR, "%i", &iID); // read C4ID::Gfxname int32_t iLineLength = SLen(szReadFrom); // not C4ID::Name? if (iLineLength < 6 || szReadFrom[4]!=':' || szReadFrom[5]!=':') { DebugLog("C4Compiler error: Malformed graphics overlay definition!"); return; } // get ID char id[5]; SCopy(szReadFrom, id, 4); szReadFrom += 6; C4Def *pSrcDef = ::Definitions.ID2Def(C4Id(id)); // defaults to NULL for unloaded def if (pSrcDef) { char GfxName[C4MaxName+1]; SCopyUntil(szReadFrom, GfxName, ',', C4MaxName); szReadFrom += strlen(GfxName); if (*szReadFrom) ++szReadFrom; // get graphics - "C4ID::" leads to *szLine == NULL, and thus the default graphic of pSrcDef! pSourceGfx = pSrcDef->Graphics.Get(GfxName); } // read mode DWORD dwRead; SCopyUntil(szReadFrom, OSTR, ',', C4MaxName); szReadFrom += strlen(OSTR); if (*szReadFrom) ++szReadFrom; sscanf(OSTR, "%i", &dwRead); eMode = (Mode) dwRead; // read action SCopyUntil(szReadFrom, Action, ',', C4MaxName); szReadFrom += strlen(Action); if (*szReadFrom) ++szReadFrom; // read blit mode SCopyUntil(szReadFrom, OSTR, ',', C4MaxName); szReadFrom += strlen(OSTR); if (*szReadFrom) ++szReadFrom; sscanf(OSTR, "%i", &dwBlitMode); // read phase SCopyUntil(szReadFrom, OSTR, ',', C4MaxName); szReadFrom += strlen(OSTR); if (*szReadFrom) ++szReadFrom; sscanf(OSTR, "%i", &iPhase); // read transform if (*szReadFrom) ++szReadFrom; // '(' int32_t iScanCnt = sscanf(szReadFrom, "%f,%f,%f,%f,%f,%f,%d", &Transform.mat[0], &Transform.mat[1], &Transform.mat[2], &Transform.mat[3], &Transform.mat[4], &Transform.mat[5], &Transform.FlipDir); if (iScanCnt != 7) { DebugLog("C4Compiler: malformed C4CV_Transform"); } iScanCnt = SCharPos(')', szReadFrom); if (iScanCnt>=0) szReadFrom += iScanCnt+1; // assign ptr immediately after read overlay *ppInput = szReadFrom; // update used facet according to read data UpdateFacet(); #endif }
void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr) { if (Game.Particles.pSmoke) { Game.Particles.Create(Game.Particles.pSmoke, float(tx), float(ty) - level / 2, 0.0f, 0.0f, float(level), dwClr); return; } // User-defined smoke level int32_t SmokeLevel = GetSmokeLevel(); // Enough smoke out there already if (Game.Objects.ObjectCount(C4Id("FXS1")) >= SmokeLevel) return; // Create smoke level = BoundBy<int32_t>(level, 3, 32); C4Object *pObj; if (pObj = Game.CreateObjectConstruction(C4Id("FXS1"), NULL, NO_OWNER, tx, ty, FullCon * level / 32)) pObj->Call(PSF_Activate); }
void Explosion(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t iCausedBy, C4Object *pByObj, C4ID idEffect, const char *szEffect) { int32_t grade = BoundBy((level / 10) - 1, 1, 3); // Sound StdStrBuf sound = FormatString("Blast%c", '0' + grade); StartSoundEffect(sound.getData(), false, 100, pByObj); // Check blast containment C4Object *container = inobj; while (container && !container->Def->ContainBlast) container = container->Contained; // Uncontained blast effects if (!container) { // Incinerate landscape if (!Game.Landscape.Incinerate(tx, ty)) if (!Game.Landscape.Incinerate(tx, ty - 10)) if (!Game.Landscape.Incinerate(tx - 5, ty - 5)) Game.Landscape.Incinerate(tx + 5, ty - 5); // Create blast object or particle C4Object *pBlast; C4ParticleDef *pPrtDef = Game.Particles.pBlast; // particle override if (szEffect) { C4ParticleDef *pPrtDef2 = Game.Particles.GetDef(szEffect); if (pPrtDef2) pPrtDef = pPrtDef2; } else if (idEffect) pPrtDef = NULL; // create particle if (pPrtDef) { Game.Particles.Create(pPrtDef, (float)tx, (float)ty, 0.0f, 0.0f, (float)level, 0); if (SEqual2(pPrtDef->Name.getData(), "Blast")) Game.Particles.Cast(Game.Particles.pFSpark, level / 5 + 1, (float)tx, (float)ty, level, level / 2 + 1.0f, 0x00ef0000, level + 1.0f, 0xffff1010); } else if (pBlast = Game.CreateObjectConstruction( idEffect ? idEffect : C4Id("FXB1"), pByObj, iCausedBy, tx, ty + level, FullCon * level / 20)) pBlast->Call(PSF_Activate); } // Blast objects Game.BlastObjects(tx, ty, level, inobj, iCausedBy, pByObj); if (container != inobj) Game.BlastObjects(tx, ty, level, container, iCausedBy, pByObj); if (!container) { // Blast free landscape. After blasting objects so newly mined materials // don't get flinged Game.Landscape.BlastFree(tx, ty, level, grade, iCausedBy); } }
BOOL C4SGame::IsMelee() { return (Goals.GetIDCount(C4Id("MELE")) || Goals.GetIDCount(C4Id("MEL2"))); }
void C4SGame::ConvertGoals(C4SRealism &rRealism) { // Convert mode to goals switch (Mode) { case C4S_Melee: Goals.SetIDCount(C4Id("MELE"),1,TRUE); ClearOldGoals(); break; case C4S_MeleeTeamwork: Goals.SetIDCount(C4Id("MELE"),1,TRUE); ClearOldGoals(); break; } Mode=0; // Convert goals (master selection) switch (CooperativeGoal) { case C4S_Goldmine: Goals.SetIDCount(C4Id("GLDM"),1,TRUE); ClearOldGoals(); break; case C4S_Monsterkill: Goals.SetIDCount(C4Id("MNTK"),1,TRUE); ClearOldGoals(); break; case C4S_ValueGain: Goals.SetIDCount(C4Id("VALG"),Max(ValueGain/100,1),TRUE); ClearOldGoals(); break; } CooperativeGoal=0; // CreateObjects,ClearObjects,ClearMaterials are still valid but invisible // Convert realism to rules if (rRealism.ConstructionNeedsMaterial) Rules.SetIDCount(C4Id("CNMT"),1,TRUE); rRealism.ConstructionNeedsMaterial=0; if (rRealism.StructuresNeedEnergy) Rules.SetIDCount(C4Id("ENRG"),1,TRUE); rRealism.StructuresNeedEnergy=0; // Convert rules if (EnableRemoveFlag) Rules.SetIDCount(C4Id("FGRV"),1,TRUE); EnableRemoveFlag=0; // Convert eliminiation to rules switch (Elimination) { case C4S_KillTheCaptain: Rules.SetIDCount(C4Id("KILC"),1,TRUE); break; case C4S_CaptureTheFlag: Rules.SetIDCount(C4Id("CTFL"),1,TRUE); break; } Elimination=1; // unconvertible default crew elimination // CaptureTheFlag requires FlagRemoveable if (Rules.GetIDCount(C4Id("CTFL"))) Rules.SetIDCount(C4Id("FGRV"),1,TRUE); }