// Call this periodically (when haste/slow wears off and when moving between depths) // to keep environmental updates in sync with player turns. public void synchronizePlayerTimeState() { playerCharacter rogue = RogueMain.GetInstance().getRogue(); creature player = RogueMain.GetInstance().getPlayer(); rogue.ticksTillUpdateEnvironment = player.ticksUntilTurn; }
// Inserts a four-character color escape sequence into a string at the insertion point. // Does NOT check string lengths, so it could theoretically write over the null terminator. // Returns the new insertion point. public short encodeMessageColor(char[] msg, short i, color theColor) { playerCharacter rogue = RogueMain.GetInstance().getRogue(); bool needTerminator = false; color col = theColor; // color col = *theColor; short oldRNG = rogue.RNG; rogue.RNG = (short)RNGs.RNG_COSMETIC; //assureCosmeticRNG; bakeColor(col); col.red = (short)Random.clamp(col.red, 0, 100); col.green = (short)Random.clamp(col.green, 0, 100); col.blue = (short)Random.clamp(col.blue, 0, 100); needTerminator = msg[i] == 0 || msg[i + 1] == 0 || msg[i + 2] == 0 || msg[i + 3] == 0; msg[i++] = (char)RogueH.COLOR_ESCAPE; msg[i++] = (char)(RogueH.COLOR_VALUE_INTERCEPT + col.red); msg[i++] = (char)(RogueH.COLOR_VALUE_INTERCEPT + col.green); msg[i++] = (char)(RogueH.COLOR_VALUE_INTERCEPT + col.blue); if (needTerminator) { msg[i] = '\0'; } rogue.RNG = oldRNG; //restoreRNG; return(i); }
public static void Main(string[] args) { Global.preInitData(); playerCharacter rogue = RogueMain.GetInstance().getRogue(); rogue.nextGameSeed = 0; // Seed based on clock. RogueMain.GetInstance().initializeRogue(rogue.nextGameSeed); RogueMain.GetInstance().startLevel(rogue.depthLevel, 1); }
// sets miner's light strength and characteristics based on rings of illumination, scrolls of darkness and water submersion public void updateMinersLightRadius() { playerCharacter rogue = RogueMain.GetInstance().getRogue(); creature player = RogueMain.GetInstance().getPlayer(); double fraction; double lightRadius; lightRadius = 100 * rogue.minersLightRadius; if (rogue.lightMultiplier < 0) { lightRadius /= (-1 * rogue.lightMultiplier + 1); } else { lightRadius *= (rogue.lightMultiplier); lightRadius = Math.Max(lightRadius, (rogue.lightMultiplier * 2 + 2)); } if (player.status[STATUS_DARKNESS] != 0) { fraction = (double)Math.Pow(1.0 - (((double)player.status[STATUS_DARKNESS]) / player.maxStatus[STATUS_DARKNESS]), 3); if (fraction < 0.05) { fraction = 0.05; } } else { fraction = 1; } lightRadius = lightRadius * fraction; if (lightRadius < 2) { lightRadius = 2; } if (rogue.inWater && lightRadius > 3) { lightRadius = Math.Max(lightRadius / 2, 3); } rogue.minersLight.radialFadeToPercent = (short)(35 + Math.Max(0, Math.Min(65, rogue.lightMultiplier * 5)) * (fraction + RogueH.FLOAT_FUDGE)); rogue.minersLight.lightRadius.upperBound = rogue.minersLight.lightRadius.lowerBound = (short)Random.clamp(lightRadius + RogueH.FLOAT_FUDGE, -30000, 30000); }
} // // Highlight the portion indicated by hiliteCharGrid with the hiliteColor at the hiliteStrength -- both latter arguments are optional. public void hiliteGrid(short[][] grid, color hiliteColor, int hiliteStrength) { playerCharacter rogue = RogueMain.GetInstance().getRogue(); short i, j, x, y; color hCol = new color(); short oldRNG = rogue.RNG; rogue.RNG = RNG_COSMETIC; //assureCosmeticRNG; if (hiliteColor != null) { ObjectCopier.CopyFrom(hCol, hiliteColor); } else { ObjectCopier.CopyFrom(hCol, Global.yellow); } IO.GetInstance().bakeColor(hCol); if (hiliteStrength == 0) { hiliteStrength = 75; } for (i = 0; i < DCOLS; i++) { for (j = 0; j < DROWS; j++) { if (grid[i][j] != 0) { x = (short)IO.GetInstance().mapToWindowX(i); y = (short)IO.GetInstance().mapToWindowY(j); displayBuffer[x, y].needsUpdate = true; displayBuffer[x, y].backColorComponents[0] = (char)Random.clamp(displayBuffer[x, y].backColorComponents[0] + hCol.red * hiliteStrength / 100, 0, 100); displayBuffer[x, y].backColorComponents[1] = (char)Random.clamp(displayBuffer[x, y].backColorComponents[1] + hCol.green * hiliteStrength / 100, 0, 100); displayBuffer[x, y].backColorComponents[2] = (char)Random.clamp(displayBuffer[x, y].backColorComponents[2] + hCol.blue * hiliteStrength / 100, 0, 100); displayBuffer[x, y].foreColorComponents[0] = (char)Random.clamp(displayBuffer[x, y].foreColorComponents[0] + hCol.red * hiliteStrength / 100, 0, 100); displayBuffer[x, y].foreColorComponents[1] = (char)Random.clamp(displayBuffer[x, y].foreColorComponents[1] + hCol.green * hiliteStrength / 100, 0, 100); displayBuffer[x, y].foreColorComponents[2] = (char)Random.clamp(displayBuffer[x, y].foreColorComponents[2] + hCol.blue * hiliteStrength / 100, 0, 100); } } } rogue.RNG = oldRNG; //restoreRNG; }
public static int rand_range(int lowerBound, int upperBound) { //brogueAssert(lowerBound <= INT_MAX && upperBound <= INT_MAX); if (upperBound <= lowerBound) { return(lowerBound); } /* nouse * if (rogue.RNG == RNG_SUBSTANTIVE) { * randomNumbersGenerated++; * } * //*/ playerCharacter rogue = RogueMain.GetInstance().getRogue(); return(RNGState [rogue.RNG].Next(lowerBound, upperBound + 1)); }