Beispiel #1
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);
                        }
                    }
                }
            }