public void UseTile(Player p, int x, int y) { switch (type) { case 329: p.anchored_to = new Vector2(x, y); break; } }
public static void CheckChunks(Player p) { //Get player pos int chunk_x = (int)Math.Truncate(p.pos.X / chunksize); int chunk_y = (int)Math.Truncate(p.pos.Y / chunksize); { for (int x = 0; x < chunksize; x++) { for (int y = 0; y < chunksize; y++) { for (int z = -1; z < 3; z++) { for (int w = -1; w < 3; w++) { int i = (z * chunksize + x) + (chunk_x * chunksize); int j = (w * chunksize + y) + (chunk_y * chunksize); //Gas physics //Liquid physics Main.gas_counter--; if (Main.gas_counter < 0 && Main.init) { Main.gas_counter = 30; try { if (world[i, j] == 247) { if (world[i, j - 1] == 0) { if (Main.rand.Next(2) == 0) { world[i, j - 1] = 242; } } if (world[i, j + 1] == 0) { if (Main.rand.Next(2) == 0) { world[i, j + 1] = 242; } } if (world[i - 1, j] == 0) { if (Main.rand.Next(2) == 0) { world[i - 1, j] = 242; } } if (world[i + 1, j] == 0) { if (Main.rand.Next(2) == 0) { world[i + 1, j] = 242; } } } else if (world[i, j] == 248) { if (world[i, j - 1] == 0) { if (Main.rand.Next(2) == 0) { world[i, j - 1] = 239; } } if (world[i, j + 1] == 0) { if (Main.rand.Next(2) == 0) { world[i, j + 1] = 239; } } if (world[i - 1, j] == 0) { if (Main.rand.Next(2) == 0) { world[i - 1, j] = 239; } } if (world[i + 1, j] == 0) { if (Main.rand.Next(2) == 0) { world[i + 1, j] = 239; } } } if (world[i, j] == 249) { if (Tile.tiles[world[i, j - 1]].gaseous) { world[i, j - 1] = 240; } if (Tile.tiles[world[i, j + 1]].gaseous) { world[i, j + 1] = 240; } if (Tile.tiles[world[i - 1, j]].gaseous) { world[i - 1, j] = 240; } if (Tile.tiles[world[i + 1, j]].gaseous) { world[i + 1, j] = 240; } } if (world[i, j] == 250) { if (Tile.tiles[world[i, j - 1]].gaseous) { world[i + 1, j] = world[i, j - 1]; world[i - 1, j] = world[i, j - 1]; } } if (Tile.tiles[world[i, j]].gaseous && Tile.tiles[world[i, j]].flammable) { if (world[i, j + 1] == 238 || world[i, j - 1] == 238 || world[i + 1, j] == 238 || world[i - 1, j] == 238) { world[i, j] = 238; } } if (Tile.tiles[world[i, j]].heavy_gas) { if (Tile.tiles[world[i, j]].gaseous && !Tile.tiles[world[i, j + 1]].solid) { world[i, j + 1] = world[i, j]; } else if (Tile.tiles[world[i, j]].gaseous && world[i, j + 1] != 0) { if (!Tile.tiles[world[i - 1, j]].solid) { world[i - 1, j] = world[i, j]; } if (!Tile.tiles[world[i + 1, j]].solid) { world[i + 1, j] = world[i, j]; } } } else { if (Tile.tiles[world[i, j]].gaseous && !Tile.tiles[world[i, j - 1]].solid) { world[i, j - 1] = world[i, j]; } else if (Tile.tiles[world[i, j]].gaseous && world[i, j - 1] != 0) { if (!Tile.tiles[world[i - 1, j]].solid) { world[i - 1, j] = world[i, j]; } if (!Tile.tiles[world[i + 1, j]].solid) { world[i + 1, j] = world[i, j]; } } } if (Tile.tiles[world[i, j]].gaseous) { if (i == 0 || i == chunksize - 1 || j == 0 || j == chunksize - 1 || Main.rand.Next(8500) < 8000) { world[i, j] = 0; } } } catch { } } //if (Main.init) //{ // //Check power // if (Tile.tiles[world[i, j]].produce_power) // { // powered[i, j] = true; // powered[i, j + 1] = true; // powered[i, j - 1] = true; // powered[i + 1, j] = true; // powered[i - 1, j] = true; // } // else // { // powered[i, j] = false; // powered[i, j + 1] = false; // powered[i, j - 1] = false; // powered[i + 1, j] = false; // powered[i - 1, j] = false; // } // if ((powered[i, j - 1] || powered[i, j + 1] || powered[i + 1, j] || powered[i - 1, j]) && Tile.tiles[world[i, j]].conduct_elec) // { // powered[i, j] = true; // } // else if (Tile.tiles[world[i, j]].conduct_elec) // { // powered[i, j] = false; // } // //Now for special effects // if (powered[i, j]) // { // Tile.tiles[world[i, j]].OnPowered(i, j); // } //} //Crop growth code if (world[i, j] >= 252 && world[i, j] <= 275) { if (world[i, j] >= 252 && world[i, j] <= 258) { if (Main.rand.Next(3000) == 0) { world[i, j]++; } if (world[i, j + 1] != 1 && world[i, j + 1] != 43) { DestroyTile(i, j); } } else if (world[i, j] >= 260 && world[i, j] <= 266) { if (Main.rand.Next(3000) == 0) { world[i, j]++; } if (world[i, j + 1] != 1 && world[i, j + 1] != 43) { DestroyTile(i, j); } } else if (world[i, j] >= 268 && world[i, j] <= 274) { if (Main.rand.Next(3000) == 0) { world[i, j]++; } if (world[i, j + 1] != 1 && world[i, j + 1] != 43) { DestroyTile(i, j); } } } if (Main.init) { sand_counter--; if (sand_counter < 0) { if (Tile.tiles[world[i, j]].gravity && !Tile.tiles[world[i, j + 1]].solid) { world[i, j + 1] = world[i, j]; world[i, j] = 0; } sand_counter = 6; } } int t = world[x + (chunk_x * chunksize), y + (chunk_y * chunksize)]; int h; //For trees //Weed growing /* if (Main.rand.Next(60) == 0) { if (y + (chunk_y * chunksize) < max_height / 2) { if (world[i, j + 1] == 1) { world[i, j] = 31 + Main.rand.Next(6); } } } */ /* try { //Making sure there's a trunk to the tree if (Tile.tiles[world[i, j]].gravity) { if (!Tile.tiles[world[i, j + 1]].solid) { world[i, j + 1] = world[i, j]; world[i, j] = 0; Logger.Write("Tile ID " + Tile.tiles[t].type + " affected by gravity and goes to " + i + "/" + j, "TILE"); } } } catch { } */ if (world[i, j] == 47 || world[i, j] == 50) { if (world[i, j + 1] != 20 && world[i, j + 1] != 47) { DestroyTile(i, j); } } if (world[i, j] == 51) { if (world[i, j + 1] != 51 && world[i, j + 1] != 43 && world[i, j + 1] != 21) { DestroyTile(i, j); } } if (world[i, j] == 25) //If it's tree trunk { if (world[i, j + 1] != 25 && world[i, j + 1] != 1 && world[i, j + 1] != 43 && world[i, j + 1] != 38) { DestroyTile(i, j); Logger.Write("Tree chopped at " + i + "/" + j, "TILE"); } } if (world[x + (chunk_x * chunksize), y + (chunk_y * chunksize)] == 1) { if (world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 1] == 0) { if (Main.rand.Next(120) == 0) { Logger.Write("Grass grew on " + (x + chunk_x * chunksize) + "/" + (y + chunk_y * chunksize), "TILE"); } } } if (world[i, j] == 26 || world[i, j] == 30) //If it's branches { if (world[i + 1, j] != 25 && world[i - 1, j] != 25) { DestroyTile(i, j); } } //Tree growing for that chunk if (t == 29) { int b_t = world[i, j + 2]; if (Main.rand.Next(Main.rand.Next(800, 8000)) == 0) { Logger.Write("Tree grown at " + i + "/" + j, "TILE"); world[x + (chunk_x * chunksize), y + (chunk_y * chunksize)] = 25; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) + 1] = 25; h = Main.rand.Next(6, 18); if (b_t == 43) { h += Main.rand.Next(8, 14); } if (b_t == 38) { h += Main.rand.Next(6, 10); } for (int a = 0; a < h; a++) { world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 1 - a] = 25; if (Main.rand.Next(4) == 0) { if (Main.rand.Next(2) == 0) { world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 1 - a] = 26; } else { world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 1 - a] = 30; } } } if (b_t == 1 || b_t == 38) { world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 1 - h] = 27; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 2 - h] = 27; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 3 - h] = 27; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 1 - h] = 27; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 2 - h] = 27; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 3 - h] = 27; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 1 - h] = 27; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 2 - h] = 27; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 3 - h] = 27; } else if (b_t == 43) { world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 1 - h] = 44; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 2 - h] = 44; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 3 - h] = 44; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 4 - h] = 44; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 5 - h] = 44; world[x + (chunk_x * chunksize), y + (chunk_y * chunksize) - 6 - h] = 44; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 1 - h] = 44; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 2 - h] = 44; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 3 - h] = 44; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 1 - h] = 44; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 2 - h] = 44; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 3 - h] = 44; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 4 - h] = 44; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 5 - h] = 44; world[x + (chunk_x * chunksize) - 1, y + (chunk_y * chunksize) - 6 - h] = 44; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 4 - h] = 44; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 5 - h] = 44; world[x + (chunk_x * chunksize) + 1, y + (chunk_y * chunksize) - 6 - h] = 44; world[x + (chunk_x * chunksize) - 2, y + (chunk_y * chunksize) - 1 - h] = 44; world[x + (chunk_x * chunksize) - 2, y + (chunk_y * chunksize) - 2 - h] = 44; world[x + (chunk_x * chunksize) - 2, y + (chunk_y * chunksize) - 3 - h] = 44; world[x + (chunk_x * chunksize) + 2, y + (chunk_y * chunksize) - 1 - h] = 44; world[x + (chunk_x * chunksize) + 2, y + (chunk_y * chunksize) - 2 - h] = 44; world[x + (chunk_x * chunksize) + 2, y + (chunk_y * chunksize) - 3 - h] = 44; world[x + (chunk_x * chunksize) - 2, y + (chunk_y * chunksize) - 4 - h] = 44; world[x + (chunk_x * chunksize) - 2, y + (chunk_y * chunksize) - 5 - h] = 44; world[x + (chunk_x * chunksize) - 2, y + (chunk_y * chunksize) - 6 - h] = 44; world[x + (chunk_x * chunksize) + 2, y + (chunk_y * chunksize) - 4 - h] = 44; world[x + (chunk_x * chunksize) + 2, y + (chunk_y * chunksize) - 5 - h] = 44; world[x + (chunk_x * chunksize) + 2, y + (chunk_y * chunksize) - 6 - h] = 44; } } } } } } } } }
public static void SaveAndExit(Player p) { //UnloadChunk((int)Math.Truncate(p.pos.X / chunksize), (int)Math.Truncate(p.pos.Y / chunksize)); /* for (int x = 0; x < max_width; x++) { for (int y = 0; y < max_height; y++) { if (alreadygen[x, y]) { s.WriteLine(world[x, y]); } else {r s.WriteLine(-1); } } } */ }
public static void SetDefaults(Player p) { switch (p.inventory[0, p.selecteditem].type) { case 2: break; } }
public static Player CreateNew(string name) { Player myPlayer = new Player(); myPlayer.p_name = name; Directory.CreateDirectory(Config.rootfolder + Config.savefolder + Config.playerdata + "/" + name); Achievement.SaveAchivements(); for (int x = 0; x < weaponClasses.Length; x++) { myPlayer.classlevels[x] = 1; myPlayer.classreqexp[x] = 8; myPlayer.classexp[x] = 0; } for (int x = 0; x < 9; x++) { for (int y = 0; y < 4; y++) { myPlayer.dyecolor[y, x] = Color.White; myPlayer.displayname[y, x] = ""; } } myPlayer.ApplyEffects(); Logger.Write("Player " + name + " created", "PLAYER"); //myPlayer.journal.s = new StreamWriter(Config.rootfolder + Config.savefolder + Config.globalfolder + Config.journal + "/The Journal of " + name + Config.save_journal); //myPlayer.journal.s.Close(); return myPlayer; }
public int BarterPrice(Player p, Item i, bool night) { int rep = (int)MathHelper.Clamp((float)p.species.actualrep, 10000, 0); int val = i.value; double friendliness = Main.rand.NextDouble(); double actualval = val; double barterpower = 0; //Calc some fun! First we calculate the barter power, calculated through friendliness and reputation barterpower = ((rep / 10000) * 100) * friendliness; barterpower /= (rep / 10000) * 100; //This gives us a percent value, that we now add or subtract some to int spec = Main.rand.Next((int)((barterpower * 100) / 4)); double actual_spec = spec / 100; double updateprice; int re_val; if (Main.rand.Next(2) == 0) { updateprice = (barterpower - actual_spec) * val; } else { updateprice = (barterpower + actual_spec) * val; } re_val = (int)updateprice; double d_re_val = re_val; double b = p.barter / 1000; d_re_val *= 1 - b; re_val = (int)d_re_val; if (!night) { return re_val; } else { if (Main.rand.Next(2) == 0) { re_val += (int)(re_val * Main.rand.NextDouble()); } else { re_val -= (int)(re_val * Main.rand.NextDouble()); } return re_val; } }
public static void DamageNPC(int id, int damage, float knockback, Item i, Player player) { int actual_damage = damage - (npcs[id].defense / 2); if (Main.rand.Next(3) == 0) { actual_damage += Main.rand.Next(actual_damage / 4); } else if (Main.rand.Next(3) == 1) { actual_damage -= Main.rand.Next(actual_damage / 4); } if (i.meleeDmg + i.magicDmg + i.rangedDmg > 0) { player.classexp[i.classtype] += damage; if (actual_damage < 1) { actual_damage = 1; } npcs[id].health -= actual_damage; //public bool poison; //public bool shock; //public bool fire; //public bool ice; //public bool air; //public bool darkness; //public bool draining; //public bool paralyze; //public bool magicka; //public bool infected; if (i.poison) { npcs[id].poisoned = true; } if (i.shock) { npcs[id].mana -= actual_damage / 2; } if (i.fire) { npcs[id].on_fire = true; } if (i.ice) { npcs[id].on_ice = true; } if (i.air) { knockback *= 5; } if (i.darkness) { npcs[id].blind = true; } if (i.draining) { player.health += actual_damage / 2; } if (i.paralyze) { if (Main.rand.Next(5) == 0) { npcs[id].paralyze = true; } } if (i.magicka) { if (Main.rand.Next(8) < 2) { npcs[id].health += npcs[id].mana; npcs[id].mana = 0; } } if (i.infected) { if (Main.rand.Next(6) == 0) { npcs[id].infected = true; } } if (npcs[id].health < 0) { npcs[id].KillNPC(); } } npcs[id].hit_sound.Play(); return; }
public void SetStats(Player p) { hometown += " " + settlements[Main.rand.Next(settlements.Length)]; if (species_num != 0) { //Each species is built for a certain class //Anatren- Assassin //Zanterrian- Mage //Maj'Talak- Ranger //Candelia/Ihaji- Scout //Armoni- Heavy Defense //Poaxinar- Warrior //Avianatrix- Archer //Feloform- Thief //Nalapin- Underground Fighter //Mahamata- Ninja //Rajin- Monk //Kala'han- Endurance if (species_num == 1) { //Built to be an assassin name = "Anatren"; meleeboost += 5; rangedboost -= 5; speedboost += 0.1f; knockbackboost -= 0.1f; } else if (species_num == 2) { //A heavy magic user name = "Zanterrian"; meleeboost -= 6; rangedboost -= 6; magicboost += 4; manaup_crystal += 5; manaboost += 10; } else if (species_num == 3) { //Raiders from the deserts that abhorr magic horribly name = "Maj'Talak"; speedboost += 0.25f; rangedboost += 4; meleeboost += 4; magicboost -= 10; manaup_crystal = 0; } else if (species_num == 4) { //People of flame that are strong in fire, but are greatly weakened in the cold and in water name = "Candelia"; firestrong = true; lavastrong = true; coldweak = true; waterweak = true; stronginhell = true; weakinsky = true; lavatic = true; } else if (species_num == 5) { //People of ice that are strong in water, but weakend in fire name = "Ihaji"; fireweak = true; lavaweak = true; coldstrong = true; waterstrong = true; weakinhell = true; stronginsky = true; aquatic = true; } else if (species_num == 6) { //Imperial soldiers that are grafted to armor. They sacrifice a ton of speed though name = "Armoni"; defenseboost += 6; speedboost -= 0.8f; } else if (species_num == 7) { //Powertanks ineffecient in ranged and magic, but brutally powerful in melee. name = "Poaxinar"; defenseboost += 6; speedboost -= 0.8f; magicboost -= 5; rangedboost -= 5; meleeboost += 8; } else if (species_num == 8) { //If you play ranged and nothing else, this is for you. Sacrifices defense, melee, and magic for speed and ranged name = "Avianatrix"; defenseboost -= 6; speedboost += 0.8f; magicboost -= 5; meleeboost -= 5; rangedboost += 8; } else if (species_num == 9) { //The Feloforms trade no fall damage and high speed for decreased defense and increased knockback suffering name = "Feloform"; noFallDmg = true; speedboost += 0.4f; defenseboost -= 4; knockbackresist -= 0.4f; } else if (species_num == 10) { //Nalapins are greatly strengthend underground, but are tremendously weakend on the surface name = "Nalapin"; gravcontrol = true; stronginhell = true; waterweak = true; coldweak = true; weakinsky = true; } else if (species_num == 11) { //Mahamatas are strong with thrown and melee weapons, but with magic and ranged they are lacking. name = "Mahamata"; thrownboost += 4; meleeboost += 4; magicboost -= 5; rangedboost -= 5; speedboost += 0.1f; } else if (species_num == 12) { //Rajin are moderatley strong in melee, but are horrible in magic. Their advantage is that they increase their health faster and have more health name = "Rajin"; meleeboost += 3; magicboost -= 10; manaboost = 0; manaup_crystal = 0; healthboost += 20; healthup_crystal += 15; } else if (species_num == 13) { //Kala'han have more health, but get mana faster. Their downside is that they sacrifice speed name = "Kala'han"; healthboost += 20; manaup_crystal += 10; speedboost -= 0.4f; knockbackresist -= 0.6f; } else if (species_num == 14) { name = "Naga"; healthboost += 10; aquatic = true; waterstrong = true; lavaweak = true; near_incinerate = true; } } else { name = "Human"; } if (p_rank != "Villager") { } }
public void UpdateStats(Player p) { actualrep = goodrep - badrep; if (actualrep == 0) { rep_title = "Unknown"; } else if (actualrep > 0 && actualrep < 100) { rep_title = "Slightly Heroic"; } else if (actualrep < 250) { rep_title = "Heroic"; } else if (actualrep < 500) { rep_title = "Very Heroic"; } else if (actualrep < 1000) { rep_title = "Slightly Famous"; } else if (actualrep < 1500) { rep_title = "Famous"; } else if (actualrep < 2500) { rep_title = "Very Famous"; } else if (actualrep < 5000) { rep_title = "Legendary"; } else if (actualrep < 7500) { rep_title = "Mythical"; } else if (actualrep < 10000) { rep_title = "Immortal Legend"; } else if (actualrep >= 10000) { rep_title = "Unforgotten Legend"; } else if (actualrep < 0 && actualrep > -100) { rep_title = "Slimeball"; } else if (actualrep > -250 && actualrep < 0) { rep_title = "Lowly Thief"; } else if (actualrep > -500 && actualrep < 0) { rep_title = "Thief"; } else if (actualrep > -1000 && actualrep < 0) { rep_title = "Slightly Infamous"; } else if (actualrep > -1500 && actualrep < 0) { rep_title = "Infamous"; } else if (actualrep > -2500 && actualrep < 0) { rep_title = "Very Infamous"; } else if (actualrep > -5000 && actualrep < 0) { rep_title = "Feared Legend"; } else if (actualrep > -7500 && actualrep < 0) { rep_title = "Very Feared Legend"; } else if (actualrep > -10000 && actualrep < 0) { rep_title = "Immortal Legend of Darkness"; } else if (actualrep <= -10000) { rep_title = "Unforgotten Legend of Darkness"; } }