public static void CheckEncounter(Point tilepos, clsSprite.dir dir) { string[] levelname = clsGame.level.levelname.ToString().Split('-'); //TODO: check if tilepos is next to NPC //check for house if (levelname[0] == "world") { if (clsGame.player.TilePosition.Y != clsGame.map.height - 1) { //check if tilepos is tall grass //if so, check for Edjimon //add 1 so the bottom tile of the sprite is used if (clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y + 1] == 1) { //if you found one if (CheckEdjimon()) { clsGame.inbattle = true; clsEdjimon wildedjimon = DetermineEdjimon(); clsBattle b = new clsBattle(clsGame.player.edjimon[0], wildedjimon); } } if (clsGame.player.TilePosition.Y + 1 != 0 && dir == clsSprite.dir.Up && clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y] == 16) { oldpos = tilepos; clsGame.level.LoadLevel("house-1"); clsGame.player.inmotion = false; } } } //try to leave house if (levelname[0] == "house" && clsGame.player.TilePosition.Y != clsGame.map.height) { //do individual house-X checks inside here switch(dir) { case clsSprite.dir.Up: if (clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y] == 4) { clsGame.level.LoadLevel("world-1"); clsGame.player.position.X = oldpos.X * 30; clsGame.player.position.Y = (oldpos.Y) * 30; //clsGame.player.inmotion = false; } break; case clsSprite.dir.Down: if (clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y + 2] == 4) { clsGame.level.LoadLevel("world-1"); clsGame.player.position.X = oldpos.X * 30; clsGame.player.position.Y = (oldpos.Y) * 30; //clsGame.player.inmotion = false; } break; } } }
// ,bool wild) /// <summary> /// Determines the results of each attack in a battle. /// </summary> /// <param name="attacker">Type of the attacker's move</param> /// <param name="defender">Type of the defender</param> /// <param name="acc">Attacker's accuracy rating</param> /// <param name="cel">Defender's evasiveness rating</param> // /// <param name="wild">Wild Edjimon or trainer?</param> /// <returns>Amount of HP lost to defender. A negative number signifies Attacker's loss.</returns> public static int Attack(clsBattle.type attacker, clsBattle.type defender, int acc , int cel) { double hp_loss = 0; //TODO: Simulate emotion, weather, injuries with percentage. //The chance is simply based on weather double chance = ProbableAttack(/*see TODO at definition*/); /* Chance increases in a non-linear manner. * The more accurate the chance, the smaller the * effect of your accuracy rating has on the * attack hit possibility. Additionally, CEL value is * less and less effective as the accuracy increases. */ chance += ((100 - chance) * ((double)acc / 100)); chance -= ((100 - chance) * ((double)cel / 100)); if (ProbableAttack() < (int)chance) { //custom formula to calculate HP lost in an attack hp_loss = (double)Math.Abs((decimal)((((clsBattle.B_enemy.attack - clsBattle.B_player.defense) * .5)) * (typematrix[(int)attacker, (int)defender]))); } return (int)hp_loss; }