public DB_NPC(int id, byte flags, short level, ushort dialog, byte index, ushort movement, PonyData pony) { ID = id; Pony = pony; Level = level; Dialog = dialog; DialogIndex = index; Movement = movement; Flags = (NPCFlags)flags; if ((Flags & NPCFlags.Trader) > 0) { Items = new List <int>(); } else { Items = null; } if ((Flags & NPCFlags.Wears) > 0) { Wears = new List <int>(); } else { Wears = null; } }
/// <summary> /// Toggles the NPC flag. /// </summary> /// <param name="flag">The flag.</param> public void ToggleNPCFlag(NPCFlags flag) { if (GetNPCFlag(flag)) { SetNPCFlag(flag, false); } else { SetNPCFlag(flag, true); } }
/// <summary> /// Sets the NPC flag. /// </summary> /// <param name="flag">The flag.</param> /// <param name="value">if set to <c>true</c> [value].</param> public void SetNPCFlag(NPCFlags flag, bool value) { if (value) { m_NPCFlags |= flag; } else { m_NPCFlags &= ~flag; } }
public NPCBaseStats(NPCFlags Flags, UInt16 Fatigue, UInt16 BarterGold, Int16 Level, UInt16 CalcMin, UInt16 CalcMax, UInt16 SpeedMultiplier, Single Karma, Int16 DispositionBase, ActorTemplateFlags TemplateFlags) { this.Flags = Flags; this.Fatigue = Fatigue; this.BarterGold = BarterGold; this.Level = Level; this.CalcMin = CalcMin; this.CalcMax = CalcMax; this.SpeedMultiplier = SpeedMultiplier; this.Karma = Karma; this.DispositionBase = DispositionBase; this.TemplateFlags = TemplateFlags; }
public NPCBaseStats(string Tag = null) : base(Tag) { Flags = new NPCFlags(); Fatigue = new UInt16(); BarterGold = new UInt16(); Level = new Int16(); CalcMin = new UInt16(); CalcMax = new UInt16(); SpeedMultiplier = new UInt16(); Karma = new Single(); DispositionBase = new Int16(); TemplateFlags = new ActorTemplateFlags(); }
private static void WriteNPCFlags(ObjectBase obj, Character chr, UpdatePacket packet) { NPCFlags npcFlags = (NPCFlags)obj.GetUInt32(UnitFields.NPC_FLAGS); if (obj is NPC) { NPC npc = (NPC)obj; if (npc.IsTrainer && !npc.TrainerEntry.CanTrain(chr)) { npcFlags = NPCFlags.None; } } packet.Write((uint)npcFlags); }
public static bool HandleNpcInfoCommand(string[] args, CommandGroup cmd) { Creature target = cmd.GetSession().GetPlayer().GetSelection <Creature>(); if (target == null) { return(cmd.SendErrorMessage(CypherStrings.SelectCreature)); } uint faction = target.GetCreatureTemplate().FactionA; NPCFlags npcflags = (NPCFlags)target.GetValue <uint>((int)UnitFields.NpcFlags); uint displayid = target.GetCreatureTemplate().ModelId[0]; uint nativeid = target.GetCreatureTemplate().ModelId[0]; uint Entry = target.GetEntry(); //CreatureTemplate const* cInfo = target->GetCreatureTemplate(); //ulong curRespawnDelay = target.->GetRespawnTimeEx()-time(NULL); //if (curRespawnDelay < 0) //curRespawnDelay = 0; //std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true); //std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); cmd.SendSysMessage(CypherStrings.NpcinfoChar, target.GetGUIDLow(), target.GetGUIDLow(), faction, npcflags, Entry, displayid, nativeid); cmd.SendSysMessage(CypherStrings.NpcinfoLevel, target.GetCreatureTemplate().Maxlevel); //cmd.SendSysMessage(CypherStrings.NPCINFO_HEALTH, target.CurHealth); //cmd.SendSysMessage(CypherStrings.NPCINFO_FLAGS, target.GetValue<uint>((int)UnitFields.Flags), target.GetValue<uint>((int)UnitFields.DynamicFlags), target.Template.FactionA); //cmd.SendSysMessage(CypherStrings.COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str()); //cmd.SendSysMessage(CypherStrings.NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId); //cmd.SendSysMessage(CypherStrings.NPCINFO_DUNGEON_ID, target->GetInstanceId()); //cmd.SendSysMessage(CypherStrings.NPCINFO_PHASEMASK, target->GetPhaseMask()); //cmd.SendSysMessage(CypherStrings.NPCINFO_ARMOR, target->GetArmor()); cmd.SendSysMessage(CypherStrings.NpcinfoPosition, target.Position.X, target.Position.Y, target.Position.Z); //cmd.SendSysMessage(CypherStrings.NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str()); if (Convert.ToBoolean(npcflags & NPCFlags.Vendor)) { cmd.SendSysMessage(CypherStrings.NpcinfoVendor); } if (Convert.ToBoolean(npcflags & NPCFlags.Trainer)) { cmd.SendSysMessage(CypherStrings.NpcinfoTrainer); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="KinCityData"/> class. /// </summary> /// <param name="reader">The reader.</param> public KinCityData(BinaryFileReader reader) { int version = reader.ReadInt(); switch (version) { case 2: { m_Treasury = reader.ReadInt(); m_TaxRate = reader.ReadDouble(); goto case 1; } case 1: { m_UnassignedGuardSlots = reader.ReadInt(); goto case 0; } case 0: { m_City = (KinFactionCities)reader.ReadInt(); m_ControlingKin = (IOBAlignment)reader.ReadInt(); m_CaptureTime = reader.ReadDeltaTime(); m_CityLeader = (PlayerMobile)reader.ReadMobile(); m_IsVotingStage = reader.ReadBool(); m_Sigil = (KinSigil)reader.ReadItem(); m_ControlPoints = reader.ReadInt(); m_ControlPointDelta = reader.ReadInt(); m_NPCFlags = (NPCFlags)reader.ReadInt(); m_GuardOption = (GuardOptions)reader.ReadInt(); m_LastGuardChangeTime = reader.ReadDeltaTime(); int length = reader.ReadInt(); if (length > 0) { for (int i = 0; i < length; ++i) { m_BeneficiaryDataList.Add(new BeneficiaryData(reader)); } } break; } } }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public NPC() { // Graphics. Graphics.DrawOffset = new Point2I(-8, -14); // Physics. EnablePhysics(PhysicsFlags.Solid | PhysicsFlags.HasGravity); Physics.CollisionBox = new Rectangle2F(-8, -11, 16, 15); Physics.SoftCollisionBox = new Rectangle2F(-10, -15, 20, 19); // General. centerOffset = Graphics.DrawOffset + new Point2I(8, 8); actionAlignDistance = 5; flags = NPCFlags.FacePlayerOnTalk | NPCFlags.FacePlayerWhenNear; // Bounding box for talking is 4 pixels beyond the hard collision box (inclusive). // Alignment limit is a max 5 pixels in either direction (inclusive). }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public NPC() { // Physics. EnablePhysics(PhysicsFlags.Solid | PhysicsFlags.HasGravity); Physics.CollisionBox = new Rectangle2F(-8, -11, 16, 13); Physics.SoftCollisionBox = new Rectangle2F(-10, -15, 20, 19); // Graphics. Graphics.DepthLayer = DepthLayer.PlayerAndNPCs; Graphics.DrawOffset = new Point2I(-8, -14); // General. centerOffset = Graphics.DrawOffset + new Point2I(8, 8); actionAlignDistance = 5; flags = NPCFlags.FacePlayerOnTalk | NPCFlags.FacePlayerWhenNear; message = null; animationTalk = null; // Bounding box for talking is 4 pixels beyond the hard collision box (inclusive). // Alignment limit is a max 5 pixels in either direction (inclusive). }
/// <summary> /// Sets all NPC flags. /// </summary> public void SetAllNPCFlags() { m_NPCFlags = (NPCFlags)0xFFFFFF; }
public static bool HasAnyFlag(this NPCFlags flags, NPCFlags otherFlags) { return (flags & otherFlags) != 0; }
// // All this will need refactoring later // public static void Load(Player player, Role role, NPCFlags race) { LoadBasicStats(player); LoadStatModRole(player, role); LoadStatModRace(player, race); }
/// <summary> /// Clears the NPC Flags. /// </summary> public void ClearNPCFLags() { m_NPCFlags = 0; }
private static void LoadStatModRace(Player player, NPCFlags race) { //do nothing atm }
public bool get(NPCFlags fl) { return(Flags[fl]); }
public void set(NPCFlags fl, bool on) { Flags[fl] = on; }
//flag rubbish hither /// <summary> /// Gets the NPC flag. /// </summary> /// <param name="flag">The flag.</param> /// <returns></returns> public bool GetNPCFlag(NPCFlags flag) { return((m_NPCFlags & flag) != 0); }
public static bool HasAnyFlag(this NPCFlags flags, NPCFlags otherFlags) { return((flags & otherFlags) != NPCFlags.None); }
public static bool HasFlag(this NPCFlags flags, NPCFlags toCheck) { return (flags & toCheck) != 0; }
public static bool Has(this NPCFlags flags, NPCFlags flag) { return (flags & flag) != 0; }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { string str = trigger.Text.NextModifiers(); string name = ""; if (str.Contains("n")) { name = trigger.Text.NextWord(); } Unit target = trigger.Args.Target; if (target == null) { trigger.Reply("No target found."); } else { Map rgn = target.Map; if (rgn == null) { trigger.Reply("Instances are currently not supported."); } else { NPC npc = null; rgn.ExecuteInContext(() => { foreach (WorldObject worldObject in rgn) { if (worldObject is NPC && (name == "" || worldObject.Name.ContainsIgnoreCase(name))) { npc = (NPC)worldObject; break; } } }); if (npc == null) { trigger.Reply("Could not find a matching NPC."); } else { Character character = trigger.Args.Character; if (trigger.Args.HasCharacter) { if (name == "" && character.Target != null) { if (character.Target is NPC) { npc = character.Target as NPC; } else { character.Target = npc; } } else { character.Target = npc; } } else { trigger.Args.Target = npc; trigger.Args.Context = npc; } trigger.Reply("Selected: {0}", (object)npc); NPCFlags npcFlags = npc.NPCFlags; trigger.Reply("NPCFlags {0}:{1}", (object)npcFlags, (object)npcFlags); UnitDynamicFlags dynamicFlags = npc.DynamicFlags; trigger.Reply("DynamicFlags {0}:{1}", (object)dynamicFlags, (object)dynamicFlags); UnitExtraFlags extraFlags = npc.ExtraFlags; trigger.Reply("ExtraFlags {0}:{1}", (object)extraFlags, (object)extraFlags); StateFlag stateFlags = npc.StateFlags; trigger.Reply("StateFlags {0}:{1}", (object)stateFlags, (object)stateFlags); UnitFlags unitFlags = npc.UnitFlags; trigger.Reply("UnitFlags {0}:{1}", (object)unitFlags, (object)(int)unitFlags); UnitFlags2 unitFlags2 = npc.UnitFlags2; trigger.Reply("UnitFlags2 {0}:{1}", (object)unitFlags2, (object)unitFlags2); } } } }
public void OnMouseOver() { if (!UnityEngine.GameObject.Find("InfoPanel")) { UnityEngine.GameObject tempAuth = Instantiate(Resources.Load("InfoPanel") as UnityEngine.GameObject, new Vector3(Screen.width - 50, 100, 0), Quaternion.identity); tempAuth.transform.SetParent(UnityEngine.GameObject.Find("Canvas").gameObject.transform); tempAuth.transform.localScale = new Vector3(1, 1, 1); tempAuth.name = "InfoPanel"; targetHealth = UnityEngine.GameObject.Find("targethealthBarInfo").GetComponent <Image>(); targetHealth.fillAmount = 0f; Transform[] ts = tempAuth.transform.GetComponentsInChildren <Transform>(true); foreach (Transform t in ts) { if (t.gameObject.name == "InfoPanelName") { Text temo = t.gameObject.GetComponent <Text>(); temo.text = obj.Name; } if (obj is Unit) { unit = obj as Unit; if (t.gameObject.name == "InfoPanelLevel") { Text temo = t.gameObject.GetComponent <Text>(); if (obj is Unit) { if (unit.Health <= 0) { temo.text = unit.Level.ToString() + " (Corpse)"; } else { temo.text = unit.Level.ToString(); } } } uint healthPercent = (unit.Health * 200 + unit.MaxHealth) / (unit.MaxHealth * 2); targetHealth.fillAmount = healthPercent / 100f; } if (obj is Player) { player = obj as Player; if (t.gameObject.name == "InfoPanelLevel") { Text temo = t.gameObject.GetComponent <Text>(); temo.text = player.Level.ToString() + " " + player.Race + " " + player.Class; } uint healthPercent = (player.Health * 200 + player.MaxHealth) / (player.MaxHealth * 2); targetHealth.fillAmount = healthPercent / 100f; } } } if (this.obj is Unit) { Unit unit = this.obj as Unit; UnitFlags flags = (UnitFlags)unit.UnitFlags; UnitFlags2 flags2 = (UnitFlags2)unit.UnitFlags2; NPCFlags NpcFlags = (NPCFlags)unit.NpcFlags; float distance = Vector3.Distance(UnityEngine.GameObject.Find(Exchange.gameClient.Player.GUID.ToString()).transform.position, transform.position); if (NpcFlags.HasAnyFlag(NPCFlags.Gossip)) { if (distance > 4) { Texture2D texture2D = Resources.Load("Images/login/speak") as Texture2D; Cursor.SetCursor(texture2D, Vector2.zero, CursorMode.Auto); } else { Texture2D texture2D = Resources.Load("Images/login/speak") as Texture2D; Cursor.SetCursor(texture2D, Vector2.zero, CursorMode.Auto); } } if (NpcFlags.HasAnyFlag(NPCFlags.QuestGiver)) { if (distance > 4) { Texture2D texture2D = Resources.Load("Images/login/unablequest") as Texture2D; Cursor.SetCursor(texture2D, Vector2.zero, CursorMode.Auto); } else { Texture2D texture2D = Resources.Load("Images/login/quest") as Texture2D; Cursor.SetCursor(texture2D, Vector2.zero, CursorMode.Auto); } } } if (Input.GetKeyUp(KeyCode.Mouse0)) { if (this.obj is GameObject) { return; } if (Exchange.gameClient.Player.Target == this.obj) { return; } if (Exchange.gameClient.Player.Target != null) { UnityEngine.GameObject.Find(Exchange.gameClient.Player.Target.GUID.ToString() + "targetSelectUnderlay").GetComponent <SpriteRenderer>().enabled = false; } UnityEngine.GameObject.Find(obj.GUID.ToString() + "targetSelectUnderlay").GetComponent <SpriteRenderer>().enabled = true; //UnityEngine.GameObject.Find(obj.GUID.ToString() + "targetSelectUnderlay").GetComponent<SpriteRenderer>().color = Color.red; Exchange.gameClient.ThreadHelper.playAudio(obj, "interface/iselecttarget").Play(); Exchange.gameClient.ThreadHelper.setTarget(this.obj); } if (Input.GetKeyUp(KeyCode.Mouse1)) { if (Exchange.gameClient.Player.Target != this.obj) { if (Exchange.gameClient.Player.Target != null) { UnityEngine.GameObject.Find(Exchange.gameClient.Player.Target.GUID.ToString() + "targetSelectUnderlay").GetComponent <SpriteRenderer>().enabled = false; } UnityEngine.GameObject.Find(obj.GUID.ToString() + "targetSelectUnderlay").GetComponent <SpriteRenderer>().enabled = true; //UnityEngine.GameObject.Find(obj.GUID.ToString() + "targetSelectUnderlay").GetComponent<SpriteRenderer>().color = Color.red; Exchange.gameClient.ThreadHelper.playAudio(obj, "interface/iselecttarget").Play(); Exchange.gameClient.ThreadHelper.setTarget(this.obj); } float distance = Vector3.Distance(UnityEngine.GameObject.Find(Exchange.gameClient.Player.GUID.ToString()).transform.position, UnityEngine.GameObject.Find(Exchange.gameClient.Player.Target.GUID.ToString()).transform.position); if (distance > 4) { System.Random random = new System.Random(); int[] AudioFile = new int[3] { 2, 4, 5 }; int slot = AudioFile[random.Next(0, AudioFile.Length)]; Exchange.gameClient.ThreadHelper.playAudio(Exchange.gameClient.Player, "character/" + Exchange.gameClient.Player.Race.ToString() + "/" + Exchange.gameClient.Player.Race.ToString() + Exchange.gameClient.Player.Gender.ToString() + "errormessages/" + Exchange.gameClient.Player.Race.ToString() + Exchange.gameClient.Player.Gender.ToString() + "_err_outofrange0" + slot.ToString()).Play(); } } }