#region chi npc case 4444: { dialog.avatar(218); switch (npcrequest.optionid) { case 0: { if (client.chipowers.count == 0) { dialog.text("sorry but you don't have chi yet."); dialog.option("i'll think about it!", 255); dialog.send(); return; } dialog.text("hello i'm chi seller."); for (int i = 0; i < client.chipowers.count; i++) { var stage = client.chipowers[i]; dialog.option(((game.enums.chipowertype)(i + 1)).tostring(), (byte)(i + 1)); } dialog.option("i'll think about it!", 255); dialog.send(); break; } default: { int mstage = npcrequest.optionid; if (mstage >= 1 && mstage <= 4) { client.entity.selectedstage = mstage; dialog.text("you choose " + ((game.enums.chipowertype)mstage).tostring() + " stage. Please select attribute you want to change "); for (int i = 0; i < 4; i++) { dialog.option("attribute [" + (byte)(i + 1) + "]", (byte)(i + 1 + 4)); } dialog.option("back", 0); dialog.option("i'll think about it!", 255); dialog.send(); break; } else if (mstage >= 4 && mstage <= 8) { try { client.entity.selectedattribute = mstage - 4; var mychiattribute = new list<enums.chiattribute>(); var powers = client.chipowers[(int)client.entity.selectedstage - 1]; for (int i = 0; i < powers.attributes.length; i++) { if (client.entity.conquerpoints >= 1) { client.entity.conquerpoints -= 1;// var attribute = powers.attributes[i]; mychiattribute.add(attribute.type); } else { dialog.text("anta yasta msh ma3ak 1 cps "); } } dialog.text("you choose attribute [" + client.entity.selectedattribute + "] please select attributetype you want to change "); for (int i = 0; i < (int)enums.chiattribute.magicdamagedecrease; i++) { var type = ((enums.chiattribute)(i + 1)); if (!mychiattribute.contains(type)) dialog.option(type.tostring(), (byte)(((i + 1) * 10))); } dialog.option("back", (byte)client.entity.selectedstage); dialog.option("i'll think about it!", 255); dialog.send(); } catch { } break; } else { var typex = mstage / 10; var mode = client.entity.selectedstage; var pos = client.entity.selectedattribute - 1; var powers = client.chipowers[mode - 1]; var attributes = powers.attributes; foreach (var attr in attributes) { if (attr.type == (enums.chiattribute)typex) { client.messagebox("sorry you can't muliplay stats", null, null); return; } } attributes[pos].type = (enums.chiattribute)typex; attributes[pos].value = (ushort)game.enums.chimaxvalues(attributes[pos].type); powers.calculatepoints(); database.chitable.sort((enums.chipowertype)mode); powers.power = (enums.chipowertype)mode; client.send(new chipowers(true).query(client)); #region update ranking database.chitable.chidata[] array = null; switch ((enums.chipowertype)mode) { case game.enums.chipowertype.dragon: Array = database.chitable.dragon; break; case game.enums.chipowertype.phoenix: Array = database.chitable.phoenix; break; case game.enums.chipowertype.tiger: Array = database.chitable.tiger; break; case game.enums.chipowertype.turtle: Array = database.chitable.turtle; break; } foreach (var chidata in array) { if (kernel.gamepool.containskey(chidata.uid)) { var pclient = kernel.gamepool[chidata.uid]; if (pclient == null) continue; if (pclient.chidata == null) continue; // make it public instead of private packethandler.sendrankingquery(new genericranking(true) { mode = genericranking.querycount }, pclient, genericranking.chi + (uint)mode, pclient.chidata.selectrank((enums.chipowertype)mode), pclient.chidata.selectpoints((enums.chipowertype)mode)); if (pclient.entity.uid == client.entity.uid || pclient.chidata.selectrank((enums.chipowertype)mode) < 50) pclient.loaditemstats(); } } #endregion database.chitable.save(client); } break; } } break; } #endregion