Example #1
0
        public SmartScript Clone()
        {
            SmartScript newSmartScript = new SmartScript();

            newSmartScript.entryorguid      = entryorguid;
            newSmartScript.source_type      = source_type;
            newSmartScript.id               = id;
            newSmartScript.link             = link;
            newSmartScript.event_type       = event_type;
            newSmartScript.event_phase_mask = event_phase_mask;
            newSmartScript.event_chance     = event_chance;
            newSmartScript.event_flags      = event_flags;
            newSmartScript.event_param1     = event_param1;
            newSmartScript.event_param2     = event_param2;
            newSmartScript.event_param3     = event_param3;
            newSmartScript.event_param4     = event_param4;
            newSmartScript.action_type      = action_type;
            newSmartScript.action_param1    = action_param1;
            newSmartScript.action_param2    = action_param2;
            newSmartScript.action_param2    = action_param3;
            newSmartScript.action_param4    = action_param4;
            newSmartScript.action_param5    = action_param5;
            newSmartScript.action_param6    = action_param6;
            newSmartScript.target_type      = target_type;
            newSmartScript.target_param1    = target_param1;
            newSmartScript.target_param2    = target_param2;
            newSmartScript.target_param3    = target_param3;
            newSmartScript.target_x         = target_x;
            newSmartScript.target_y         = target_y;
            newSmartScript.target_z         = target_z;
            newSmartScript.target_o         = target_o;
            newSmartScript.comment          = comment;
            return(newSmartScript);
        }
Example #2
0
        public SmartScript Clone(SmartScript smartScript)
        {
            SmartScript newSmartScript = new SmartScript();

            newSmartScript.entryorguid      = smartScript.entryorguid;
            newSmartScript.source_type      = smartScript.source_type;
            newSmartScript.id               = smartScript.id;
            newSmartScript.link             = smartScript.link;
            newSmartScript.event_type       = smartScript.event_type;
            newSmartScript.event_phase_mask = smartScript.event_phase_mask;
            newSmartScript.event_chance     = smartScript.event_chance;
            newSmartScript.event_flags      = smartScript.event_flags;
            newSmartScript.event_param1     = smartScript.event_param1;
            newSmartScript.event_param2     = smartScript.event_param2;
            newSmartScript.event_param3     = smartScript.event_param3;
            newSmartScript.event_param4     = smartScript.event_param4;
            newSmartScript.action_type      = smartScript.action_type;
            newSmartScript.action_param1    = smartScript.action_param1;
            newSmartScript.action_param2    = smartScript.action_param2;
            newSmartScript.action_param2    = smartScript.action_param3;
            newSmartScript.action_param4    = smartScript.action_param4;
            newSmartScript.action_param5    = smartScript.action_param5;
            newSmartScript.action_param6    = smartScript.action_param6;
            newSmartScript.target_type      = smartScript.target_type;
            newSmartScript.target_param1    = smartScript.target_param1;
            newSmartScript.target_param2    = smartScript.target_param2;
            newSmartScript.target_param3    = smartScript.target_param3;
            newSmartScript.target_x         = smartScript.target_x;
            newSmartScript.target_y         = smartScript.target_y;
            newSmartScript.target_z         = smartScript.target_z;
            newSmartScript.target_o         = smartScript.target_o;
            newSmartScript.comment          = smartScript.comment;
            return(newSmartScript);
        }
Example #3
0
        public void AddSmartScript(SmartScript script)
        {
            ListViewItem lvi = new ListViewItem(script.entryorguid.ToString());
            lvi.Name = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {

                if (_excludedProperties.Contains(propInfo.Name))
                    continue;

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());

            }

            if (_smartScripts.All(p => p.entryorguid != script.entryorguid))
                _smartScripts.Add(script);

            Items.Add(lvi);
        }
        public int AddSmartScript(SmartScript script, bool listViewOnly = false)
        {
            ListViewItem lvi = new ListViewItem(script.entryorguid.ToString());
            lvi.Name = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {
                if (_excludedProperties.Contains(propInfo.Name))
                    continue;

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            }

            if (!listViewOnly)
                _smartScripts.Add(script);

            ListViewItem newItem = Items.Add(lvi);
            HandleHighlightItems();
            return newItem.Index;
        }
Example #5
0
        private async void TestForm_Load(object sender, EventArgs e)
        {

            smartScriptListView1 = new SmartScriptListView(await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(33303, (int)SourceTypes.SourceTypeCreature));
            smartScriptListView1.View = View.Details;

            smartScriptListView1.Size = new Size(5000, 500);

            Controls.Add(smartScriptListView1);

            var sm = new SmartScript { entryorguid = 123, comment = "test" };

            smartScriptListView1.AddSmartScript(sm);

            smartScriptListView1.ExcludeProperty("source_type");
            smartScriptListView1.IncludeProperty("source_type");

            smartScriptListView1.ReplaceSmartScript(new SmartScript { entryorguid = 123, comment = "testing123" });


        }
Example #6
0
        public async Task<TimedActionListOrEntries> GetTimedActionlistsOrEntries(SmartScript smartScript, SourceTypes sourceType)
        {
            TimedActionListOrEntries timedActionListOrEntries = new TimedActionListOrEntries();
            timedActionListOrEntries.entries = new List<string>();
            timedActionListOrEntries.sourceTypeOfEntry = SourceTypes.SourceTypeScriptedActionlist;

            if (sourceType == SourceTypes.SourceTypeScriptedActionlist)
            {
                List<SmartScript> smartScriptsCallingActionlist = await worldDatabase.GetSmartScriptsCallingActionLists();

                if (smartScriptsCallingActionlist != null)
                {
                    foreach (SmartScript _smartScript in smartScriptsCallingActionlist)
                    {
                        switch ((SmartAction)_smartScript.action_type)
                        {
                            case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                            case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                                if (_smartScript.action_param1 == smartScript.entryorguid ||
                                    _smartScript.action_param2 == smartScript.entryorguid ||
                                    _smartScript.action_param3 == smartScript.entryorguid ||
                                    _smartScript.action_param4 == smartScript.entryorguid ||
                                    _smartScript.action_param5 == smartScript.entryorguid ||
                                    _smartScript.action_param6 == smartScript.entryorguid)
                                {
                                    timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                    timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                }

                                break;
                            case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                                for (int i = _smartScript.action_param1; i <= _smartScript.action_param2; ++i)
                                {
                                    if (i == smartScript.entryorguid && !timedActionListOrEntries.entries.Contains(i.ToString()))
                                    {
                                        timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                        timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                        break;
                                    }
                                }
                                break;
                        }
                    }
                }
            }
            else
            {
                switch ((SmartAction)smartScript.action_type)
                {
                    case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                        timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                        timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                        timedActionListOrEntries.entries.Add(smartScript.action_param2.ToString());

                        if (smartScript.action_param3 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param3.ToString());

                        if (smartScript.action_param4 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param4.ToString());

                        if (smartScript.action_param5 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param5.ToString());

                        if (smartScript.action_param6 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param6.ToString());

                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                        for (int i = smartScript.action_param1; i <= smartScript.action_param2; ++i)
                            timedActionListOrEntries.entries.Add(i.ToString());
                        break;
                }
            }

            return timedActionListOrEntries;
        }
Example #7
0
 private string GenerateCommentForScript(SmartScript smartScript)
 {
     return String.Empty;
 }
Example #8
0
        public SmartScript BuildSmartScript(ListViewItem item)
        {
            SmartScript smartScript = new SmartScript();
            smartScript.entryorguid = XConverter.ToInt32(item.Text);
            smartScript.source_type = XConverter.ToInt32(item.SubItems[1].Text);
            smartScript.id = XConverter.ToInt32(item.SubItems[2].Text);
            smartScript.link = XConverter.ToInt32(item.SubItems[3].Text);
            smartScript.event_type = XConverter.ToInt32(item.SubItems[4].Text);
            smartScript.event_phase_mask = XConverter.ToInt32(item.SubItems[5].Text);
            smartScript.event_chance = XConverter.ToInt32(item.SubItems[6].Text);
            smartScript.event_flags = XConverter.ToInt32(item.SubItems[7].Text);
            smartScript.event_param1 = XConverter.ToInt32(item.SubItems[8].Text);
            smartScript.event_param2 = XConverter.ToInt32(item.SubItems[9].Text);
            smartScript.event_param3 = XConverter.ToInt32(item.SubItems[10].Text);
            smartScript.event_param4 = XConverter.ToInt32(item.SubItems[11].Text);
            smartScript.action_type = XConverter.ToInt32(item.SubItems[12].Text);
            smartScript.action_param1 = XConverter.ToInt32(item.SubItems[13].Text);
            smartScript.action_param2 = XConverter.ToInt32(item.SubItems[14].Text);
            smartScript.action_param3 = XConverter.ToInt32(item.SubItems[15].Text);
            smartScript.action_param4 = XConverter.ToInt32(item.SubItems[16].Text);
            smartScript.action_param5 = XConverter.ToInt32(item.SubItems[17].Text);
            smartScript.action_param6 = XConverter.ToInt32(item.SubItems[18].Text);
            smartScript.target_type = XConverter.ToInt32(item.SubItems[19].Text);
            smartScript.target_param1 = XConverter.ToInt32(item.SubItems[20].Text);
            smartScript.target_param2 = XConverter.ToInt32(item.SubItems[21].Text);
            smartScript.target_param3 = XConverter.ToInt32(item.SubItems[22].Text);
            smartScript.target_x = XConverter.ToInt32(item.SubItems[23].Text);
            smartScript.target_y = XConverter.ToInt32(item.SubItems[24].Text);
            smartScript.target_z = XConverter.ToInt32(item.SubItems[25].Text);
            smartScript.target_o = XConverter.ToInt32(item.SubItems[26].Text);

            //! This method is also called when we generate a comment, so the field is not yet filled
            if (item.SubItems.Count > 27)
                smartScript.comment = item.SubItems[27].Text;

            return smartScript;
        }
Example #9
0
 private string GetStringByTargetType(SmartScript smartScript, WorldDatabase worldDatabase)
 {
     switch ((SmartTarget)smartScript.target_type)
     {
         case SmartTarget.SMART_TARGET_SELF:
             return "Self";
         case SmartTarget.SMART_TARGET_VICTIM:
             return "Victim";
         case SmartTarget.SMART_TARGET_HOSTILE_SECOND_AGGRO:
             return "Second On Threatlist";
         case SmartTarget.SMART_TARGET_HOSTILE_LAST_AGGRO:
             return "Last On Threatlist";
         case SmartTarget.SMART_TARGET_HOSTILE_RANDOM:
             return "Random On Threatlist";
         case SmartTarget.SMART_TARGET_HOSTILE_RANDOM_NOT_TOP:
             return "Random On Threatlist Not Top";
         case SmartTarget.SMART_TARGET_ACTION_INVOKER:
             return "Invoker";
         case SmartTarget.SMART_TARGET_POSITION:
             return "Position";
         case SmartTarget.SMART_TARGET_CREATURE_RANGE:
         case SmartTarget.SMART_TARGET_CREATURE_DISTANCE:
         case SmartTarget.SMART_TARGET_CLOSEST_CREATURE:
             return "Closest Creature '" + worldDatabase.GetCreatureNameById(smartScript.target_param1) + "'";
         case SmartTarget.SMART_TARGET_CREATURE_GUID:
             return "Closest Creature '" + worldDatabase.GetCreatureNameByGuid(smartScript.target_param1) + "'";
         case SmartTarget.SMART_TARGET_GAMEOBJECT_RANGE:
         case SmartTarget.SMART_TARGET_GAMEOBJECT_DISTANCE:
         case SmartTarget.SMART_TARGET_CLOSEST_GAMEOBJECT:
             return "Closest Gameobject '" + worldDatabase.GetGameobjectNameById(smartScript.target_param1) + "'";
         case SmartTarget.SMART_TARGET_GAMEOBJECT_GUID:
             return "Closest Gameobject '" + worldDatabase.GetGameobjectNameByGuid(smartScript.target_param1) + "'";
         case SmartTarget.SMART_TARGET_INVOKER_PARTY:
             return "Invoker's Party";
         case SmartTarget.SMART_TARGET_PLAYER_RANGE:
         case SmartTarget.SMART_TARGET_PLAYER_DISTANCE:
         case SmartTarget.SMART_TARGET_CLOSEST_PLAYER:
             return "Closest Player";
         case SmartTarget.SMART_TARGET_ACTION_INVOKER_VEHICLE:
             return "Invoker's Vehicle";
         case SmartTarget.SMART_TARGET_OWNER_OR_SUMMONER:
             return "Owner Or Summoner";
         case SmartTarget.SMART_TARGET_THREAT_LIST:
             return "First Unit On Threatlist";
         case SmartTarget.SMART_TARGET_CLOSEST_ENEMY:
             return "Closest Enemy";
         case SmartTarget.SMART_TARGET_CLOSEST_FRIENDLY:
             return "Closest Friendly Unit";
         default:
             return "<unsupported target type>";
     }
 }
Example #10
0
        public async Task<string> GenerateCommentFor(SmartScript smartScript, EntryOrGuidAndSourceType entryOrGuidAndSourceType, bool forced = false)
        {
            if (!forced && !Settings.Default.GenerateComments)
                return String.IsNullOrWhiteSpace(smartScript.comment) ? "Npc - Event - Action (phase) (dungeon difficulty)" : smartScript.comment;

            string fullLine = String.Empty;

            try
            {
                WorldDatabase worldDatabase = SAI_Editor_Manager.Instance.worldDatabase;
                SQLiteDatabase sqliteDatabase = SAI_Editor_Manager.Instance.sqliteDatabase;

                SmartScript smartScriptLink = null;
                int entry = smartScript.entryorguid;

                switch (smartScript.source_type)
                {
                    case 0: //! Creature
                        fullLine += await worldDatabase.GetObjectNameByIdOrGuidAndSourceType(SourceTypes.SourceTypeCreature, smartScript.entryorguid) + " - ";
                        fullLine += smartEventStrings[(SmartEvent)smartScript.event_type];
                        break;
                    case 1: //! Gameobject
                        fullLine += await worldDatabase.GetObjectNameByIdOrGuidAndSourceType(SourceTypes.SourceTypeGameobject, smartScript.entryorguid) + " - ";
                        fullLine += smartEventStrings[(SmartEvent)smartScript.event_type];
                        break;
                    case 9: //! Actionlist
                        if (entryOrGuidAndSourceType.sourceType == SourceTypes.SourceTypeScriptedActionlist)
                        {
                            TimedActionListOrEntries timedActionListOrEntries = await SAI_Editor_Manager.Instance.GetTimedActionlistsOrEntries(smartScript, SourceTypes.SourceTypeScriptedActionlist);

                            if (timedActionListOrEntries.entries != null && timedActionListOrEntries.entries.Count > 0)
                                fullLine += await worldDatabase.GetObjectNameByIdOrGuidAndSourceType(timedActionListOrEntries.sourceTypeOfEntry, XConverter.ToInt32(timedActionListOrEntries.entries[0])) + " - ";
                        }
                        else
                            fullLine += await worldDatabase.GetObjectNameByIdOrGuidAndSourceType(entryOrGuidAndSourceType.sourceType, entryOrGuidAndSourceType.entryOrGuid) + " - ";

                        fullLine += "On Script";
                        break;
                    case 2: //! Areatrigger
                        return String.Empty;
                }

                if (fullLine.Contains("_previousLineComment_"))
                {
                    if (smartScriptLink != null)
                    {
                        fullLine = fullLine.Replace("_previousLineComment_", smartEventStrings[(SmartEvent)smartScriptLink.event_type]);
                        smartScript.event_param1 = Convert.ToInt32(smartScriptLink.event_param1);
                        smartScript.event_param2 = Convert.ToInt32(smartScriptLink.event_param2);
                        smartScript.event_param3 = Convert.ToInt32(smartScriptLink.event_param3);
                        smartScript.event_param4 = Convert.ToInt32(smartScriptLink.event_param4);

                        if (smartScriptLink.link == 0)
                            smartScriptLink = null;
                    }
                }
                else if (smartScript.link > 0)
                    smartScriptLink = smartScript;

                //! This must be called AFTER we check for _previousLineComment_ so that copied event types don't need special handling
                if (fullLine.Contains("_eventParamOne_"))
                    fullLine = fullLine.Replace("_eventParamOne_", smartScript.event_param1.ToString());

                if (fullLine.Contains("_eventParamTwo_"))
                    fullLine = fullLine.Replace("_eventParamTwo_", smartScript.event_param2.ToString());

                if (fullLine.Contains("_eventParamThree_"))
                    fullLine = fullLine.Replace("_eventParamThree_", smartScript.event_param3.ToString());

                if (fullLine.Contains("_eventParamFour_"))
                    fullLine = fullLine.Replace("_eventParamFour_", smartScript.event_param4.ToString());

                if (fullLine.Contains("_spellNameEventParamOne_"))
                {
                    if (smartScript.event_param1 > 0)
                        fullLine = fullLine.Replace("_spellNameEventParamOne_", await sqliteDatabase.GetSpellNameById(smartScript.event_param1));
                    else
                        fullLine = fullLine.Replace(" '_spellNameEventParamOne_'", String.Empty);
                }

                if (fullLine.Contains("_targetCastingSpellName_"))
                {
                    if (smartScript.event_param3.ToString() != "0")
                        fullLine = fullLine.Replace("_targetCastingSpellName_", await sqliteDatabase.GetSpellNameById(smartScript.event_param3));
                    else
                        fullLine = fullLine.Replace(" '_targetCastingSpellName_'", String.Empty);
                }

                if (fullLine.Contains("_questNameEventParamOne_"))
                {
                    if (smartScript.event_param1 == 0) //! Any quest (SMART_EVENT_ACCEPTED_QUEST / SMART_EVENT_REWARD_QUEST)
                        fullLine = fullLine.Replace(" '_questNameEventParamOne_'", String.Empty);
                    else
                        fullLine = fullLine.Replace("_questNameEventParamOne_", await worldDatabase.GetQuestTitleById(smartScript.event_param1));
                }

                if (fullLine.Contains("_hasAuraEventParamOne_"))
                    fullLine = fullLine.Replace("_hasAuraEventParamOne_", smartScript.event_param1 > 0 ? "Has Aura" : "Aura Not Present");

                //! Action type
                fullLine += " - " + smartActionStrings[(SmartAction)smartScript.action_type];

                if (fullLine.Contains("_actionParamOne_"))
                    fullLine = fullLine.Replace("_actionParamOne_", smartScript.action_param1.ToString());

                if (fullLine.Contains("_actionParamTwo_"))
                    fullLine = fullLine.Replace("_actionParamTwo_", smartScript.action_param2.ToString());

                if (fullLine.Contains("_actionParamThree_"))
                    fullLine = fullLine.Replace("_actionParamThree_", smartScript.action_param3.ToString());

                if (fullLine.Contains("_actionParamFour_"))
                    fullLine = fullLine.Replace("_actionParamFour_", smartScript.action_param4.ToString());

                if (fullLine.Contains("_actionParamFive_"))
                    fullLine = fullLine.Replace("_actionParamFive_", smartScript.action_param5.ToString());

                if (fullLine.Contains("_actionParamSix_"))
                    fullLine = fullLine.Replace("_actionParamSix_", smartScript.action_param6.ToString());

                if (fullLine.Contains("_spellNameActionParamOne_"))
                {
                    if (smartScript.action_param1.ToString() != "0")
                        fullLine = fullLine.Replace("_spellNameActionParamOne_", await sqliteDatabase.GetSpellNameById(smartScript.action_param1));
                    else
                        fullLine = fullLine.Replace(" '_spellNameActionParamOne_'", String.Empty);
                }

                if (fullLine.Contains("_spellNameActionParamTwo_"))
                {
                    if (smartScript.action_param2.ToString() != "0")
                        fullLine = fullLine.Replace("_spellNameActionParamTwo_", await sqliteDatabase.GetSpellNameById(smartScript.action_param2));
                    else
                        fullLine = fullLine.Replace(" '_spellNameActionParamTwo_'", String.Empty);
                }

                if (fullLine.Contains("_questNameActionParamOne_"))
                    fullLine = fullLine.Replace("_questNameActionParamOne_", await worldDatabase.GetQuestTitleById(smartScript.action_param1));

                if (fullLine.Contains("_questNameCastCreatureOrGo_"))
                    fullLine = fullLine.Replace("_questNameCastCreatureOrGo_", await worldDatabase.GetQuestTitleByCriteria(smartScript.action_param1, smartScript.action_param1, smartScript.action_param1, smartScript.action_param1, smartScript.action_param2));

                if (fullLine.Contains("_questNameKillCredit_"))
                    fullLine = fullLine.Replace("_questNameKillCredit_", await worldDatabase.GetQuestTitleByCriteria(smartScript.action_param1, smartScript.action_param1, smartScript.action_param1, smartScript.action_param1));

                if (fullLine.Contains("_reactStateParamOne_"))
                {
                    switch (smartScript.action_param1)
                    {
                        case 0:
                            fullLine = fullLine.Replace("_reactStateParamOne_", "Passive");
                            break;
                        case 1:
                            fullLine = fullLine.Replace("_reactStateParamOne_", "Defensive");
                            break;
                        case 2:
                            fullLine = fullLine.Replace("_reactStateParamOne_", "Aggressive");
                            break;
                        default:
                            fullLine = fullLine.Replace("_reactStateParamOne_", "<Unknown Reactstate>");
                            break;
                    }
                }

                if (fullLine.Contains("_actionRandomParameters_"))
                {
                    string randomEmotes = smartScript.action_param1 + ", " + smartScript.action_param2;

                    if (smartScript.action_param3 > 0)
                        randomEmotes += ", " + smartScript.action_param3;

                    if (smartScript.action_param4 > 0)
                        randomEmotes += ", " + smartScript.action_param4;

                    if (smartScript.action_param5 > 0)
                        randomEmotes += ", " + smartScript.action_param5;

                    if (smartScript.action_param6 > 0)
                        randomEmotes += ", " + smartScript.action_param6;

                    fullLine = fullLine.Replace("_actionRandomParameters_", randomEmotes);
                }

                if (fullLine.Contains("_creatureNameActionParamOne_"))
                    fullLine = fullLine.Replace("_creatureNameActionParamOne_", await worldDatabase.GetCreatureNameById(smartScript.action_param1));

                if (fullLine.Contains("_getUnitFlags_"))
                {
                    string commentUnitFlag = "";
                    int unitFlags = smartScript.action_param1;

                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SERVER_CONTROLLED) != 0) commentUnitFlag += "Server Controlled & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_NON_ATTACKABLE) != 0) commentUnitFlag += "Not Attackable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_DISABLE_MOVE) != 0) commentUnitFlag += "Disable Movement & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PVP_ATTACKABLE) != 0) commentUnitFlag += "Pvp Attackable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_RENAME) != 0) commentUnitFlag += "Rename & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PREPARATION) != 0) commentUnitFlag += "Preparation & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_NOT_ATTACKABLE_1) != 0) commentUnitFlag += "Not Attackable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_IMMUNE_TO_PC) != 0) commentUnitFlag += "Immune To Players & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_IMMUNE_TO_NPC) != 0) commentUnitFlag += "Immune To NPC's & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_LOOTING) != 0) commentUnitFlag += "Looting & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PET_IN_COMBAT) != 0) commentUnitFlag += "Pet In Combat & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PVP) != 0) commentUnitFlag += "PvP & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SILENCED) != 0) commentUnitFlag += "Silenced & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PACIFIED) != 0) commentUnitFlag += "Pacified & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_STUNNED) != 0) commentUnitFlag += "Stunned & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_IN_COMBAT) != 0) commentUnitFlag += "In Combat & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_DISARMED) != 0) commentUnitFlag += "Disarmed & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_CONFUSED) != 0) commentUnitFlag += "Confused & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_FLEEING) != 0) commentUnitFlag += "Fleeing & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PLAYER_CONTROLLED) != 0) commentUnitFlag += "Player Controlled & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_NOT_SELECTABLE) != 0) commentUnitFlag += "Not Selectable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SKINNABLE) != 0) commentUnitFlag += "Skinnable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_MOUNT) != 0) commentUnitFlag += "Mounted & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SHEATHE) != 0) commentUnitFlag += "Sheathed & ";

                    commentUnitFlag = commentUnitFlag.Trim(new[] { ' ', '&', ' ' }); //! Trim last ' & ' from the comment..

                    if (commentUnitFlag.Contains("&"))
                        fullLine = fullLine.Replace("_getUnitFlags_", "s_getUnitFlags_");

                    fullLine = fullLine.Replace("_getUnitFlags_", " " + commentUnitFlag);
                }

                if (fullLine.Contains("_startOrStopActionParamOne_"))
                {
                    if (smartScript.action_param1.ToString() == "0")
                        fullLine = fullLine.Replace("_startOrStopActionParamOne_", "Stop");
                    else //! Even if above 1 or below 0 we start attacking/allow-combat-movement
                        fullLine = fullLine.Replace("_startOrStopActionParamOne_", "Start");
                }

                if (fullLine.Contains("_enableDisableActionParamOne_"))
                {
                    if (smartScript.action_param1.ToString() == "0")
                        fullLine = fullLine.Replace("_enableDisableActionParamOne_", "Disable");
                    else //! Even if above 1 or below 0 we start attacking/allow-combat-movement
                        fullLine = fullLine.Replace("_enableDisableActionParamOne_", "Enable");
                }

                if (fullLine.Contains("_incrementOrDecrementActionParamOne_"))
                {
                    if (smartScript.action_param1.ToString() == "1")
                        fullLine = fullLine.Replace("_incrementOrDecrementActionParamOne_", "Increment");
                    else if (smartScript.action_param2.ToString() == "1")
                        fullLine = fullLine.Replace("_incrementOrDecrementActionParamOne_", "Decrement");
                    //else //? What to do?
                }

                if (fullLine.Contains("_sheathActionParamOne_"))
                {
                    switch (smartScript.action_param1)
                    {
                        case 0:
                            fullLine = fullLine.Replace("_sheathActionParamOne_", "Unarmed");
                            break;
                        case 1:
                            fullLine = fullLine.Replace("_sheathActionParamOne_", "Melee");
                            break;
                        case 2:
                            fullLine = fullLine.Replace("_sheathActionParamOne_", "Ranged");
                            break;
                        default:
                            fullLine = fullLine.Replace("_sheathActionParamOne_", "<Unknown Sheath>");
                            break;
                    }
                }

                if (fullLine.Contains("_forceDespawnActionParamOne_"))
                {
                    if (smartScript.action_param1 > 2)
                        fullLine = fullLine.Replace("_forceDespawnActionParamOne_", "In " + smartScript.action_param1 + " ms");
                    else
                        fullLine = fullLine.Replace("_forceDespawnActionParamOne_", "Instant");
                }

                if (fullLine.Contains("_invincibilityHpActionParamsOneTwo_"))
                {
                    if (smartScript.action_param1 > 0)
                        fullLine = fullLine.Replace("_invincibilityHpActionParamsOneTwo_", smartScript.action_param1.ToString());
                    else if (smartScript.action_param2 > 0)
                        fullLine = fullLine.Replace("_invincibilityHpActionParamsOneTwo_", smartScript.action_param2 + "%");
                    else
                        fullLine = fullLine.Replace("_invincibilityHpActionParamsOneTwo_", "<Unsupported parameters>");
                }

                if (fullLine.Contains("_onOffActionParamOne_"))
                {
                    if (smartScript.action_param1 == 1)
                        fullLine = fullLine.Replace("_onOffActionParamOne_", "On");
                    else
                        fullLine = fullLine.Replace("_onOffActionParamOne_", "Off");
                }

                if (fullLine.Contains("_gameobjectNameActionParamOne_"))
                    fullLine = fullLine.Replace("_gameobjectNameActionParamOne_", await worldDatabase.GetGameobjectNameById(smartScript.action_param1));

                if (fullLine.Contains("_addItemBasedOnActionParams_"))
                {
                    fullLine = fullLine.Replace("_addItemBasedOnActionParams_", "'" + await worldDatabase.GetItemNameById(smartScript.action_param1) + "' ");

                    if (smartScript.action_param2 > 1)
                        fullLine += smartScript.action_param2 + " Times";
                    else
                        fullLine += "1 Time";
                }

                if (fullLine.Contains("_updateAiTemplateActionParamOne_"))
                {
                    switch ((SmartAiTemplates)smartScript.action_param1)
                    {
                        case SmartAiTemplates.SMARTAI_TEMPLATE_BASIC:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "Basic");
                            break;
                        case SmartAiTemplates.SMARTAI_TEMPLATE_CASTER:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "Caster");
                            break;
                        case SmartAiTemplates.SMARTAI_TEMPLATE_TURRET:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "Turret");
                            break;
                        case SmartAiTemplates.SMARTAI_TEMPLATE_PASSIVE:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "Passive");
                            break;
                        case SmartAiTemplates.SMARTAI_TEMPLATE_CAGED_GO_PART:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "Caged Gameobject Part");
                            break;
                        case SmartAiTemplates.SMARTAI_TEMPLATE_CAGED_NPC_PART:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "Caged Creature Part");
                            break;
                        default:
                            fullLine = fullLine.Replace("_updateAiTemplateActionParamOne_", "<_updateAiTemplateActionParamOne_ Unknown ai template>");
                            break;
                    }
                }

                if (fullLine.Contains("_setOrientationTargetType_"))
                {
                    switch ((SmartTarget)smartScript.target_type)
                    {
                        case SmartTarget.SMART_TARGET_SELF:
                            fullLine = fullLine.Replace("_setOrientationTargetType_", "Home Position");
                            break;
                        case SmartTarget.SMART_TARGET_POSITION:
                            fullLine = fullLine.Replace("_setOrientationTargetType_", smartScript.target_o.ToString());
                            break;
                        default:
                            fullLine = fullLine.Replace("_setOrientationTargetType_", "To Target");
                            break;
                    }
                }

                if (fullLine.Contains("_getTargetType_"))
                    fullLine = fullLine.Replace("_getTargetType_", GetStringByTargetType(smartScript, worldDatabase));

                if (fullLine.Contains("_goStateActionParamOne_"))
                {
                    switch (smartScript.action_param1)
                    {
                        case 0:
                            fullLine = fullLine.Replace("_goStateActionParamOne_", "Not Ready");
                            break;
                        case 1:
                            fullLine = fullLine.Replace("_goStateActionParamOne_", "Ready");
                            break;
                        case 2:
                            fullLine = fullLine.Replace("_goStateActionParamOne_", "Activated");
                            break;
                        case 3:
                            fullLine = fullLine.Replace("_goStateActionParamOne_", "Deactivated");
                            break;
                        default:
                            fullLine = fullLine.Replace("_goStateActionParamOne_", "<Unknown Gameobject State>");
                            break;
                    }
                }

                if (fullLine.Contains("_getGoFlags_"))
                {
                    string commentGoFlag = "";
                    int goFlags = smartScript.action_param1;

                    if ((goFlags & (int)GoFlags.GO_FLAG_IN_USE) != 0) commentGoFlag += "In Use & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_LOCKED) != 0) commentGoFlag += "Locked & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_INTERACT_COND) != 0) commentGoFlag += "Interact Condition & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_TRANSPORT) != 0) commentGoFlag += "Transport & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_NOT_SELECTABLE) != 0) commentGoFlag += "Not Selectable & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_NODESPAWN) != 0) commentGoFlag += "No Despawn & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_TRIGGERED) != 0) commentGoFlag += "Triggered & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_DAMAGED) != 0) commentGoFlag += "Damaged & ";
                    if ((goFlags & (int)GoFlags.GO_FLAG_DESTROYED) != 0) commentGoFlag += "Destroyed & ";

                    commentGoFlag = commentGoFlag.Trim(new[] { ' ', '&', ' ' }); //! Trim last ' & ' from the comment..

                    if (commentGoFlag.Contains("&"))
                        fullLine = fullLine.Replace("_getGoFlags_", "s_getGoFlags_");

                    fullLine = fullLine.Replace("_getGoFlags_", " " + commentGoFlag);
                }

                if (fullLine.Contains("_getDynamicFlags_"))
                {
                    string commentDynamicFlag = "";
                    int dynamicFlags = smartScript.action_param1;

                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_NONE) != 0) commentDynamicFlag += "None & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_LOOTABLE) != 0) commentDynamicFlag += "Lootable & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_TRACK_UNIT) != 0) commentDynamicFlag += "Track Units & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_TAPPED) != 0) commentDynamicFlag += "Tapped & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_TAPPED_BY_PLAYER) != 0) commentDynamicFlag += "Tapped By Player & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_SPECIALINFO) != 0) commentDynamicFlag += "Special Info & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_DEAD) != 0) commentDynamicFlag += "Dead & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_REFER_A_FRIEND) != 0) commentDynamicFlag += "Refer A Friend & ";
                    if ((dynamicFlags & (int)DynamicFlags.UNIT_DYNFLAG_TAPPED_BY_ALL_THREAT_LIST) != 0) commentDynamicFlag += "Tapped By Threatlist & ";

                    commentDynamicFlag = commentDynamicFlag.Trim(new[] { ' ', '&', ' ' }); //! Trim last ' & ' from the comment..

                    if (commentDynamicFlag.Contains("&"))
                        fullLine = fullLine.Replace("_getDynamicFlags_", "s_getDynamicFlags_");

                    fullLine = fullLine.Replace("_getDynamicFlags_", " " + commentDynamicFlag);
                }

                if (fullLine.Contains("_getBytes1Flags_"))
                {
                    switch ((UnitFieldBytes1Type)smartScript.action_param2)
                    {
                        case UnitFieldBytes1Type.UnitStandStateType:
                            {
                                switch ((UnitStandStateType)smartScript.action_param1)
                                {
                                    case UnitStandStateType.UNIT_STAND_STATE_STAND:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Stand Up");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SIT:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Sit Down");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SIT_CHAIR:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Sit Down Chair");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SLEEP:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Sleep");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SIT_LOW_CHAIR:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Sit Low Chair");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SIT_MEDIUM_CHAIR:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Sit Medium Chair");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SIT_HIGH_CHAIR:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Sit High Chair");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_DEAD:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Dead");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_KNEEL:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Kneel");
                                        break;
                                    case UnitStandStateType.UNIT_STAND_STATE_SUBMERGED:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Standstate Submerged");
                                        break;
                                    default:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "<Unknown bytes1 (UnitStandStateType)>");
                                        break;
                                }
                                break;
                            }
                        case UnitFieldBytes1Type.UnitStandFlags:
                            {
                                switch ((UnitStandFlags)smartScript.action_param1)
                                {
                                    case UnitStandFlags.UNIT_STAND_FLAGS_UNK1:
                                    case UnitStandFlags.UNIT_STAND_FLAGS_UNK4:
                                    case UnitStandFlags.UNIT_STAND_FLAGS_UNK5:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "<Unknown>");
                                        break;
                                    case UnitStandFlags.UNIT_STAND_FLAGS_CREEP:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Creep");
                                        break;
                                    case UnitStandFlags.UNIT_STAND_FLAGS_UNTRACKABLE:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Untrackable");
                                        break;
                                    default:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "<Unknown bytes1 (UnitStandFlags)>");
                                        break;
                                }
                                break;
                            }
                        case UnitFieldBytes1Type.UnitBytes1_Flags:
                            {
                                switch ((UnitBytes1_Flags)smartScript.action_param1)
                                {
                                    case UnitBytes1_Flags.UNIT_BYTE1_FLAG_UNK_3:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "<Unknown>");
                                        break;
                                    case UnitBytes1_Flags.UNIT_BYTE1_FLAG_HOVER:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Hover");
                                        break;
                                    case UnitBytes1_Flags.UNIT_BYTE1_FLAG_ALWAYS_STAND:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "Always Stand");
                                        break;
                                    default:
                                        fullLine = fullLine.Replace("_getBytes1Flags_", "<Unknown bytes1 (UnitBytes1_Flags)>");
                                        break;
                                }
                                break;
                            }
                    }
                }

                if (fullLine.Contains("_powerTypeActionParamOne_"))
                {
                    switch (smartScript.action_param1)
                    {
                        case 0:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Mana");
                            break;
                        case 1:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Rage");
                            break;
                        case 2:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Focus");
                            break;
                        case 3:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Energy");
                            break;
                        case 4:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Happiness");
                            break;
                        case 5:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Rune");
                            break;
                        case 6:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "Runic Power");
                            break;
                        default:
                            fullLine = fullLine.Replace("_powerTypeActionParamOne_", "<Unknown Powertype>");
                            break;
                    }
                }

                if (fullLine.Contains("_getUnitFlags_"))
                {
                    string commentUnitFlag = "";
                    int unitFlags = smartScript.action_param1;

                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SERVER_CONTROLLED) != 0) commentUnitFlag += "Server Controlled & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_NON_ATTACKABLE) != 0) commentUnitFlag += "Not Attackable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_DISABLE_MOVE) != 0) commentUnitFlag += "Disable Move & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PVP_ATTACKABLE) != 0) commentUnitFlag += "PvP Attackable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_RENAME) != 0) commentUnitFlag += "Rename & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PREPARATION) != 0) commentUnitFlag += "Preparation & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_NOT_ATTACKABLE_1) != 0) commentUnitFlag += "Not Attackable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_IMMUNE_TO_PC) != 0) commentUnitFlag += "Immune To Players & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_IMMUNE_TO_NPC) != 0) commentUnitFlag += "Immune To Creatures & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_LOOTING) != 0) commentUnitFlag += "Looting & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PET_IN_COMBAT) != 0) commentUnitFlag += "Pet In Combat & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PVP) != 0) commentUnitFlag += "PvP & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SILENCED) != 0) commentUnitFlag += "Silenced & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PACIFIED) != 0) commentUnitFlag += "Pacified & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_STUNNED) != 0) commentUnitFlag += "Stunned & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_IN_COMBAT) != 0) commentUnitFlag += "In Combat & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_TAXI_FLIGHT) != 0) commentUnitFlag += "Taxi Flight & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_DISARMED) != 0) commentUnitFlag += "Disarmed & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_CONFUSED) != 0) commentUnitFlag += "Confused & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_FLEEING) != 0) commentUnitFlag += "Fleeing & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_PLAYER_CONTROLLED) != 0) commentUnitFlag += "Player Controlled & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_NOT_SELECTABLE) != 0) commentUnitFlag += "Not Selectable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SKINNABLE) != 0) commentUnitFlag += "Skinnable & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_MOUNT) != 0) commentUnitFlag += "Mounted & ";
                    if ((unitFlags & (int)UnitFlags.UNIT_FLAG_SHEATHE) != 0) commentUnitFlag += "Sheathed & ";

                    commentUnitFlag = commentUnitFlag.Trim(new[] { ' ', '&', ' ' }); //! Trim last ' & ' from the comment..

                    if (commentUnitFlag.Contains("&"))
                        fullLine = fullLine.Replace("_getUnitFlags_", "s_getUnitFlags_");

                    fullLine = fullLine.Replace("_getUnitFlags_", " " + commentUnitFlag);
                }

                if (fullLine.Contains("_morphToEntryOrModelActionParams_"))
                {
                    if (smartScript.action_param1 > 0)
                        fullLine = fullLine.Replace("_morphToEntryOrModelActionParams_", "Morph To Creature " + worldDatabase.GetCreatureNameById(smartScript.action_param1));
                    else if (smartScript.action_param2 > 0)
                        fullLine = fullLine.Replace("_morphToEntryOrModelActionParams_", "Morph To Model " + smartScript.action_param2);
                    else
                        fullLine = fullLine.Replace("_morphToEntryOrModelActionParams_", "Demorph");
                }

                if (fullLine.Contains("_mountToEntryOrModelActionParams_"))
                {
                    if (smartScript.action_param1 > 0)
                        fullLine = fullLine.Replace("_mountToEntryOrModelActionParams_", "Mount To Creature " + worldDatabase.GetCreatureNameById(smartScript.action_param1));
                    else if (smartScript.action_param2 > 0)
                        fullLine = fullLine.Replace("_mountToEntryOrModelActionParams_", "Mount To Model " + smartScript.action_param2);
                    else
                        fullLine = fullLine.Replace("_mountToEntryOrModelActionParams_", "Dismount");
                }

                if (smartScript.event_phase_mask > 0)
                {
                    List<int> listOfSplitPhases = new List<int>();

                    int event_phase_mask = smartScript.event_phase_mask;
                    int event_phase_mask2 = event_phase_mask;
                    int log2 = 0;

                    while (event_phase_mask2 >= 2)
                    {
                        event_phase_mask2 /= 2;
                        log2++;
                    }

                    for (int l2 = log2; l2 >= 0; l2--)
                    {
                        int power = (int)Math.Pow(2, l2);

                        if (event_phase_mask >= power)
                        {
                            event_phase_mask -= power;
                            listOfSplitPhases.Add(power);
                        }
                    }

                    int[] arrayOfSplitPhases = listOfSplitPhases.ToArray();
                    Array.Reverse(arrayOfSplitPhases); //! Reverse them so they are ascending
                    fullLine += " (Phase";

                    if (listOfSplitPhases.Count > 1)
                        fullLine += "s";

                    fullLine += " " + String.Join(" & ", arrayOfSplitPhases) + ")";
                }

                if (smartScript.event_flags > 0)
                {
                    if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_NOT_REPEATABLE) != 0))
                        fullLine += " (No Repeat)";

                    if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_0) != 0) && (((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_1) != 0) &&
                        (((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_2) != 0) && (((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_3) != 0))
                        fullLine += " (Dungeon & Raid)";
                    else
                    {
                        if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_0) != 0) && (((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_1) != 0))
                            fullLine += " (Dungeon)";
                        else
                        {
                            if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_0) != 0))
                                fullLine += " (Normal Dungeon)";
                            else if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_1) != 0))
                                fullLine += " (Heroic Dungeon)";
                        }

                        if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_2) != 0) && (((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_3) != 0))
                            fullLine += " (Raid)";
                        else
                        {
                            if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_2) != 0))
                                fullLine += " (Normal Raid)";
                            else if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DIFFICULTY_3) != 0))
                                fullLine += " (Heroic Raid)";
                        }
                    }

                    if ((((SmartEventFlags)smartScript.event_flags & SmartEventFlags.SMART_EVENT_FLAG_DEBUG_ONLY) != 0))
                        fullLine += " (Debug)";
                }

                return fullLine;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return fullLine;
        }
Example #11
0
        private async void buttonNewLine_Click(object sender, EventArgs e)
        {
            if (listViewSmartScripts.Items.Count == 0)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure you want to create a new script for the given entry and sourcetype?", "Something went wrong", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dialogResult == DialogResult.Yes)
                    TryToCreateScript();

                return;
            }

            buttonNewLine.Enabled = false;
            SmartScript newSmartScript = new SmartScript();
            newSmartScript.entryorguid = originalEntryOrGuidAndSourceType.entryOrGuid;
            newSmartScript.source_type = (int)originalEntryOrGuidAndSourceType.sourceType;

            if (checkBoxLockEventId.Checked)
                newSmartScript.id = ++lastSmartScriptIdOfScript;
            else
                newSmartScript.id = -1;

            if (Settings.Default.GenerateComments)
                newSmartScript.comment = await CommentGenerator.Instance.GenerateCommentFor(newSmartScript, originalEntryOrGuidAndSourceType);
            else
                newSmartScript.comment = GetDefaultCommentForSourceType((SourceTypes)newSmartScript.source_type);

            newSmartScript.event_chance = 100;
            int index = listViewSmartScripts.AddSmartScript(newSmartScript);
            HandleShowBasicInfo();

            listViewSmartScripts.Items[index].Selected = true;
            listViewSmartScripts.Select();
            listViewSmartScripts.EnsureVisible(index);

            buttonNewLine.Enabled = true;
        }
Example #12
0
        public async void TryToCreateScript()
        {
            if (listViewSmartScripts.Items.Count > 0)
            {
                DialogResult dialogResult = MessageBox.Show("There is already a script loaded at this moment. Do you want to overwrite this?\n\nWarning: overwriting means local unsaved changes will also be discarded!", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                
                if (dialogResult != DialogResult.Yes)
                    return;

                ResetFieldsToDefault();
            }

            int entryorguid = 0;

            try
            {
                entryorguid = Int32.Parse(textBoxEntryOrGuid.Text);
            }
            catch (OverflowException)
            {
                MessageBox.Show("The entryorguid is either too big or too small.", "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int source_type = (int)GetSourceTypeByIndex();
            string sourceTypeString = GetSourceTypeString((SourceTypes)source_type);
            string aiName = await SAI_Editor_Manager.Instance.worldDatabase.GetObjectAiName(entryorguid, source_type);
            lastSmartScriptIdOfScript = 0;

            if ((SourceTypes)source_type == SourceTypes.SourceTypeAreaTrigger)
            {
                if (aiName != String.Empty)
                {
                    string errorMessage = "This areatrigger already has its ";

                    if (aiName != "SmartTrigger")
                        errorMessage += "ScriptName set to '" + aiName + "'";
                    else
                        errorMessage += "AIName set (for SmartAI)! Do you want to load it instead?";

                    DialogResult dialogResult = MessageBox.Show(errorMessage, "Something went wrong", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (dialogResult == DialogResult.Yes)
                        TryToLoadScript();

                    return;
                }
            }
            else
            {
                if (aiName != String.Empty)
                {
                    string strAlreadyHasAiName = "This " + sourceTypeString + " already has its AIName set to '" + aiName + "'";

                    if (SAI_Editor_Manager.Instance.IsAiNameSmartAi(aiName))
                        strAlreadyHasAiName += "! Do you want to load it instead?";
                    else
                        strAlreadyHasAiName += " and can therefore not have any SmartAI. Do you want to get rid of this AIName right now?";

                    DialogResult dialogResult = MessageBox.Show(strAlreadyHasAiName, "Something went wrong", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (dialogResult == DialogResult.Yes)
                    {
                        if (SAI_Editor_Manager.Instance.IsAiNameSmartAi(aiName))
                            TryToLoadScript();
                        else
                            //! We don't have to target areatrigger_scripts here, as we've already done this a few lines up
                            new SqlOutputForm("UPDATE `" + GetTemplateTableBySourceType((SourceTypes)source_type) + "` SET `AIName`=" + '"' + '"' + " WHERE `entry`=" + entryorguid + ";\n").ShowDialog(this);
                    }

                    return;
                }

                string scriptName = await SAI_Editor_Manager.Instance.worldDatabase.GetObjectScriptName(entryorguid, source_type);

                if (scriptName != String.Empty)
                {
                    MessageBox.Show("This " + sourceTypeString + " already has a ScriptName set (to '" + scriptName + "')!", "Something went wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            List<SmartScript> smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(entryorguid, source_type);

            if (smartScripts != null && smartScripts.Count > 0)
            {
                string errorMessage = "This " + sourceTypeString + " already has smart scripts";// (without its AIName set to SmartAI)! Do you want to load it instead?";

                if ((SourceTypes)source_type != SourceTypes.SourceTypeScriptedActionlist)
                    errorMessage += " (without its AIName set to SmartAI)!";
                else
                    errorMessage += "!";

                errorMessage += " Do you want to load it instead?";
                DialogResult dialogResult = MessageBox.Show(errorMessage, "Something went wrong", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dialogResult == DialogResult.Yes)
                    TryToLoadScript();

                return;
            }

            buttonNewLine.Enabled = false;
            checkBoxListActionlistsOrEntries.Text = GetSourceTypeByIndex() == SourceTypes.SourceTypeScriptedActionlist ? "List entries too" : "List actionlists too";
            SetPictureBoxEnabled(pictureBoxLoadScript, Resources.icon_load_script, false);
            SetPictureBoxEnabled(pictureBoxCreateScript, Resources.icon_create_script, false);

            originalEntryOrGuidAndSourceType.entryOrGuid = entryorguid;
            originalEntryOrGuidAndSourceType.sourceType = (SourceTypes)source_type;

            listViewSmartScripts.ReplaceSmartScripts(new List<SmartScript>());

            SmartScript newSmartScript = new SmartScript();
            newSmartScript.entryorguid = entryorguid;
            newSmartScript.source_type = source_type;

            if (checkBoxLockEventId.Checked)
                newSmartScript.id = 0;
            else
                newSmartScript.id = -1;

            newSmartScript.link = XConverter.ToInt32(textBoxLinkTo.Text);
            newSmartScript.event_type = XConverter.ToInt32(textBoxEventType.Text);
            newSmartScript.event_phase_mask = XConverter.ToInt32(textBoxEventPhasemask.Text);
            newSmartScript.event_chance = XConverter.ToInt32(textBoxEventChance.Value);
            newSmartScript.event_flags = XConverter.ToInt32(textBoxEventFlags.Text);
            newSmartScript.event_param1 = XConverter.ToInt32(textBoxEventParam1.Text);
            newSmartScript.event_param2 = XConverter.ToInt32(textBoxEventParam2.Text);
            newSmartScript.event_param3 = XConverter.ToInt32(textBoxEventParam3.Text);
            newSmartScript.event_param4 = XConverter.ToInt32(textBoxEventParam4.Text);
            newSmartScript.action_type = XConverter.ToInt32(textBoxActionType.Text);
            newSmartScript.action_param1 = XConverter.ToInt32(textBoxActionParam1.Text);
            newSmartScript.action_param2 = XConverter.ToInt32(textBoxActionParam2.Text);
            newSmartScript.action_param3 = XConverter.ToInt32(textBoxActionParam3.Text);
            newSmartScript.action_param4 = XConverter.ToInt32(textBoxActionParam4.Text);
            newSmartScript.action_param5 = XConverter.ToInt32(textBoxActionParam5.Text);
            newSmartScript.action_param6 = XConverter.ToInt32(textBoxActionParam6.Text);
            newSmartScript.target_type = XConverter.ToInt32(textBoxTargetType.Text);
            newSmartScript.target_param1 = XConverter.ToInt32(textBoxTargetParam1.Text);
            newSmartScript.target_param2 = XConverter.ToInt32(textBoxTargetParam2.Text);
            newSmartScript.target_param3 = XConverter.ToInt32(textBoxTargetParam3.Text);
            newSmartScript.target_x = XConverter.ToInt32(textBoxTargetX.Text);
            newSmartScript.target_y = XConverter.ToInt32(textBoxTargetY.Text);
            newSmartScript.target_z = XConverter.ToInt32(textBoxTargetZ.Text);
            newSmartScript.target_o = XConverter.ToInt32(textBoxTargetO.Text);

            if (Settings.Default.GenerateComments)
                newSmartScript.comment = await CommentGenerator.Instance.GenerateCommentFor(newSmartScript, originalEntryOrGuidAndSourceType);
            else
                newSmartScript.comment = textBoxComments.Text;

            listViewSmartScripts.AddSmartScript(newSmartScript);

            HandleShowBasicInfo();

            listViewSmartScripts.Items[0].Selected = true;
            listViewSmartScripts.Select();

            buttonNewLine.Enabled = true;
            buttonGenerateComments.Enabled = true;
            SetPictureBoxEnabled(pictureBoxLoadScript, Resources.icon_load_script, true);
            SetPictureBoxEnabled(pictureBoxCreateScript, Resources.icon_create_script, true);
        }
Example #13
0
        public void ReplaceSmartScript(SmartScript script)
        {
            ListViewItem lvi = Items[script.entryorguid.ToString()];

            if (lvi == null)
                return;

            lvi.SubItems.Clear();

            lvi.Name = script.entryorguid.ToString();
            lvi.Text = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {

                if (_excludedProperties.Contains(propInfo.Name))
                    continue;

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());

            }

            _smartScripts[_smartScripts.IndexOf(_smartScripts.Single(p => p.entryorguid == script.entryorguid))] = script;
        }
        public void ReplaceSmartScript(SmartScript script)
        {
            ListViewItem lvi = null;

            foreach (ListViewItem item in Items)
            {
                if (item.SubItems[0].Text == script.entryorguid.ToString() && item.SubItems[2].Text == script.id.ToString())
                {
                    lvi = item;
                    break;
                }
            }

            if (lvi == null)
                return;

            lvi.SubItems.Clear();
            lvi.Name = script.entryorguid.ToString();
            lvi.Text = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {
                if (_excludedProperties.Contains(propInfo.Name))
                    continue;

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            }

            _smartScripts[_smartScripts.IndexOf(GetSmartScript(script.entryorguid, script.id))] = script;
            HandleHighlightItems();
        }
        public void RemoveSmartScript(SmartScript script)
        {
            foreach (ListViewItem item in Items)
            {
                if (item.Text == script.entryorguid.ToString() && item.SubItems[2].Text == script.id.ToString())
                {
                    Items.Remove(item);
                    break;
                }
            }

            foreach (SmartScript smartScript in _smartScripts)
            {
                if (smartScript.entryorguid == script.entryorguid && smartScript.id == script.id)
                {
                    _smartScripts.Remove(smartScript);
                    break;
                }
            }
        }