protected override void OnDisconnected() { if (account != null) { if (account.characters != null) { CharacterFunctions.quitGameWorld(this); foreach (Character character in account.characters.Values) { character.Save(); } account.clearCharacters(); } } OutPacket wayToHell = new OutPacket(9); wayToHell.WriteInt(9); wayToHell.WriteShort(3); wayToHell.WriteRepeatedByte(6, 3); // just for lulz WriteRawPacket(wayToHell.ToArray()); if (m_processor != null) { Logger.WriteLog(Logger.LogTypes.Disconnect, "[{0}] Client {1} disconnected.", m_processor.Label, Label); m_deathAction(this); } }
//Positions the camera in the right place public static void CameraPositioning(CharacterFunctions stats) { //Addes Horizontal offset var direction = stats.HoverRight ? 1 : -1; var newPos = stats.transform.position; var horOffset = stats.CameraHorizontalOffset; if (stats.MoveState == CharacterStats.MovementState.Running) { horOffset = stats.RunCamHorizontalOffset; } //Smooth transition from walking to running if (horOffset != stats.CurrentHorizontalOffset) { stats.CurrentHorizontalOffset = Mathf.SmoothStep(stats.CurrentHorizontalOffset, horOffset, stats.HorOffsetStep); } newPos += (stats.transform.right * stats.CurrentHorizontalOffset * direction); //Adds Vertical Offset newPos += (stats.transform.up * stats.CameraHeight); //Sets it to the camera stats.PlayerCamera.transform.position = newPos; //Makes the camera aim var newLookAt = stats.PlayerCamera.transform.position; stats.PlayerCamera.transform.Find("Camera").LookAt(newLookAt); }
public void UpdateStats() { currentStats.UpdateStats(); currentStats.Battle.range = Stats.Battle.range; currentStats.Battle.dmg_dice = Stats.Battle.dmg_dice; currentStats.Equipment.itemsSlot = Stats.Equipment.itemsSlot; currentStats.Equipment.bagSlot = Stats.Equipment.bagSlot; Equipment.ItemSlots.Capacity(currentStats.Equipment.itemsSlot + 1); Equipment.Backpack.Capacity((currentStats.Equipment.bagSlot + 1) * 3); currentStats = CharacterFunctions.CalculateBase(currentStats, Stats.Base); currentStats = CharacterFunctions.CalculateAbility(currentStats, Stats.Ability); currentStats = CharacterFunctions.CalculateResistance(currentStats, Stats.Resistance); currentStats = CharacterFunctions.CalculateOther(currentStats, Stats.Other); currentStats = CharacterFunctions.CalculateBattle(currentStats, Stats.Battle); currentStats = CharacterFunctions.CalculateEquipment(currentStats, Equipment); currentStats = CharacterFunctions.CalculateTraits(currentStats, Traits); currentStats = CharacterFunctions.CalculateStates(currentStats, Effects); currentStats = CharacterFunctions.CalculateBaseBonus(currentStats, Equipment); currentStats = CharacterFunctions.CalculateBattleBonus(currentStats, Equipment, Stats); Precent_Stats = CharacterFunctions.PrecentCalculate(Traits, Effects); currentStats = CharacterFunctions.Precent(currentStats, Precent_Stats); currentStats = CharacterFunctions.Calculate_HpMp(currentStats); }
public static void RequestSpawn(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter != null) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to spawn a character while being ingame."); c.Close(); return; } byte selected_character = p.ReadByte(); if (!c.getAccount().characters.ContainsKey(selected_character)) { Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Wrong target '{0}' has been selected by selection packet", selected_character); c.Close(); return; } Character target = c.getAccount().characters[selected_character]; c.getAccount().activeCharacter = target; WMap.Instance.addToCharacters(target); CharacterFunctions.setPlayerPosition(target, target.getPosition()[0], target.getPosition()[1], target.getMap()); CharacterFunctions.calculateCharacterStatistics(target); StaticPackets.sendSystemMessageToClient(c, 1, Constants.WelcomeMessage); }
/// <summary> /// Controls the camera so it follows the player in a Third Person Shooter feel. /// </summary> /// <param name="hor">Input needed to move the Camera left and right.</param> /// <param name="ver">Input needed to move the Camera up and down.</param> /// <param name="stats">Gets the Camera variables, such as height, distance, sensitivity, etc.</param> public static void FollowPlayer(float hor, float ver, CharacterFunctions stats) { //Moves Camera RotateCamera(hor, stats); TiltCamera(ver, stats); CameraPositioning(stats); //Sets the Field of View var currentFOV = stats.CameraFOV; if (stats.MoveState == CharacterStats.MovementState.Aiming) { currentFOV = stats.AimingFOV; } else if (stats.MoveState == CharacterStats.MovementState.Running) { currentFOV = stats.RunningFOV; } //Smooth transition if (currentFOV != stats.CurrentFOV) { stats.CurrentFOV = Mathf.SmoothStep(stats.CurrentFOV, currentFOV, stats.FOVStep); } stats.PlayerCamera.transform.Find("Camera").GetComponent <Camera>().fieldOfView = stats.CurrentFOV; }
private void CheckGrounded() { var colliderThreshold = 0.05f; var topLeftOfGroundCheck = new Vector2(playerBoxCollider.bounds.min.x, playerBoxCollider.bounds.min.y - colliderThreshold); var bottomRightOfGroundCheck = new Vector2(playerBoxCollider.bounds.max.x, playerBoxCollider.bounds.min.y - lengthToSearch); playerState = !CharacterFunctions.GroundCheck(topLeftOfGroundCheck, bottomRightOfGroundCheck) ? PlayerState.IN_AIR : PlayerState.GROUNDED; }
protected void PickUp(CharacterFunctions player) { //Adds a Gun to the player hand player.PickUpGun(gun); //After it's been picked up it destroys itself Destroy(gameObject); }
//Rotates the player left and right public static void RotateCamera(float hor, CharacterFunctions stats) { //Depends if the player is aiming down the sights var horizontalSensitivity = stats.MoveState == CharacterStats.MovementState.Aiming ? stats.HorizontalAimSensitivity : stats.HorizontalSensitivity; //Rotates the camera and the player stats.transform.Rotate(new Vector3(0, horizontalSensitivity * hor, 0)); stats.PlayerCamera.transform.rotation = stats.transform.rotation; }
//Checks to see if there is anything behind the camera so it doesn't clip through it private static void TiltCamera(float ver, CharacterFunctions stats) { //Sets references var cam = stats.PlayerCamera.transform.Find("Camera"); Vector3 newPos = cam.transform.localPosition; //Makes sure there is nothing behind the player var direction = (cam.transform.position - stats.PlayerCamera.transform.position).normalized; //Chooses the camera distance var curRadius = stats.CameraDistance; if (stats.MoveState == CharacterStats.MovementState.Aiming) { curRadius = stats.AimCameraDistance; } else if (stats.MoveState == CharacterStats.MovementState.Running) { curRadius = stats.RunCameraDistance; } //Smooth transition between the movement if (curRadius != stats.CurrentCameraRadius) { stats.CurrentCameraRadius = Mathf.SmoothStep(stats.CurrentCameraRadius, curRadius, stats.RadiusStep); } var currentRadius = stats.CurrentCameraRadius; //Checks with raycast if (Physics.Raycast(stats.PlayerCamera.transform.position, direction, out RaycastHit hit, curRadius, stats.CameraMask)) { if (hit.collider != null && hit.distance >= stats.CameraMinDistance) { currentRadius = hit.distance - 0.1f; } } var verticalSensitivity = stats.MoveState == CharacterStats.MovementState.Aiming ? stats.VerticalAimSensitivity : stats.VerticalSensitivity; //Circle Equation Vector3 CircleEquation(Vector3 vect, float radius) { float theta = Mathf.Clamp(Mathf.Atan((vect.y - (ver * verticalSensitivity)) / -vect.z), -0.7f, 1.5f); vect.z = -radius *Mathf.Cos(theta); vect.y = radius * Mathf.Sin(theta); return(vect); } //Calculates the tilt movement newPos = CircleEquation(newPos, currentRadius); //Sets the positions and fixes the Child position stats.PlayerCamera.transform.Find("Camera").localPosition = newPos; }
public static void Equip(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter == null) { Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook equip while not being ingame."); c.Close(); return; } Character chr = c.getAccount().activeCharacter; byte changeType = p.ReadByte(); byte[] swapSlots = p.ReadBytes(2); if (changeType == (byte)0x00) { if (!chr.getEquipment().swapEquips(swapSlots[0], swapSlots[1])) { Logger.LogCheat(Logger.HackTypes.Equip, c, "Attempted to swap weapons, while one of them or even both are null."); c.Close(); return; } WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[0], chr.getEquipment().getEquipments()[swapSlots[0]].getItemID())); WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[1], chr.getEquipment().getEquipments()[swapSlots[1]].getItemID())); } else { if (!chr.getInventory().equipItem(swapSlots[0], swapSlots[1], chr.getEquipment())) { Console.WriteLine("so sorz : >"); return; } WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[1], chr.getEquipment().getEquipments()[swapSlots[1]].getItemID())); } OutPacket op = new OutPacket(24); op.WriteInt(24); op.WriteShort(0x04); op.WriteShort(0x0c); op.WriteInt(135593729); op.WriteInt(c.getAccount().activeCharacter.getuID()); op.WriteShort(0x01); op.WriteByte(changeType); op.WriteBytes(swapSlots); c.WriteRawPacket(op.ToArray()); CharacterFunctions.calculateCharacterStatistics(chr); }
//Skills #region Functions public void UpdateStats() { currentStats.UpdateStats(); currentStats.Battle.range = StaticValues.Races.Races[Actor.Race].Stats.Battle.range; currentStats.Battle.dmg_dice = StaticValues.Races.Races[Actor.Race].Stats.Battle.dmg_dice + StaticValues.Classes.Classes[Actor.Class].Stats.Battle.dmg_dice; currentStats.Equipment.itemsSlot = Stats.Equipment.itemsSlot; currentStats.Equipment.bagSlot = Stats.Equipment.bagSlot; Equipment.ItemSlots.Capacity(currentStats.Equipment.itemsSlot + 1); Equipment.Backpack.Capacity((currentStats.Equipment.bagSlot + 1) * 3); currentStats = CharacterFunctions.CalculateBase(currentStats, Stats.Base); currentStats = CharacterFunctions.CalculateBase(currentStats, Actor.Stats.Base); currentStats = CharacterFunctions.CalculateBase(currentStats, StaticValues.Races.Races[Actor.Race].Stats.Base); currentStats = CharacterFunctions.CalculateBase(currentStats, StaticValues.Classes.Classes[Actor.Class].Stats.Base); currentStats = CharacterFunctions.CalculateAbility(currentStats, Stats.Ability); currentStats = CharacterFunctions.CalculateAbility(currentStats, Actor.Stats.Ability); currentStats = CharacterFunctions.CalculateAbility(currentStats, StaticValues.Races.Races[Actor.Race].Stats.Ability); currentStats = CharacterFunctions.CalculateAbility(currentStats, StaticValues.Classes.Classes[Actor.Class].Stats.Ability); currentStats = CharacterFunctions.CalculateResistance(currentStats, Stats.Resistance); currentStats = CharacterFunctions.CalculateResistance(currentStats, Actor.Stats.Resistance); currentStats = CharacterFunctions.CalculateResistance(currentStats, StaticValues.Races.Races[Actor.Race].Stats.Resistance); currentStats = CharacterFunctions.CalculateResistance(currentStats, StaticValues.Classes.Classes[Actor.Class].Stats.Resistance); currentStats = CharacterFunctions.CalculateOther(currentStats, Stats.Other); currentStats = CharacterFunctions.CalculateOther(currentStats, Actor.Stats.Other); currentStats = CharacterFunctions.CalculateOther(currentStats, StaticValues.Races.Races[Actor.Race].Stats.Other); currentStats = CharacterFunctions.CalculateOther(currentStats, StaticValues.Classes.Classes[Actor.Class].Stats.Other); currentStats = CharacterFunctions.CalculateBattle(currentStats, Stats.Battle); currentStats = CharacterFunctions.CalculateBattle(currentStats, Actor.Stats.Battle); currentStats = CharacterFunctions.CalculateBattle(currentStats, StaticValues.Races.Races[Actor.Race].Stats.Battle); currentStats = CharacterFunctions.CalculateBattle(currentStats, StaticValues.Classes.Classes[Actor.Class].Stats.Battle); HpMpIncreaseByLvl(); currentStats = CharacterFunctions.CalculateEquipment(currentStats, Equipment); currentStats = CharacterFunctions.CalculateTraits(currentStats, Traits); currentStats = CharacterFunctions.CalculateStates(currentStats, Effects); currentStats = CharacterFunctions.CalculateBaseBonus(currentStats, Equipment); currentStats = CharacterFunctions.CalculateBattleBonus(currentStats, Equipment, Actor); Precent_Stats = CharacterFunctions.PrecentCalculate(Traits, Effects); currentStats = CharacterFunctions.Precent(currentStats, Precent_Stats); currentStats = CharacterFunctions.Calculate_HpMp(currentStats);//Finish Function }
public static void MoveOrUnequip(MartialClient c, InPacket p) { Console.WriteLine("move or unequip"); if (c.getAccount().activeCharacter == null) { Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook invManag while not being ingame."); c.Close(); return; } Character chr = c.getAccount().activeCharacter; byte[] decrypted = p.ReadBytes(12); byte[] amountByte = { decrypted[8], decrypted[9], decrypted[10], decrypted[11] }; int amount = BitTools.byteArrayToInt(amountByte); if (decrypted[0] == (byte)0x00) { if (!chr.getInventory().unequipItem(decrypted[1], decrypted[4], decrypted[3], chr.getEquipment())) { Console.WriteLine("problem with unequipItem"); return; } WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, decrypted[1], 0)); } else { if (!chr.getInventory().moveItem(decrypted[1], decrypted[2], amount, decrypted[4], decrypted[3])) { Console.WriteLine("problem with move item"); return; } } OutPacket op = new OutPacket(28); op.WriteInt(28); op.WriteShort(0x04); op.WriteShort(0x10); op.WriteInt(); op.WriteInt(c.getAccount().activeCharacter.getuID()); op.WriteShort(0x01); op.WriteBytes(new byte[] { decrypted[0], decrypted[1], decrypted[2], decrypted[3], decrypted[4] }); op.WriteByte(); op.WriteBytes(new byte[] { decrypted[8], decrypted[9], decrypted[10], decrypted[11] }); c.WriteRawPacket(op.ToArray()); CharacterFunctions.calculateCharacterStatistics(chr); }
public static void ReturnToSelection(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter == null) { Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Hooked returnToSelection with null of activeCharacter"); c.Close(); return; } c.getAccount().activeCharacter.getInventory().updateInv(); c.getAccount().activeCharacter.getInventory().saveInv(); c.getAccount().activeCharacter.getCommunity().relistCommunities(); CharacterFunctions.quitGameWorld(c); c.getAccount().relistCharacters(); c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), true)); }
public void LoadCharacters() { using (var con = new MySqlConnection(MasterServer.Instance.SqlConnection.mConnectionString)) using (var cmd = con.CreateCommand()) { con.Open(); cmd.CommandText = "SELECT * FROM chars WHERE ownerID = " + aID + " LIMIT 5"; using (var reader = cmd.ExecuteReader()) { List <int> ids = new List <int>(); for (int i = 0; i < 5; i++) { if (!reader.Read()) { break; } ids.Add(reader.GetInt32(0)); } foreach (int id in ids) { Character chr = new Character(); chr.setcID(id); if (chr.Load(this) == 0) { Logger.WriteLog(Logger.LogTypes.Error, "Could not load character with ID {0}.", chr.getuID()); continue; } chr.setAccount(this); MySQLTool.loadEq(chr); MySQLTool.loadInv(chr); MySQLTool.loadCargo(chr); MySQLTool.loadSkills(chr); MySQLTool.loadSkillBar(chr); MySQLTool.loadCommunities(chr); CharacterFunctions.calculateCharacterStatistics(chr); this.appendToCharacters(chr); } } } }
public static void Warp(MartialClient c, InCommand cmd) { if (cmd.commandArgs.Length < 2) { StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true"); return; } if (c.getAccount().activeCharacter == null) { Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler"); c.Close(); return; } Character chr = c.getAccount().activeCharacter; short goMap = -1; float goX = -1; float goY = -1; if (cmd.commandArgs.Length == 2) { switch (cmd.commandArgs[0].ToLower()) { case "npc": { int npcID = -1; if (!Int32.TryParse(cmd.commandArgs[1], out npcID)) { StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse NPC's ID."); return; } if (WMap.Instance.getNpcs().ElementAtOrDefault(npcID) == null) { StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find NPC of ID " + npcID + "!"); return; } NPC npc = WMap.Instance.getNpcs()[npcID]; goMap = npc.getMap(); goX = npc.getPosition()[0]; goY = npc.getPosition()[1]; break; } /*case "mob": * { * int mobID = -1; * if(!Int32.TryParse(cmd.commandArgs[1], out mobID)) * { * StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse Mob's ID."); * return; * } * * Mob mob = WMap.Instance.getGrid(chr.getMap()).findMobByuID(mobID); * if(mob == null) * { * StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find Mob of ID " + mobID + "!"); * return; * } * * goMap = mob.getMap(); * goX = mob.getPosition()[0]; * goY = mob.getPosition()[1]; * break; * }*/ case "player": { Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[1]); if (player == null) { StaticPackets.sendSystemMessageToClient(c, 1, "Player wasn't found."); return; } goMap = player.getMap(); goX = player.getPosition()[0]; goY = player.getPosition()[1]; break; } default: { if (!MiscFunctions.IsNumeric(cmd.commandArgs[0]) || cmd.commandArgs[1] != "true" && !MiscFunctions.IsNumeric(cmd.commandArgs[1])) { StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true"); return; } Waypoint closestTown = null; short _desiredMap = -1; if (!Int16.TryParse(cmd.commandArgs[0], out _desiredMap)) { StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired map's ID!"); return; } if (cmd.commandArgs[1] == "true") { closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(_desiredMap, new Waypoint(0, 0)); if (closestTown == null) { StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + "!"); return; } } else if (MiscFunctions.IsNumeric(cmd.commandArgs[1])) { int _desiredTown = -1; if (!Int32.TryParse(cmd.commandArgs[1], out _desiredTown)) { StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired town's index!"); return; } closestTown = TownCoordsCache.Instance.getWaypointAtIndexForMap(_desiredMap, _desiredTown); if (closestTown == null) { StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + " with index " + _desiredTown + "!"); return; } } goMap = Convert.ToInt16(cmd.commandArgs[0]); goX = closestTown.getX(); goY = closestTown.getY(); break; } } } else if (cmd.commandArgs.Length == 3) { foreach (string parser in cmd.commandArgs) { if (!MiscFunctions.IsNumeric(parser)) { StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!"); return; } } goMap = Convert.ToInt16(cmd.commandArgs[2]); goX = Convert.ToSingle(cmd.commandArgs[0]); goY = Convert.ToSingle(cmd.commandArgs[1]); } else { return; } CharacterFunctions.setPlayerPosition(c.getAccount().activeCharacter, goX, goY, goMap); return; }
private void Start() { _character = transform.parent.GetComponent <CharacterFunctions>(); _animator = GetComponent <Animator>(); }
public static void CreateNewCharacter(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter != null) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while being ingame."); c.Close(); return; } if (c.getAccount().characters.Count() == 5) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while characters count is 5."); c.Close(); return; } string charName = MiscFunctions.obscureString(p.ReadString(18)); if (charName == null) { c.WriteRawPacket(Constants.createNCharNameTaken); return; } if (charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName)) { c.WriteRawPacket(Constants.createNCharNameTaken); return; } byte face = (byte)p.ReadShort(); if (face < 1 || face > 7) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with face no {0}", face); c.WriteRawPacket(Constants.createNCharNameTaken); return; } short unknownShit = p.ReadShort(); // but let's check it if (unknownShit > 0) { Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit); } short unknownShit2 = p.ReadShort(); if (unknownShit2 > 0) { Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit2); } byte cClass = (byte)p.ReadShort(); if (cClass < 1 || cClass > 4) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with class no {0}", cClass); c.WriteRawPacket(Constants.createNCharNameTaken); return; } byte[] stats = { (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort() }; byte statPoints = (byte)p.ReadShort(); if (stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + statPoints > 55) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with weird amount of attributes."); c.WriteRawPacket(Constants.createNCharNameTaken); return; } Character newChr = new Character(); newChr.setName(charName); newChr.setFace(face); newChr.setcClass(cClass); newChr.setStr(stats[0]); newChr.setDex(stats[1]); newChr.setVit(stats[2]); newChr.setAgi(stats[3]); newChr.setInt(stats[4]); newChr.setStatPoints(statPoints); newChr.setAccount(c.getAccount()); if (newChr.Create() == true) { CharacterFunctions.createEquipments(newChr); CharacterFunctions.createInventories(newChr); CharacterFunctions.calculateCharacterStatistics(newChr); newChr.setCurHP(newChr.getMaxHP()); newChr.setCurMP(newChr.getMaxMP()); newChr.setCurSP(newChr.getMaxSP()); c.getAccount().appendToCharacters(newChr); c.WriteRawPacket(Constants.createNewCharacter); return; } c.WriteRawPacket(Constants.createNCharNameTaken); return; }
// Holy Grail ftw public static void useItem(Character chr, Item item, byte usingIndex, InPacket p) { MartialClient c = chr.getAccount().mClient; ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID()); Boolean shouldDecrease = false; string determined = null; int determiner = 0; if (itemData.getIsStackable()) { shouldDecrease = true; } else { if (itemData.getTimeToExpire() == 0) { shouldDecrease = true; } } // well.. we don't care if it's handled by server.. let's just remove them & f**k haterz! qq if (shouldDecrease) { if (!chr.getInventory().decrementItem(usingIndex)) { Console.WriteLine("something went wrong with decrement.."); return; } } switch (itemData.getCategory()) { case 1001: // healingz { if (itemData.getHealHP() > 0 || itemData.getHealMana() > 0 || itemData.getHealStamina() > 0) { StaticPackets.releaseHealPacket(chr, (int)(chr.getCurHP() + itemData.getHealHP()), (short)(chr.getCurMP() + itemData.getHealMana()), (short)(chr.getCurSP() + itemData.getHealStamina())); } break; } case 1002: // skillz o.o { StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "If you'd like to learn any skill, go to skills list and press CTRL+LMB."); break; } case 1003: // teleport { if (chr.getMap() == itemData.getTeleportMap() || chr.getMap() != itemData.getTeleportMap() && itemData.getSpecialEffect() != 0) { CharacterFunctions.setPlayerPosition(chr, itemData.getTeleportX(), itemData.getTeleportY(), (short)itemData.getTeleportMap()); } break; } case 1007: // reset skills { chr.getSkills().resetAll(); chr.getSkillBar().getSkillBar().Clear(); break; } case 1011: // effect potions { chr.setEffect((byte)itemData.getSpecialEffect()); break; } case 1012: // tae potion { break; } case 1013: // faction change { if (chr.getFaction() == 0) { return; } chr.setFaction(chr.getFaction() == 1 ? (byte)2 : (byte)1); break; } case 1015: // chuk amulet { determiner = BitConverter.ToInt32(p.ReadBytes(4), 0); if (determiner == 0) { return; } ItemData determinedItem = ItemDataCache.Instance.getItemData(determiner); if (determinedItem == null || determinedItem.getCategory() != 1003 || (determiner < 212100146 && determiner > 212100164 && determiner != 212100185 && determiner != 212100187)) { Console.WriteLine("I CAN'T TURN 10 INTO 20 CHICKENZ"); return; } CharacterFunctions.setPlayerPosition(chr, determinedItem.getTeleportX(), determinedItem.getTeleportY(), (short)determinedItem.getTeleportMap()); break; } case 1016: // karma amulet { chr.setKarmaMessagingTimes((short)(chr.getKarmaMessagingTimes() + 1)); break; } case 1020: // name changer { p.Skip(4); string charName = MiscFunctions.obscureString(p.ReadString(16)); if (charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName)) { StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "Wrong input " + charName + "."); return; } chr.setName(charName); determined = charName; CharacterFunctions.refreshCharacterForTheWorld(chr); break; } case 1021: // face changer { chr.setFace((byte)itemData.getSpecialEffect()); break; } case 1024: { // yy..? break; } case 1031: // red castle { determiner = BitConverter.ToInt32(p.ReadBytes(4), 0); if (determiner == 0) { return; } ItemData determinedItem = ItemDataCache.Instance.getItemData(determiner); if (determinedItem == null || determinedItem.getCategory() != 56 || ((determiner < 273001255 && determiner > 273001257) && determiner != 283000472 && determiner != 283000543 && determiner != 283000575 && determiner != 283000614 && determiner != 283000934 && determiner != 283001078 && determiner != 283001373 && determiner != 283001376)) { Console.WriteLine("I CAN'T TURN 10 INTO 20 CHICKENZ"); return; } CharacterFunctions.setPlayerPosition(chr, determinedItem.getTeleportX(), determinedItem.getTeleportY(), (short)determinedItem.getTeleportMap()); break; } default: { StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "Feature not implemented yet"); return; } } OutPacket op = new OutPacket(52); op.WriteInt(52); op.WriteShort(0x04); op.WriteShort(0x05); op.WriteInt(140328705); op.WriteInt(chr.getuID()); op.WriteShort(0x01); op.WriteByte(0x01); op.WriteByte(usingIndex); op.WriteInt(item.getQuantity()); op.WriteInt(793149441); op.WriteInt(/*determiner > 0 ? determiner : 0*/); op.WritePaddedString(determined, 17); op.WriteByte(0x90); op.WriteByte(0xd2); op.WriteByte(0x2a); c.WriteRawPacket(op.ToArray()); OutPacket ops = new OutPacket(40); ops.WriteInt(40); ops.WriteShort(0x05); ops.WriteShort(0x05); ops.WriteInt(779458561); ops.WriteInt(chr.getuID()); ops.WriteInt(item.getItemID()); ops.WritePaddedString(determined, 17); ops.WriteByte(0x9e); ops.WriteByte(0x0f); ops.WriteByte(0xbf); WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), ops.ToArray()); }
public static void Quit(MartialClient c, InPacket p) { CharacterFunctions.quitGameWorld(c); c.WriteRawPacket(new byte[] { (byte)0x09, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x03, (byte)0x00, (byte)0x64, (byte)0x00, (byte)0x00 }); c.Close(); }
/// <summary> /// Adds Recoil to the camera. Making the camera slightly move up every time the function is called. /// </summary> /// <param name="recoil">The amount of recoild or movement the gun will have, or the camera will move.</param> /// <param name="stats">The Player Controller or character that this will affect.</param> public static void RecoilCamera(float recoil, CharacterFunctions stats) { TiltCamera(recoil, stats); }
//Opens the container for the player public void OpenContainer(CharacterFunctions stats) { stats.OpenContainer(ref ContainedItems, gameObject.name); }
//Picks up the item and adds it into the inventory of the player public void PickUpItem(CharacterFunctions stats) { stats.PickUpitem(self); Destroy(gameObject); }