public override void ExecuteCommand(Client client, Identity target, string[] args) { int itemid = Int32.Parse(args[1]); if (!ItemLoader.ItemList.ContainsKey(itemid)) { client.SendChatText("No such item"); return; } ItemTemplate it = ItemLoader.ItemList[itemid]; if (it == null) { client.SendChatText("No Item with id " + itemid + " found."); return; } client.SendChatText("Item Debug Info for Item " + itemid); client.SendChatText("Attack values:"); foreach (KeyValuePair<int,int> at in it.Attack) { client.SendChatText("Type: " + at.Key + " Value: " + at.Value); } client.SendChatText("Defense values:"); foreach (KeyValuePair<int,int> at in it.Defend) { client.SendChatText("Type: " + at.Key + " Value: " + at.Value); } client.SendChatText("Item Attributes:"); foreach (KeyValuePair<int, int> at in it.Stats) { client.SendChatText("Type: " + at.Key + " Value: " + at.Value); } client.SendChatText("Events/Functions:"); foreach (Events ev in it.Events) { client.SendChatText("Eventtype: " + ev.EventType); foreach (Functions fu in ev.Functions) { client.SendChatText(" Functionnumber: " + fu.FunctionType); foreach (object arg in fu.Arguments.Values) { client.SendChatText(" Argument: " + arg); } foreach (Requirements aor in fu.Requirements) { client.SendChatText( " Reqs: " + aor.Statnumber + " " + aor.Operator + " " + aor.Value + " " + aor.ChildOperator); } } } }
/// <summary> /// </summary> /// <param name="client"> /// </param> public static void Read(Client client) { // client got all the needed data and // wants to enter the world. After we // reply to this, the character will really be in game var announce = new CharInPlayMessage { Identity = client.Character.Identity, Unknown = 0x00 }; client.Playfield.Announce(announce); // Player is in game now, starting is over, set stats normally now client.Character.Starting = false; // Mobs get sent whenever player enters playfield, BUT (!) they are NOT synchronized, because the mobs don't save stuff yet. // for instance: the waypoints the mob went through will NOT be saved and therefore when you re-enter the PF, it will AGAIN // walk the same waypoints. // TODO: Fix it /*foreach (MobType mob in NPCPool.Mobs) { // TODO: Make cache - use pf indexing somehow. if (mob.pf == client.Character.pf) { mob.SendToClient(client); } }*/ }
public static void Read(OrgClientMessage message, Client client) { switch ((byte)message.Command) { case 1: { // org create /* client wants to create organization * name of org is message.CommandArgs */ if (OrganizationDao.CreateOrganization(message.CommandArgs, DateTime.UtcNow, client.Character.Identity.Instance)) { client.SendChatText("You have created the guild: " + message.CommandArgs); int orgID = OrganizationDao.GetOrganizationId(message.CommandArgs); // Make sure the order of these next two lines is not swapped -NV client.Character.Stats["ClanLevel"].Value = 0; client.Character.Stats["Clan"].Value = orgID; break; } else { client.SendChatText("This guild already <font color=#DC143C>exists</font>"); break; } } #region /org ranks case 2: // org ranks // Displays Org Rank Structure. /* Select governingform from DB, Roll through display from GovForm */ if (client.Character.Stats["Clan"].BaseValue == 0) { client.SendChatText("You're not in an organization!"); break; } var governingForm = OrganizationDao.GetGovernmentForm((int)client.Character.Stats["Clan"].BaseValue); client.SendChatText("Current Rank Structure: " + GetRankList(governingForm)); break; #endregion #region /org contract case 3: // org contract break; #endregion #region unknown org command 4 case 4: Console.WriteLine("Case 4 Started"); break; #endregion #region /org info case 5: { IInstancedEntity tPlayer = null; if ((tPlayer = client.Playfield.FindByIdentity(message.Target)) != null) { string orgDescription = string.Empty, orgObjective = string.Empty, orgHistory = string.Empty, orgLeaderName = string.Empty; int orgGoverningForm = 0, orgLeaderID = 0; DBOrganization orgData = OrganizationDao.GetOrganizationData((int)tPlayer.Stats["Clan"].BaseValue); if (orgData != null) { orgDescription = orgData.Description; orgObjective = orgData.Objective; orgHistory = orgData.History; orgGoverningForm = orgData.GovernmentForm; orgLeaderID = orgData.LeaderID; } orgLeaderName = CharacterDao.GetCharacterNameById(orgLeaderID); string textGovForm = null; if (orgGoverningForm == 0) { textGovForm = "Department"; } else if (orgGoverningForm == 1) { textGovForm = "Faction"; } else if (orgGoverningForm == 2) { textGovForm = "Republic"; } else if (orgGoverningForm == 3) { textGovForm = "Monarchy"; } else if (orgGoverningForm == 4) { textGovForm = "Anarchism"; } else if (orgGoverningForm == 5) { textGovForm = "Feudalism"; } else { textGovForm = "Department"; } var orgRank = GetRank( orgGoverningForm, tPlayer.Stats["ClanLevel"].BaseValue); var infoMessage = new OrgInfoMessage { Identity = tPlayer.Identity, Unknown = 0x00, Unknown1 = 0x00000000, Unknown2 = 0x00000000, Organization = new Identity { Type = IdentityType.Organization, Instance = (int)tPlayer.Stats["Clan"].BaseValue }, // TODO: Possible NULL here OrganizationName = (tPlayer as Character).OrganizationName, Description = orgDescription, Objective = orgObjective, GoverningForm = textGovForm, LeaderName = orgLeaderName, Rank = orgRank, Unknown3 = new object[0] }; client.SendCompressed(infoMessage); } } break; #endregion #region /org disband case 6: // Add Org Bank to prez DBOrganization orgDisband = OrganizationDao.GetOrganizationData((int)client.Character.Stats["Clan"].BaseValue); client.Character.Stats["Cash"].BaseValue += (uint)orgDisband.Bank; // Clear stat 5 (Clan) from all chars where value=orgId StatDao.DisbandOrganization((int)client.Character.Stats["Clan"].BaseValue); break; #endregion #region /org startvote <text> <duration> <entries> case 7: // org startvote <"text"> <duration(minutes)> <entries> // arguments (<text> <duration> and <entries>) are in CmdStr break; #endregion #region /org vote info case 8: // org vote info break; #endregion #region /org vote <entry> case 9: // <entry> is CmdStr break; #endregion #region /org promote case 10: { // some arg in CmdByte. No idea what it is // create the target namespace t_promote IInstancedEntity toPromote = null; var promoteSql = string.Empty; var targetOldRank = -1; var targetNewRank = -1; var newPresRank = -1; var oldPresRank = 0; toPromote = client.Playfield.FindByIdentity(message.Target); if (toPromote != null) { // First we check if target is in the same org as you if (toPromote.Stats["Clan"].BaseValue != client.Character.Stats["Clan"].BaseValue) { // not in same org client.SendChatText("Target is not in your organization!"); break; } // Target is in same org, are you eligible to promote? Promoter Rank has to be TargetRank-2 or == 0 if ((client.Character.Stats["ClanLevel"].Value == (toPromote.Stats["ClanLevel"].Value - 2)) || (client.Character.Stats["ClanLevel"].Value == 0)) { // Promoter is eligible. Start the process // First we get the details about the org itself DBOrganization orgPromote = OrganizationDao.GetOrganizationData((int)client.Character.Stats["Clan"].BaseValue); var promoteGovForm = -1; var promotedToRank = string.Empty; var demotedFromRank = string.Empty; if (orgPromote != null) { // Check if new rank == 0, if so, demote promoter if ((targetOldRank - 1) == 0) { /* This is a bit more complex. Here we need to promote new president first * then we go about demoting old president * finally we set the new leader in Sql * Reset OrgName to set changes */ OrganizationDao.SetNewPrez(orgPromote.ID, toPromote.Identity.Instance); toPromote.Stats["ClanLevel"].Value = 0; client.Character.Stats["ClanLevel"].Value = 1; client.SendChatText( "You've passed leadership of the organization to: " + (toPromote as Character).Name); ((toPromote as Character).Client as Client).SendChatText( "You've been promoted to the rank of " + promotedToRank + " by " + client.Character.Name); } else { // Just Promote targetOldRank = toPromote.Stats["ClanLevel"].Value; targetNewRank = targetOldRank - 1; promotedToRank = GetRank(promoteGovForm, (uint)targetNewRank); toPromote.Stats["ClanLevel"].Value = targetNewRank; client.SendChatText( "You've promoted " + (toPromote as Character).Name + " to " + promotedToRank); ((toPromote as Character).Client as Client).SendChatText( "You've been promoted to the rank of " + promotedToRank + " by " + client.Character.Name); } } else { client.SendChatText("Organization does not exist?"); } } else { // Promoter not eligible to promote client.SendChatText( "Your Rank is not high enough to promote " + (toPromote as Character).Name); break; } } break; } #endregion #region /org demote case 11: // demote target player // create the target namespace t_demote IInstancedEntity toDemote = null; var demoteSql = string.Empty; var targetCurRank = -1; var targetNewerRank = -1; toDemote = client.Character.Playfield.FindByIdentity(message.Target); if (toDemote != null) { // First we check if target is in the same org as you if (toDemote.Stats["Clan"].BaseValue != client.Character.Stats["Clan"].BaseValue) { // not in same org client.SendChatText("Target is not in your organization!"); break; } // Target is in same org, are you eligible to demote? Promoter Rank has to be TargetRank-2 or == 0 if ((client.Character.Stats["ClanLevel"].Value <= (toDemote.Stats["ClanLevel"].Value - 2)) || (client.Character.Stats["ClanLevel"].Value == 0)) { // Promoter is eligible. Start the process // First we get the details about the org itself DBOrganization orgDemote = OrganizationDao.GetOrganizationData((int)client.Character.Stats["Clan"].BaseValue); var demoteGovForm = -1; var demotedToRank = string.Empty; if (orgDemote == null) { client.SendChatText("Organization does not exist?"); break; } // Check whether new rank would be lower than lowest for current govform if ((targetCurRank + 1) > GetLowestRank(orgDemote.GovernmentForm)) { client.SendChatText("You can't demote character any lower!"); break; } targetCurRank = toDemote.Stats["ClanLevel"].Value; targetNewerRank = targetCurRank + 1; demotedToRank = GetRank(demoteGovForm, (uint)targetNewerRank); toDemote.Stats["ClanLevel"].Value = targetNewerRank; client.SendChatText("You've demoted " + (toDemote as Character).Name + " to " + demotedToRank); ((toDemote as Character).Client as Client).SendChatText( "You've been demoted to the rank of " + demotedToRank + " by " + client.Character.Name); break; } else { // Promoter not eligible to promote client.SendChatText("Your Rank is not high enough to demote " + (toDemote as Character).Name); break; } } break; #endregion #region unknown org command 12 case 12: Console.WriteLine("Case 12 Started"); break; #endregion #region /org kick <name> case 13: /* // kick <name> from org // <name> is CmdStr // create the t_player Client namespace, using CmdStr to find character id, in replacement of target.Instance var kickedFrom = client.Character.Stats["Clan"].BaseValue; DBCharacter kickChar = CharacterDao.GetByCharName(message.CommandArgs); if (kickChar == null) { client.SendChatText("No character with name "+message.CommandArgs+" exists."); break; } var kickeeId = kickChar.Id; IInstancedEntity targetPlayer = client.Playfield.FindByIdentity( new Identity() { Type = IdentityType.CanbeAffected, Instance = kickeeId }); if (targetPlayer != null) { // Check if CmdStr is actually part of the org var kickeeOrgId = targetPlayer.Stats["Clan"].BaseValue; if (kickeeOrgId != client.Character.Stats["Clan"].BaseValue) { // Not part of Org. break out. client.SendChatText(message.CommandArgs + "is not a member of your organization!"); break; } // They are part of the org, so begin the processing... // First we check if the player is online... var onlineSql = "SELECT online FROM characters WHERE ID = " + client.Character.Id.Instance; dt = ms.ReadDatatable(onlineSql); var onlineStatus = 0; if (dt.Rows.Count > 0) { onlineStatus = (Int32)dt.Rows[0][0]; } if (onlineStatus == 0) { // Player isn't online. Org Kicks are processed in a different method // TODO: Offline Org KICK break; } // Player is online. Start the kick. targetPlayer.Character.Stats.ClanLevel.Set(0); targetPlayer.Character.OrgId = 0; var kickedFromSql = "SELECT Name FROM organizations WHERE ID = " + client.Character.OrgId; dt = ms.ReadDatatable(kickedFromSql); var kickedFromName = string.Empty; if (dt.Rows.Count > 0) { kickedFromName = (string)dt.Rows[0][0]; } targetPlayer.SendChatText("You've been kicked from the organization " + kickedFromName); } */ // TODO: Offline Org KICK break; #endregion #region /org invite case 14: {/* Client tPlayer = null; if ((tPlayer = FindClient.FindClientById(message.Target.Instance)) != null) { var inviteMessage = new OrgInviteMessage { Identity = tPlayer.Character.Id, Unknown = 0x00, Unknown1 = 0x00000000, Unknown2 = 0x00000000, Organization = new Identity { Type = IdentityType .Organization, Instance = (int) client.Character.OrgId }, OrganizationName = client.Character.OrgName, Unknown3 = 0x00000000 }; tPlayer.SendCompressed(inviteMessage); }*/ } break; #endregion #region Org Join case 15: {/* // target.Instance holds the OrgID of the Org wishing to be joined. var orgIdtoJoin = message.Target.Instance; var JoinSql = "SELECT * FROM organizations WHERE ID = '" + orgIdtoJoin + "' LIMIT 1"; var gov_form = 0; dt = ms.ReadDatatable(JoinSql); if (dt.Rows.Count > 0) { gov_form = (Int32)dt.Rows[0]["GovernmentForm"]; } // Make sure the order of these next two lines is not swapped -NV client.Character.Stats.ClanLevel.Set(GetLowestRank(gov_form)); client.Character.OrgId = (uint)orgIdtoJoin; */ } break; #endregion #region /org leave case 16: /* // org leave // TODO: Disband org if it was leader that left org. -Suiv- // I don't think a Disband happens if leader leaves. I don't think leader -can- leave without passing lead to another // Something worth testing on Testlive perhaps ~Chaz // Just because something happens on TL, doesnt mean its a good idea. Really tbh id prefer it if you had to explicitly type /org disband to disband rather than /org leave doing it... -NV // Agreeing with NV. Org Leader can't leave without passing lead on. org disband requires /org disband to specifically be issued, with a Yes/No box. var LeaveSql = "SELECT * FROM organizations WHERE ID = " + client.Character.OrgId; var govern_form = 0; dt = ms.ReadDatatable(LeaveSql); if (dt.Rows.Count > 0) { govern_form = (Int32)dt.Rows[0]["GovernmentForm"]; } if ((client.Character.Stats.ClanLevel.Value == 0) && (govern_form != 4)) { client.SendChatText( "Organization Leader cannot leave organization without Disbanding or Passing Leadership!"); } else { client.Character.OrgId = 0; client.SendChatText("You left the guild"); } */ break; #endregion #region /org tax | /org tax <tax> case 17: // gets or sets org tax // <tax> is CmdStr // if no <tax>, then just send chat text with current tax info if (message.CommandArgs == null) { client.SendChatText("The current organization tax rate is: "); break; } else { break; } #endregion #region /org bank case 18: {/* // org bank dt = ms.ReadDatatable("SELECT * FROM organizations WHERE ID=" + client.Character.OrgId); if (dt.Rows.Count > 0) { var bank_credits = (UInt64)dt.Rows[0]["Bank"]; client.SendChatText("Your bank has " + bank_credits + " credits in its account"); } */ } break; #endregion #region /org bank add <cash> case 19: {/* if (client.Character.OrgId == 0) { client.SendChatText("You are not in an organisation."); break; } // org bank add <cash> var minuscredits_fromplayer = Convert.ToInt32(message.CommandArgs); var characters_credits = client.Character.Stats.Cash.Value; if (characters_credits < minuscredits_fromplayer) { client.SendChatText("You do not have enough Credits"); } else { var total_Creditsspent = characters_credits - minuscredits_fromplayer; client.Character.Stats.Cash.Set(total_Creditsspent); ms.SqlUpdate( "UPDATE `organizations` SET `Bank` = `Bank` + " + minuscredits_fromplayer + " WHERE `ID` = " + client.Character.OrgId); client.SendChatText("You have donated " + minuscredits_fromplayer + " to the organization"); }*/ } break; #endregion #region /org bank remove <cash> case 20: /* // org bank remove <cash> // <cash> is CmdStr // player wants to take credits from org bank // only leader can do that if ((client.Character.Stats.ClanLevel.Value != 0) || (client.Character.OrgId == 0)) { client.SendChatText("You're not the leader of an Organization"); break; } var removeCredits = Convert.ToInt32(message.CommandArgs); long orgBank = 0; dt = ms.ReadDatatable("SELECT Bank FROM organizations WHERE ID = " + client.Character.OrgId); if (dt.Rows.Count > 0) { orgBank = (Int64)dt.Rows[0][0]; } if (removeCredits > orgBank) { client.SendChatText("Not enough credits in Organization Bank!"); break; } else { var neworgbank = orgBank - removeCredits; var existingcreds = 0; existingcreds = client.Character.Stats.Cash.Value; var newcreds = existingcreds + removeCredits; ms.SqlUpdate( "UPDATE organizations SET Bank = " + neworgbank + " WHERE ID = " + client.Character.OrgId); client.Character.Stats.Cash.Set(newcreds); client.SendChatText("You've removed " + removeCredits + " credits from the organization bank"); } */ break; #endregion #region /org bank paymembers <cash> case 21: // <cash> is CmdStr // give <cash> credits to every org member // credits are taken from org bank // only leader can do it break; #endregion #region /org debt case 22: // send player text about how big is his/her tax debt to org break; #endregion #region /org history <text> case 23: {/* if (client.Character.Stats.ClanLevel.Value == 0) { // org history <history text> ms.SqlUpdate( "UPDATE organizations SET history = '" + message.CommandArgs + "' WHERE ID = '" + client.Character.OrgId + "'"); client.SendChatText("History Updated"); } else { client.SendChatText("You must be the Organization Leader to perform this command!"); }*/ } break; #endregion #region /org objective <text> case 24: {/* if (client.Character.Stats.ClanLevel.Value == 0) { // org objective <objective text> ms.SqlUpdate( "UPDATE organizations SET objective = '" + message.CommandArgs + "' WHERE ID = '" + client.Character.OrgId + "'"); client.SendChatText("Objective Updated"); } else { client.SendChatText("You must be the Organization Leader to perform this command!"); }*/ } break; #endregion #region /org description <text> case 25: {/* if (client.Character.Stats.ClanLevel.Value == 0) { // org description <description text> ms.SqlUpdate( "UPDATE organizations SET description = '" + message.CommandArgs + "' WHERE ID = '" + client.Character.OrgId + "'"); client.SendChatText("Description Updated"); } else { client.SendChatText("You must be the Organization Leader to perform this command!"); }*/ } break; #endregion #region /org name <text> case 26: { // org name <name> /* Renames Organization * Checks for Existing Orgs with similar name to stop crash * Chaz */ /* if (client.Character.Stats.ClanLevel.Value == 0) { var SqlQuery26 = "SELECT * FROM organizations WHERE Name LIKE '" + message.CommandArgs + "' LIMIT 1"; string CurrentOrg = null; dt = ms.ReadDatatable(SqlQuery26); if (dt.Rows.Count > 0) { CurrentOrg = (string)dt.Rows[0]["Name"]; } if (CurrentOrg == null) { var SqlQuery27 = "UPDATE organizations SET Name = '" + message.CommandArgs + "' WHERE ID = '" + client.Character.OrgId + "'"; ms.SqlUpdate(SqlQuery27); client.SendChatText("Organization Name Changed to: " + message.CommandArgs); // Forces reloading of org name and the like // XXXX TODO: Make it reload for all other members in the org client.Character.OrgId = client.Character.OrgId; break; } else { client.SendChatText("An Organization already exists with that name"); break; } } else { client.SendChatText("You must be the organization leader to perform this command!"); }*/ break; } #endregion #region /org governingform <text> case 27: { // org governingform <form> /* Current Governing Forms: * Department, Faction, Republic, Monarchy, Anarchism, Feudalism */ /* // Check on whether your President or not if (client.Character.Stats.ClanLevel.Value == 0) { // first we drop the case on the input, just to be sure. var GovFormNum = -1; if (message.CommandArgs == null) { // list gov forms client.SendChatText( "List of Accepted Governing Forms is: department, faction, republic, monarchy, anarchism, feudalism"); break; } // was correct input passed? switch (message.CommandArgs.ToLower()) { case "department": GovFormNum = 0; break; case "faction": GovFormNum = 1; break; case "republic": GovFormNum = 2; break; case "monarchy": GovFormNum = 3; break; case "anarchism": GovFormNum = 4; break; case "feudalism": GovFormNum = 5; break; default: client.SendChatText(message.CommandArgs + " Is an invalid Governing Form!"); client.SendChatText( "Accepted Governing Forms are: department, faction, republic, monarchy, anarchism, feudalism"); break; } if (GovFormNum != -1) { ms.SqlUpdate( "UPDATE organizations SET GovernmentForm = '" + GovFormNum + "' WHERE ID = '" + client.Character.OrgId + "'"); foreach (var currentCharId in OrgMisc.GetOrgMembers(client.Character.OrgId, true)) { client.Character.Stats.ClanLevel.Set(GetLowestRank(GovFormNum)); } client.SendChatText("Governing Form is now: " + message.CommandArgs); break; } } else { // Haha! You're not the org leader! client.SendChatText("You must be the Org Leader to perform this command"); break; }*/ } break; #endregion #region /org stopvote <text> case 28: // <text> is CmdStr break; #endregion #region unknown command default: break; #endregion } }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="target"> /// </param> /// <param name="args"> /// </param> public override void ExecuteCommand(Client client, Identity target, string[] args) { // Fallback to self if no target is selected if (target.Instance == 0) { target = client.Character.Identity; } if (target.Type != IdentityType.CanbeAffected) { client.SendChatText("Target must be player/monster/NPC"); return; } IInstancedEntity targetDynel = client.Playfield.FindByIdentity(target); if (targetDynel != null) { Dynel targetCharacter = (Dynel)targetDynel; // May be obsolete in the future, let it stay in comment yet // ch.CalculateSkills(); int statId; try { statId = StatNamesDefaults.GetStatNumber(args[1]); } catch (Exception) { client.SendChatText("Unknown Stat name " + args[1]); return; } uint statValue; int effectiveValue; int trickle; int mod; int perc; try { statValue = targetCharacter.Stats[statId].BaseValue; effectiveValue = targetCharacter.Stats[statId].Value; trickle = targetCharacter.Stats[statId].Trickle; mod = targetCharacter.Stats[statId].Modifier; perc = targetCharacter.Stats[statId].PercentageModifier; } catch (StatDoesNotExistException) { client.SendChatText("Unknown Stat Id " + statId); return; } string response = string.Empty; INamedEntity namedDynel = targetCharacter as INamedEntity; if (namedDynel != null) { response = "Character " + namedDynel.Name + " (" + targetCharacter.Identity.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue; } else { response = "Dynel " + targetCharacter.Identity.Instance + "Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue; } client.SendChatText(response); if (statValue != targetCharacter.Stats[args[1]].Value) { response = "Effective value Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + effectiveValue; client.SendChatText(response); } response = "Trickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc; client.SendChatText(response); } else { // Shouldnt be happen again (fallback to self) client.SendChatText("Unable to find target."); } }
public override void CommandHelp(Client client) { client.SendChatText("Usage: /command debugitem ItemID"); return; }
/// <summary> /// </summary> /// <param name="charID"> /// </param> /// <param name="client"> /// </param> public void Read(int charID, Client client) { // Don't edit anything in this region // unless you are 300% sure you know what you're doing // Character is created and read when Client connects in Client.cs->CreateCharacter // client.CreateCharacter(charID); client.Server.Info( client, "Client connected. ID: {0} IP: {1} Character name: {2}", client.Character.Identity.Instance, client.ClientAddress, client.Character.Name); // now we have to start sending packets like // character stats, inventory, playfield info // and so on. I will put some packets here just // to get us in game. We have to start moving // these packets somewhere else and make packet // builders instead of sending (half) hardcoded // packets. /* send chat server info to client */ ChatServerInfo.Send(client); /* send playfield info to client */ PlayfieldAnarchyF.Send(client); var sendSCFUs = new IMSendPlayerSCFUs { toClient = client }; client.Playfield.SendSCFUsToClient(sendSCFUs); /* set SocialStatus to 0 */ client.Character.Stats[521].BaseValue = 0; Stat.Send(client, 521, 0, false); var identity = new Identity { Type = IdentityType.CanbeAffected, Instance = charID }; /* Action 167 Animation and Stance Data maybe? */ var message = new CharacterActionMessage { Identity = identity, Action = CharacterActionType.ChangeAnimationAndStance, Target = Identity.None, Parameter1 = 0x00000000, Parameter2 = 0x00000001 }; client.SendCompressed(message); var gameTimeMessage = new GameTimeMessage { Identity = identity, Unknown1 = 30024.0f, Unknown3 = 185408, Unknown4 = 80183.3125f }; client.SendCompressed(gameTimeMessage); /* set SocialStatus to 0 */ Stat.Set(client, 521, 0, false); /* again */ Stat.Set(client, 521, 0, false); /* visual */ SimpleCharFullUpdate.SendToPlayfield(client); /* inventory, items and all that */ FullCharacter.Send(client); var specials = new[] { new SpecialAttackInfo { Unknown1 = 0x0000AAC0, Unknown2 = 0x00023569, Unknown3 = 0x00000064, Unknown4 = "MAAT" }, new SpecialAttackInfo { Unknown1 = 0x0000A431, Unknown2 = 0x0000A430, Unknown3 = 0x00000090, Unknown4 = "DIIT" }, new SpecialAttackInfo { Unknown1 = 0x00011294, Unknown2 = 0x00011295, Unknown3 = 0x0000008E, Unknown4 = "BRAW" } }; var specialAttackWeaponMessage = new SpecialAttackWeaponMessage { Identity = identity, Specials = specials }; client.SendCompressed(specialAttackWeaponMessage); // done // Timers are allowed to update client stats now. client.Character.DoNotDoTimers = false; // spawn all active monsters to client // TODO: Implement NonPlayerCharacterHandler // NonPlayerCharacterHandler.SpawnMonstersInPlayfieldToClient(client, client.Character.PlayField); // TODO: Implement VendorHandler // if (VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField) > 0) // { // Shops // VendorHandler.GetVendorsInPF(client); // } // WeaponItemFullCharUpdate Maybe the right location , First Check if weapons present usually in equipment // Packets.WeaponItemFullUpdate.Send(client, client.Character); // TODO: create a better alternative to ProcessTimers // client.Character.ProcessTimers(DateTime.Now + TimeSpan.FromMilliseconds(200)); client.Character.CalculateSkills(); AppearanceUpdate.AnnounceAppearanceUpdate(client.Character); // done, so we call a hook. // Call all OnConnect script Methods Program.csc.CallMethod("OnConnect", client.Character); }
/// <summary> /// </summary> /// <param name="client"> /// </param> public override void CommandHelp(Client client) { // No help needed, no arguments can be given return; }
public static void Read(CharacterActionMessage packet, Client client) { var mys = new SqlWrapper(); var actionNum = (int)packet.Action; var unknown1 = packet.Unknown1; var args1 = packet.Parameter1; var args2 = packet.Parameter2; var unknown2 = packet.Unknown2; switch (actionNum) { case 19: { // Cast nano // CastNanoSpell var msg = new CastNanoSpellMessage { Identity = client.Character.Identity, Unknown = 0x00, NanoId = args2, Target = packet.Target, Unknown1 = 0x00000000, Caster = client.Character.Identity }; client.Character.Playfield.Announce(msg); // CharacterAction 107 var characterAction107 = new CharacterActionMessage { Identity = client.Character.Identity, Unknown = 0x00, Action = CharacterActionType.Unknown1, Unknown1 = 0x00000000, Target = Identity.None, Parameter1 = 1, Parameter2 = args2, Unknown2 = 0x0000 }; client.Character.Playfield.Announce(characterAction107); // CharacterAction 98 var characterAction98 = new CharacterActionMessage { Identity = packet.Target, Unknown = 0x00, Action = CharacterActionType.Unknown2, Unknown1 = 0x00000000, Target = new Identity { Type = IdentityType .NanoProgram, Instance = args2 }, Parameter1 = client.Character.Identity.Instance, Parameter2 = 0x249F0, // duration? Unknown2 = 0x0000 }; client.Character.Playfield.Announce(characterAction98); } break; /* this is here to prevent server crash that is caused by * search action if server doesn't reply if something is * found or not */ case 66: { // If action == search /* Msg 110:136744723 = "No hidden objects found." */ // TODO: SEARCH!! SendFeedback.Send(client, 110, 136744723); } break; case 105: { // If action == Info Request IInstancedEntity tPlayer = client.Playfield.FindByIdentity(packet.Target); var tChar = tPlayer as Character; if (tChar != null) { var LegacyScore = tChar.Stats["PvP_Rating"].BaseValue; string LegacyTitle = null; if (LegacyScore < 1400) { LegacyTitle = string.Empty; } else if (LegacyScore < 1500) { LegacyTitle = "Freshman"; } else if (LegacyScore < 1600) { LegacyTitle = "Rookie"; } else if (LegacyScore < 1700) { LegacyTitle = "Apprentice"; } else if (LegacyScore < 1800) { LegacyTitle = "Novice"; } else if (LegacyScore < 1900) { LegacyTitle = "Neophyte"; } else if (LegacyScore < 2000) { LegacyTitle = "Experienced"; } else if (LegacyScore < 2100) { LegacyTitle = "Expert"; } else if (LegacyScore < 2300) { LegacyTitle = "Master"; } else if (LegacyScore < 2500) { LegacyTitle = "Champion"; } else { LegacyTitle = "Grand Master"; } var orgGoverningForm = 0; var ms = new SqlWrapper(); var dt = ms.ReadDatatable( "SELECT `GovernmentForm` FROM organizations WHERE ID=" + tChar.Stats["Clan"].BaseValue); if (dt.Rows.Count > 0) { orgGoverningForm = (Int32)dt.Rows[0][0]; } // Uses methods in ZoneEngine\PacketHandlers\OrgClient.cs /* Known packetFlags-- * 0x40 - No org | 0x41 - Org | 0x43 - Org and towers | 0x47 - Org, towers, player has personal towers | 0x50 - No pvp data shown * Bitflags-- * Bit0 = hasOrg, Bit1 = orgTowers, Bit2 = personalTowers, Bit3 = (Int32) time until supression changes (Byte) type of supression level?, Bit4 = noPvpDataShown, Bit5 = hasFaction, Bit6 = ?, Bit 7 = null. */ int? orgId; string orgRank; InfoPacketType type; if (tPlayer.Stats["Clan"].BaseValue == 0) { type = InfoPacketType.Character; orgId = null; orgRank = null; } else { type = InfoPacketType.CharacterOrg; orgId = (int?)tPlayer.Stats["Clan"].BaseValue; if (client.Character.Stats["Clan"].BaseValue == tPlayer.Stats["Clan"].BaseValue) { orgRank = OrgClient.GetRank( orgGoverningForm, tPlayer.Stats["ClanLevel"].BaseValue); } else { orgRank = string.Empty; } } var info = new CharacterInfoPacket { Unknown1 = 0x01, Profession = (Profession) tPlayer.Stats["Profession"].Value, Level = (byte)tPlayer.Stats["Level"].Value, TitleLevel = (byte)tPlayer.Stats["TitleLevel"].Value, VisualProfession = (Profession) tPlayer.Stats["VisualProfession"].Value, SideXp = 0, Health = tPlayer.Stats["Health"].Value, MaxHealth = tPlayer.Stats["Life"].Value, BreedHostility = 0x00000000, OrganizationId = orgId, FirstName = tChar.FirstName, LastName = tChar.LastName, LegacyTitle = LegacyTitle, Unknown2 = 0x0000, OrganizationRank = orgRank, TowerFields = null, CityPlayfieldId = 0x00000000, Towers = null, InvadersKilled = tPlayer.Stats["InvadersKilled"].Value, KilledByInvaders = tPlayer.Stats["KilledByInvaders"].Value, AiLevel = tPlayer.Stats["AlienLevel"].Value, PvpDuelWins = tPlayer.Stats["PvpDuelKills"].Value, PvpDuelLoses = tPlayer.Stats["PvpDuelDeaths"].Value, PvpProfessionDuelLoses = tPlayer.Stats["PvpProfessionDuelDeaths"].Value, PvpSoloKills = tPlayer.Stats["PvpRankedSoloKills"].Value, PvpTeamKills = tPlayer.Stats["PvpRankedTeamKills"].Value, PvpSoloScore = tPlayer.Stats["PvpSoloScore"].Value, PvpTeamScore = tPlayer.Stats["PvpTeamScore"].Value, PvpDuelScore = tPlayer.Stats["PvpDuelScore"].Value }; var infoPacketMessage = new InfoPacketMessage { Identity = tPlayer.Identity, Unknown = 0x00, Type = type, Info = info }; client.SendCompressed(infoPacketMessage); } else // TODO: NPC's {/* var npc = (NonPlayerCharacterClass) FindDynel.FindDynelById(packet.Target); if (npc != null) { var infoPacket = new PacketWriter(); // Start packet header infoPacket.PushByte(0xDF); infoPacket.PushByte(0xDF); infoPacket.PushShort(10); infoPacket.PushShort(1); infoPacket.PushShort(0); infoPacket.PushInt(3086); // sender (server ID) infoPacket.PushInt(client.Character.Id.Instance); // receiver infoPacket.PushInt(0x4D38242E); // packet ID infoPacket.PushIdentity(npc.Id); // affected identity infoPacket.PushByte(0); // ? // End packet header infoPacket.PushByte(0x50); // npc's just have 0x50 infoPacket.PushByte(1); // esi_001? infoPacket.PushByte((byte)npc.Stats.Profession.Value); // Profession infoPacket.PushByte((byte)npc.Stats.Level.Value); // Level infoPacket.PushByte((byte)npc.Stats.TitleLevel.Value); // Titlelevel infoPacket.PushByte((byte)npc.Stats.VisualProfession.Value); // Visual Profession infoPacket.PushShort(0); // no idea for npc's infoPacket.PushUInt(npc.Stats.Health.Value); // Current Health (Health) infoPacket.PushUInt(npc.Stats.Life.Value); // Max Health (Life) infoPacket.PushInt(0); // BreedHostility? infoPacket.PushUInt(0); // org ID infoPacket.PushShort(0); infoPacket.PushShort(0); infoPacket.PushShort(0); infoPacket.PushShort(0); infoPacket.PushInt(0x499602d2); infoPacket.PushInt(0x499602d2); infoPacket.PushInt(0x499602d2); var infoPacketA = infoPacket.Finish(); client.SendCompressed(infoPacketA); }*/ } } break; case 120: { // If action == Logout // Start 30 second logout timer if client is not a GM (statid 215) if (client.Character.Stats["GMLevel"].Value == 0) { // client.startLogoutTimer(); } else { // If client is a GM, disconnect without timer client.Server.DisconnectClient(client); } } break; case 121: { // If action == Stop Logout // Stop current logout timer and send stop logout packet client.Character.UpdateMoveType((byte)client.Character.PreviousMoveMode); //client.CancelLogOut(); } break; case 87: { // If action == Stand client.Character.UpdateMoveType(37); // Send stand up packet, and cancel timer/send stop logout packet if timer is enabled //client.StandCancelLogout(); } break; case 22: { // Kick Team Member } break; case 24: { // Leave Team /* var team = new TeamClass(); team.LeaveTeam(client); */ } break; case 25: { // Transfer Team Leadership } break; case 26: { // Team Join Request // Send Team Invite Request To Target Player /* var team = new TeamClass(); team.SendTeamRequest(client, packet.Target); */ } break; case 28: { /* // Request Reply // Check if positive or negative response // if positive var team = new TeamClass(); var teamID = TeamClass.GenerateNewTeamId(client, packet.Target); // Destination Client 0 = Sender, 1 = Reciever // Reciever Packets /////////////////// // CharAction 15 team.TeamRequestReply(client, packet.Target); // CharAction 23 team.TeamRequestReplyCharacterAction23(client, packet.Target); // TeamMember Packet team.TeamReplyPacketTeamMember(1, client, packet.Target, "Member1"); // TeamMemberInfo Packet team.TeamReplyPacketTeamMemberInfo(1, client, packet.Target); // TeamMember Packet team.TeamReplyPacketTeamMember(1, client, packet.Target, "Member2"); // Sender Packets ///////////////// // TeamMember Packet team.TeamReplyPacketTeamMember(0, client, packet.Target, "Member1"); // TeamMemberInfo Packet team.TeamReplyPacketTeamMemberInfo(0, client, packet.Target); // TeamMember Packet team.TeamReplyPacketTeamMember(0, client, packet.Target, "Member2"); */ } break; case 0x70: // Remove/Delete item ItemDao.RemoveItem((int)packet.Target.Type, client.Character.Identity.Instance, packet.Target.Instance); client.Character.BaseInventory.RemoveItem((int)packet.Target.Type, packet.Target.Instance); client.SendCompressed(packet); break; case 0x34: // Split? IItem it = client.Character.BaseInventory.Pages[(int)packet.Target.Type][packet.Target.Instance]; it.MultipleCount -= args2; Item newItem = new Item(it.Quality, it.LowID, it.HighID); newItem.MultipleCount = args2; client.Character.BaseInventory.Pages[(int)packet.Target.Type].Add( client.Character.BaseInventory.Pages[(int)packet.Target.Type].FindFreeSlot(), newItem); client.Character.BaseInventory.Pages[(int)packet.Target.Type].Write(); break; #region Join item case 0x35: client.Character.BaseInventory.Pages[(int)packet.Target.Type][packet.Target.Instance].MultipleCount += client.Character.BaseInventory.Pages[(int)packet.Target.Type][args2].MultipleCount; client.Character.BaseInventory.Pages[(int)packet.Target.Type].Remove(args2); client.Character.BaseInventory.Pages[(int)packet.Target.Type].Write(); client.SendCompressed(packet); break; #endregion #region Sneak Action // ################################################################################### // Spandexpants: This is all i have done so far as to make sneak turn on and off, // currently i cannot find a missing packet or link which tells the server the player // has stopped sneaking, hidden packet or something, will come back to later. // ################################################################################### // Sneak Packet Received case 163: { // TODO: IF SNEAKING IS ALLOWED RUN THIS CODE. // Send Action 162 : Enable Sneak var sneak = new CharacterActionMessage { Identity = client.Character.Identity, Unknown = 0x00, Action = CharacterActionType.StartedSneaking, Unknown1 = 0x00000000, Target = Identity.None, Parameter1 = 0, Parameter2 = 0, Unknown2 = 0x0000 }; client.SendCompressed(sneak); // End of Enable sneak // TODO: IF SNEAKING IS NOT ALLOWED SEND REJECTION PACKET } break; #endregion #region Use Item on Item /* case 81: { var item1 = packet.Target; var item2 = new Identity { Type = (IdentityType)args1, Instance = args2 }; var cts = new Tradeskill(client, item1.Instance, item2.Instance); cts.ClickBuild(); break; } */ #endregion #region Change Visual Flag case 166: { client.Character.Stats["VisualFlags"].Value = args2; // client.SendChatText("Setting Visual Flag to "+unknown3.ToString()); AppearanceUpdate.AnnounceAppearanceUpdate(client.Character); break; } #endregion /* #region Tradeskill Source Changed case 0xdc: TradeSkillReceiver.TradeSkillSourceChanged(client, args1, args2); break; #endregion #region Tradeskill Target Changed case 0xdd: TradeSkillReceiver.TradeSkillTargetChanged(client, args1, args2); break; #endregion #region Tradeskill Build Pressed case 0xde: TradeSkillReceiver.TradeSkillBuildPressed(client, packet.Target.Instance); break; #endregion */ #region default default: { client.Playfield.Announce(packet); } break; #endregion } }
/// <summary> /// </summary> /// <param name="commandName"> /// </param> /// <param name="client"> /// </param> /// <param name="target"> /// </param> /// <param name="commandArguments"> /// </param> public void CallChatCommand(string commandName, Client client, Identity target, string[] commandArguments) { Contract.Requires(commandName != null); Assembly assembly = Assembly.GetExecutingAssembly(); if (commandName.ToUpperInvariant() != "LISTCOMMANDS") { foreach (KeyValuePair<string, Type> kv in this.chatCommands) { if (kv.Key.Substring(kv.Key.IndexOf(":", StringComparison.Ordinal) + 1).ToUpperInvariant() == commandName.ToUpperInvariant()) { AOChatCommand aoc = (AOChatCommand) assembly.CreateInstance(kv.Key.Substring(0, kv.Key.IndexOf(":", StringComparison.Ordinal))); if (aoc != null) { // Check GM Level bitwise if ((client.Character.Stats["GMLevel"].Value < aoc.GMLevelNeeded()) && (aoc.GMLevelNeeded() > 0)) { client.SendChatText( "You are not authorized to use this command!. This incident will be recorded."); // It is not yet :) return; } if (commandArguments != null) { // Check if only one argument has been passed for "help" if (commandArguments.Length == 2) { if (commandArguments[1].ToUpperInvariant() == "HELP") { aoc.CommandHelp(client); return; } } } // Execute the command with the given command arguments, if CheckCommandArguments is true else print command help if (aoc.CheckCommandArguments(commandArguments)) { aoc.ExecuteCommand(client, target, commandArguments); } else { aoc.CommandHelp(client); } } } } } else { client.SendChatText("Available Commands:"); string[] scriptNames = this.chatCommands.Keys.ToArray(); if (scriptNames.Length >= 0) { for (int i = 0; i < scriptNames.Length; i++) { scriptNames[i] = scriptNames[i].Substring(scriptNames[i].IndexOf(":", StringComparison.Ordinal) + 1) + ":" + scriptNames[i].Substring(0, scriptNames[i].IndexOf(":", StringComparison.Ordinal)); } Array.Sort(scriptNames); foreach (string scriptName in scriptNames) { string typename = scriptName.Substring(scriptName.IndexOf(":", StringComparison.Ordinal) + 1); AOChatCommand aoc = (AOChatCommand)assembly.CreateInstance(typename); if (aoc != null) { if (client.Character.Stats["GMLevel"].Value >= aoc.GMLevelNeeded()) { client.SendChatText( scriptName.Substring(0, scriptName.IndexOf(":", StringComparison.Ordinal))); } } } } } }
/// <summary> /// Execute the chat command /// </summary> /// <param name="client"> /// client /// </param> /// <param name="target"> /// Target identity /// </param> /// <param name="args"> /// command arguments /// </param> public abstract void ExecuteCommand(Client client, Identity target, string[] args);
/// <summary> /// Returns Help for this command /// </summary> /// <param name="client"> /// </param> public abstract void CommandHelp(Client client);
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="target"> /// </param> /// <param name="args"> /// </param> public override void ExecuteCommand(Client client, Identity target, string[] args) { // Fallback to self if no target is selected bool fallback = false; if (target.Instance == 0) { target = client.Character.Identity; fallback = true; } int statId = 0; try { statId = StatNamesDefaults.GetStatNumber(args[1]); } catch (Exception) { client.SendChatText("Unknown Stat name " + args[1]); return; } uint statNewValue = 1234567890; try { statNewValue = uint.Parse(args[2]); } catch { try { // For values >= 2^31 statNewValue = uint.Parse(args[2]); } catch (FormatException) { } catch (OverflowException) { } } IStats tempch = client.Playfield.FindByIdentity(target); if (tempch == null) { client.SendChatText("Target vanished? This should NOT be reached"); } uint statOldValue; try { statOldValue = tempch.Stats[statId].BaseValue; var IM = new IMExecuteFunction( new Functions { Target = Constants.ItemtargetSelectedtarget, FunctionType = Constants.FunctiontypeSet, Requirements = new List<Requirements>(), Arguments = new FunctionArguments { Values = new List<object> { statId, (int)statNewValue } }, TickCount = 1, TickInterval = 1, dolocalstats = true }, ((INamedEntity)tempch).Identity); if (fallback) { IM.Function.Target = Constants.ItemtargetSelf; } if (tempch.CheckRequirements(IM.Function, true)) { ((IInstancedEntity)tempch).Playfield.Publish(IM); } } catch { client.SendChatText("Unknown StatId " + statId); return; } INamedEntity namedEntity = tempch as INamedEntity; string response; if (namedEntity != null) { response = "Character " + namedEntity.Name + " (" + target.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") ="; } else { response = "Dynel (" + ((IInstancedEntity)tempch).Identity.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") ="; } response += " Old: " + statOldValue; response += " New: " + statNewValue; client.SendChatText(response); }