cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
180 stars 47 forks source link

Script engine improvements #409

Closed xfurry closed 9 years ago

xfurry commented 10 years ago

Hi,

During the last couple of weeks I received a few requests for improvements on the script engine.

I will post all the requested patches here, so everyone can share the feedback and input before I commit them to master.

1 Script Command Modify Unit Flags This was requested by @grz3s and allows changing the unit flag of a creature from DB scripts.

diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index c346610..21bd7aa 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -289,3 +289,7 @@ Where "A  ->  B" means that the command is executed from A with B as target.
 34 SCRIPT_COMMAND_TERMINATE_COND            * datalong = condition_id, datalong2 = fail-quest (if provided this quest will be failed for a player)
                                             * !(data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL): terminate when condition is true
                                                 data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL:  terminate when condition is false
+
+35 SCRIPT_COMMAND_MODIFY_UNIT_FLAGS         resultingSource = Creature
+                                            * datalong=Unit_Flags
+                                            * datalong2= 0x00=toggle, 0x01=add, 0x02=remove
diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp
index 049cd72..9732bc8 100644
--- a/src/game/ScriptMgr.cpp
+++ b/src/game/ScriptMgr.cpp
@@ -678,6 +678,8 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
                 }
                 break;
             }
+            case SCRIPT_COMMAND_MODIFY_UNIT_FLAGS:          // 35
+                break;
             default:
             {
                 sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
@@ -1796,6 +1798,28 @@ bool ScriptAction::HandleScriptStep()
             }
             return terminateResult;
         }
+        case SCRIPT_COMMAND_MODIFY_UNIT_FLAGS:               // 35
+        {
+            if (LogIfNotCreature(pSource))
+                break;
+
+            // Add Flags
+            if (m_script->unitFlag.change_flag & 0x01)
+                pSource->SetFlag(UNIT_FIELD_FLAGS, m_script->unitFlag.flag);
+            // Remove Flags
+            else if (m_script->unitFlag.change_flag & 0x02)
+                pSource->RemoveFlag(UNIT_FIELD_FLAGS, m_script->unitFlag.flag);
+            // Toggle Flags
+            else
+            {
+                if (pSource->HasFlag(UNIT_FIELD_FLAGS, m_script->unitFlag.flag))
+                    pSource->RemoveFlag(UNIT_FIELD_FLAGS, m_script->unitFlag.flag);
+                else
+                    pSource->SetFlag(UNIT_FIELD_FLAGS, m_script->unitFlag.flag);
+            }
+
+            break;
+        }
         default:
             sLog.outErrorDb(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command);
             break;
diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h
index ffae118..e9f9a04 100644
--- a/src/game/ScriptMgr.h
+++ b/src/game/ScriptMgr.h
@@ -100,6 +100,9 @@ enum ScriptCommand                                          // resSource, resTar
     SCRIPT_COMMAND_XP_USER                  = 33,           // source or target with Player, datalong = bool (0=off, 1=on)
     SCRIPT_COMMAND_TERMINATE_COND           = 34,           // datalong = condition_id, datalong2 = if != 0 then quest_id of quest that will be failed for player's group if the script is terminated
                                                             // data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL terminate when condition is false ELSE terminate when condition is true
+    SCRIPT_COMMAND_MODIFY_UNIT_FLAGS        = 35,           // resSource = Creature
+                                                            // datalong = Unit_Flags
+                                                            // datalong2:0x00 = toggle, 0x01 = add, 0x02 = remove
 };

 #define MAX_TEXT_ID 4                                       // used for SCRIPT_COMMAND_TALK
@@ -323,6 +326,12 @@ struct ScriptInfo
             uint32 failQuest;                               // datalong2
         } terminateCond;

+        struct                                              // case SCRIPT_COMMAND_MODIFY_UNIT_FLAGS (35)
+        {
+            uint32 flag;                                    // datalong
+            uint32 change_flag;                             // datalong2
+        } unitFlag;
+
         struct
         {
             uint32 data[2];

2 Allow DBscripts_on_spell to run for missing triggered missile spells. Also requested by @grz3s. The only problem with this one is that the error still appears even if the dbscript runs fine.

diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 41f1745..be95192 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -3997,7 +3997,16 @@ void Spell::EffectTriggerMissileSpell(SpellEffectIndex effect_idx)

     if (!spellInfo)
     {
-        sLog.outError("EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u",
+        // No previous Effect might have started a script
+        bool startDBScript = ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, effect_idx);
+        if (startDBScript)
+        {
+            DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectTriggerMissileSpell", m_spellInfo->Id);
+            startDBScript = m_caster->GetMap()->ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget);
+        }
+
+        if (!startDBScript)
+            sLog.outError("EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u",
                       m_spellInfo->Id, effect_idx, triggered_spell_id);
         return;
     }

3 Add condition Creature_in_range. This was requested by @Schmoozerd in this thread: https://github.com/scriptdev2/scriptdev2/issues/93

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 74576a0..87f19f6 100755
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -45,6 +45,10 @@
 #include "GossipDef.h"
 #include "Mail.h"
 #include "InstanceData.h"
+#include "Cell.h"
+#include "CellImpl.h"
+#include "GridNotifiers.h"
+#include "GridNotifiersImpl.h"

 #include <limits>

@@ -7997,6 +8001,16 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co
                 case 3:                                     // Creature source is dead
                     return !source || source->GetTypeId() != TYPEID_UNIT || !((Unit*)source)->isAlive();
             }
+        case CONDITION_CREATURE_IN_RANGE:
+        {
+            Creature* creature = NULL;
+
+            MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*player, m_value1, true, false, m_value2, true);
+            MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(creature, creature_check);
+            Cell::VisitGridObjects(player, searcher, m_value2);
+
+            return creature;
+        }
         default:
             return false;
     }
@@ -8452,6 +8466,19 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu
             }
             break;
         }
+        case CONDITION_CREATURE_IN_RANGE:
+        {
+            if (!sCreatureStorage.LookupEntry<CreatureInfo> (value1))
+            {
+                sLog.outErrorDb("Creature in range condition (entry %u, type %u) has an invalid value in value1. (Creature %u does not exist in the database), skipping.", entry, condition, value1);
+                return false;
+            }
+            if (value2 <= 0)
+            {
+                sLog.outErrorDb("Creature in range condition (entry %u, type %u) has an invalid value in value2. (Range %u must be greater than 0), skipping.", entry, condition, value2);
+                return false;
+            }
+        }
         case CONDITION_NONE:
             break;
         default:
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
index 34b745f..f5665da 100755
--- a/src/game/ObjectMgr.h
+++ b/src/game/ObjectMgr.h
@@ -403,6 +403,7 @@ enum ConditionType
     CONDITION_GENDER                = 35,                   // 0=male, 1=female, 2=none (see enum Gender)
     CONDITION_DEAD_OR_AWAY          = 36,                   // value1: 0=player dead, 1=player is dead (with group dead), 2=player in instance are dead, 3=creature is dead
                                                             // value2: if != 0 only consider players in range of this value
+    CONDITION_CREATURE_IN_RANGE     = 37,                   // value1: creature entry; value2: range; returns only alive creatures
 };

 enum ConditionSource                                        // From where was the condition called?

4 The last feature allows AI event sending to all units, not only to those which are able to assist. This will make interaction between not friendly units, or not selectable units more easy. Feature requested by @ulduar

diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index a584092..8087c80 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -218,9 +218,18 @@ void CreatureAI::SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32
         std::list<Creature*> receiverList;

         // Use this check here to collect only assitable creatures in case of CALL_ASSISTANCE, else be less strict
-        MaNGOS::AnyAssistCreatureInRangeCheck u_check(m_creature, eventType == AI_EVENT_CALL_ASSISTANCE ? pInvoker : NULL, fRadius);
-        MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck> searcher(receiverList, u_check);
-        Cell::VisitGridObjects(m_creature, searcher, fRadius);
+        if (eventType == AI_EVENT_CALL_ASSISTANCE)
+        {
+            MaNGOS::AnyAssistCreatureInRangeCheck u_check(m_creature, pInvoker, fRadius);
+            MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck> searcher(receiverList, u_check);
+            Cell::VisitGridObjects(m_creature, searcher, fRadius);
+        }
+        else
+        {
+            MaNGOS::AnyUnitInObjectRangeCheck u_check(m_creature, fRadius);
+            MaNGOS::CreatureListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(receiverList, u_check);
+            Cell::VisitGridObjects(m_creature, searcher, fRadius);
+        }

         if (!receiverList.empty())
         {

As I said in the beginning, please share your feedback on these improvements.

ghost commented 10 years ago

Very timely! Thanks!

Schmoozerd commented 10 years ago

About 1: (Toggle UnitFlags) This has the issue that it is unclear when/if/how these will be reset. In any case i think you must ensure that they will be reset on respawn. This is why i originally went for the way to toggle the unit-flag changes to faction changes https://github.com/cmangos/mangos-wotlk/blob/master/doc/script_commands.txt#L245 which appeared to be a reasonable choice.

About 4: (Throw events to all npcs) I am not really sure if this is a good idea - adding this will require other places to also check for friendlyness in case of REQUEST_HEAL and similar events. Probably all but the custom events (that should be safeguarded in some ways anyhow) should only be sent to friendlies.

ghost commented 10 years ago

About 4: (Throw events to all npcs) Schmoozerd here I disagree with you. these send AI event needed to minimize hacks and sсripts. Flags greatly hinder send desired EVENT creatures. if you leave things as they are very complicate scripts. Forum сmangos I wrote what was happening. I am unable to go there, but I will give a link. my Internet provider has made this site in the list of banned, why the heck did he do it though. http://cmangos.net/thread-590.html implement all in SD2 - excuse me, I'm like besides the basic artificial intelligence can not write, but in the database easier to fix.

xfurry commented 10 years ago

Partially implemented in 12659 and 12660. I decided that the first 2 points are scrapped, since they are not really required.

xfurry commented 10 years ago

Another discussed script improvement is the areatrigger dbscripts support (poke @cala and @Tobschinski about this).

Here is my proposal (untested), but this is still an open discussion:

diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index c346610..3ccd2de 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -8,6 +8,7 @@ This file is part of the CMaNGOS Project. See AUTHORS file for Copyright informa
 ## id
 -- --------------------------

+dbscripts_on_areatrigger            Areatrigger entry
 dbscripts_on_creature_death         Creature entry
 dbscripts_on_creature_movement      DB project self defined id
 dbscripts_on_event                  Event id. Several sources: spell effect 61, taxi/transport nodes, gameobject_template data
@@ -84,6 +85,9 @@ Map coordinates for commands that need it.
 ## origin of script and source/target in scripts
 -- --------------------------

+dbscripts_on_areatrigger
+                            Areatrigger used
+                                Source: player. Target: player
 dbscripts_on_creature_death
                             Creature death
                                 Source: creature. Target: Unit (player/creature)
diff --git a/sql/mangos.sql b/sql/mangos.sql
index 689fe66..4bb27f7 100644
--- a/sql/mangos.sql
+++ b/sql/mangos.sql
@@ -1515,7 +1515,7 @@ UNLOCK TABLES;
 --
 -- Table structure of `dbscripts_on_event`, `dbscripts_on_go_use`, `dbscripts_on_go_template_use`,
 --                    `dbscripts_on_gossip`, `dbscripts_on_quest_end`, `dbscripts_on_quest_start`,
---                    `dbscripts_on_spell`, `dbscripts_on_creature_death`
+--                    `dbscripts_on_spell`, `dbscripts_on_creature_death`, `dbscripts_on_areatrigger`
 DROP TABLE IF EXISTS dbscripts_on_event;
 CREATE TABLE dbscripts_on_event LIKE dbscripts_on_creature_movement;
 DROP TABLE IF EXISTS dbscripts_on_go_use;
@@ -1532,6 +1532,8 @@ DROP TABLE IF EXISTS dbscripts_on_spell;
 CREATE TABLE dbscripts_on_spell LIKE dbscripts_on_creature_movement;
 DROP TABLE IF EXISTS dbscripts_on_creature_death;
 CREATE TABLE dbscripts_on_creature_death LIKE dbscripts_on_creature_movement;
+DROP TABLE IF EXISTS dbscripts_on_areatrigger;
+CREATE TABLE dbscripts_on_areatrigger LIKE dbscripts_on_creature_movement;

 --
 -- Table structure for table `disenchant_loot_template`
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index ae1f800..5559b88 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -42,6 +42,7 @@
 #include "Pet.h"
 #include "SocialMgr.h"
 #include "DBCEnums.h"
+#include "ScriptMgr.h"

 void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data)
 {
@@ -743,6 +744,9 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
             return;
     }

+    // Start Areatrigger script
+    player->GetMap()->ScriptsStart(sAreaTriggerScripts, Trigger_ID, player, player);
+
     // NULL if all values default (non teleport trigger)
     AreaTrigger const* at = sObjectMgr.GetAreaTrigger(Trigger_ID);
     if (!at)
diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp
index 049cd72..ba8bfcc 100644
--- a/src/game/ScriptMgr.cpp
+++ b/src/game/ScriptMgr.cpp
@@ -43,6 +43,7 @@ ScriptMapMapName sEventScripts;
 ScriptMapMapName sGossipScripts;
 ScriptMapMapName sCreatureDeathScripts;
 ScriptMapMapName sCreatureMovementScripts;
+ScriptMapMapName sAreaTriggerScripts;

 INSTANTIATE_SINGLETON_1(ScriptMgr);

@@ -823,6 +824,18 @@ void ScriptMgr::LoadCreatureDeathScripts()
     }
 }

+void ScriptMgr::LoadAreaTriggerDBScripts()
+{
+    LoadScripts(sAreaTriggerScripts, "dbscripts_on_areatrigger");
+
+    // check ids
+    for (ScriptMapMap::const_iterator itr = sAreaTriggerScripts.second.begin(); itr != sAreaTriggerScripts.second.end(); ++itr)
+    {
+        if (!sObjectMgr.GetAreaTrigger(itr->first))
+            sLog.outErrorDb("Table `dbscripts_on_areatrigger` has not existing areatrigger (Entry: %u) as script id", itr->first);
+    }
+}
+
 void ScriptMgr::LoadDbScriptStrings()
 {
     sObjectMgr.LoadMangosStrings(WorldDatabase, "db_script_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, true);
@@ -842,6 +855,7 @@ void ScriptMgr::LoadDbScriptStrings()
     CheckScriptTexts(sGossipScripts, ids);
     CheckScriptTexts(sCreatureDeathScripts, ids);
     CheckScriptTexts(sCreatureMovementScripts, ids);
+    CheckScriptTexts(sAreaTriggerScripts, ids);

     sWaypointMgr.CheckTextsExistance(ids);

diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h
index ffae118..37efbb4 100644
--- a/src/game/ScriptMgr.h
+++ b/src/game/ScriptMgr.h
@@ -443,6 +443,7 @@ extern ScriptMapMapName sEventScripts;
 extern ScriptMapMapName sGossipScripts;
 extern ScriptMapMapName sCreatureDeathScripts;
 extern ScriptMapMapName sCreatureMovementScripts;
+extern ScriptMapMapName sAreaTriggerScripts;

 enum ScriptLoadResult
 {
@@ -467,6 +468,7 @@ class ScriptMgr
         void LoadGossipScripts();
         void LoadCreatureDeathScripts();
         void LoadCreatureMovementScripts();
+        void LoadAreaTriggerDBScripts();

         void LoadDbScriptStrings();

diff --git a/src/game/World.cpp b/src/game/World.cpp
index 660c776..f9eab60 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -1331,6 +1331,7 @@ void World::SetInitialWorldSettings()
     sScriptMgr.LoadGameObjectTemplateScripts();             // must be after load Creature/Gameobject(Template/Data)
     sScriptMgr.LoadEventScripts();                          // must be after load Creature/Gameobject(Template/Data)
     sScriptMgr.LoadCreatureDeathScripts();                  // must be after load Creature/Gameobject(Template/Data)
+    sScriptMgr.LoadAreaTriggerDBScripts();
     sLog.outString(">>> Scripts loaded");
     sLog.outString();
xfurry commented 10 years ago

Last call for the dbscripts_on_areatrigger: Is there anyone still interesting in this, or can I close and trash this patch?

ghost commented 10 years ago

Of course add. What work disappear, can through them will be easier even script writing. In some cases.

xfurry commented 10 years ago

Of course add. What work disappear, can through them will be easier even script writing. In some cases.

Did you actually test this, or are you just trolling...? :worried: My patch has a few issues, and I can see that nobody is bothered about them.

ghost commented 10 years ago

They are a few quests tied it again - for example the Firelord, which I finally finished, but no one before and do not care. Also in the intro Alizabal Baradin Hold. Example: https://github.com/Dramacydal/murlocs_434/blob/master/src/bindings/ScriptDev2/scripts/eastern_kingdoms/throne_of_the_tides/instance_throne_of_the_tides.cpp#L267 And https://github.com/Dramacydal/murlocs_434/blob/master/src/bindings/ScriptDev2/scripts/eastern_kingdoms/throne_of_the_tides/boss_ozumat.cpp#L629 And https://github.com/TrinityCore/TrinityCore/blob/4.3.4/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp#L63 About - Alizabal has areatrigger,

('5586901','55869','10','0','100','6','0','45','0','0','1','-55','0','0','0','0','0','0','0','0','0','0','Alizabal - Yell Intro'),

Will need to replace it)

xfurry commented 10 years ago

You didn't understand how scripts work...

In order to trigger a dbscript for area trigger I would need to add a condition system that will only start the script if player has a certain quest, or if the script isn't already completed inside the given instance. This isn't possible currently, especially the second part, so areatrigger scripts won't be available in instances anyway.

From my point of view I consider this patch incomplete, and in the current situation it won't be pushed to master any time soon.

ghost commented 10 years ago

CONDITION_COMPLETED_ENCOUNTER (Handling is in spell.cpp and unit.cpp) It would be nice to have on the server side to create their encounters to override data from dbc. Or create your instance date in the database without touching SD2. In any case, you are asked to answer, I said what I think. In the Light of Dawn quest I've seen such a function as SetData and GetData(no InstanceData) In Trinity has long been a feature packed into SAI, Mangos unfortunately it has not.

xfurry commented 10 years ago

CONDITION_COMPLETED_ENCOUNTER (Handling is in spell.cpp and unit.cpp) It would be nice to have on the server side to create their encounters to override data from dbc.

I'm not saying it's not possible. But the current patch doesn't support that. It would be possible to add a 2nd table to handle area trigger script start based on condition. Why not try to write this yourself, and I will review your patch? :wink:

ghost commented 10 years ago

I already offered a few patches on the forum are and what is the result? Disclaimer. Give an example of why it is needed and then maybe add examples also provided, but it did not help.

xfurry commented 10 years ago

I already offered a few patches on the forum are and what is the result?

I appreciate that you submitted patches on the forum, but those patches are for DB, mostly for Cata-DB. I do not develop DB for cata, so I think that YTDB should be more interested in those patches. Poke @Neatelves about them.

Give an example of why it is needed and then maybe add examples also provided, but it did not help.

There are many examples. In case of an intro yell done by area trigger, this needs to be done only once in that instance. How will you handle that with DB conditions, if it's not related to any encounter? How will you translate this script - https://github.com/scriptdev2/scriptdev2/blob/master/scripts/eastern_kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp#L466 or this script - https://github.com/scriptdev2/scriptdev2/blob/master/scripts/northrend/icecrown_citadel/icecrown_citadel/instance_icecrown_citadel.cpp#L87 into an dbscript for at?

You can't do that currently, and since you can't do that we either need to develop a way for this to happen or drop the whole concept of dbscripts_on_at.

ghost commented 10 years ago

And so why limit the base functionality? Why so serious to rely on SD2? I understand there is a script instance - but it is not done in the database) without serious hacking. I barely made ​​sure that it was possible to send AI ​event without restrictions,Thank you and it. You say that Ragnaros(Firelands) should be implemented in SD2. At the same time, as you say, I realized that none of you are not interested in Cataclysm. That, in principle, significantly. It remains to hack, and then by offu not be done. About areatrigger - on Cataclysm The big problem in the opcode, and so they work on the principle - I want to work, I want to disabled. So I find it hard to answer your question. You can create a trigger of a custom NPC - will be an excellent replacement areatrigger. Thanks for you work.

cala commented 9 years ago

@Xfurry : I tested yesterday your patch for dbscripts_on_areatrigger support (really sorry for the delay). I tested it with a DBscripts version of what was discussed here: http://cmangos.net/thread-6754.html

It worked nicely. The current DBscripts commands may need some adjustements for this specific script like SCRIPT_COMMAND_TERMINATE_SCRIPT currently not supporting "creature is dead but not despawned". Script is pasted below. If you need me to test it further on some specific conditions or whatever, just let me tell. :smile:

-- Added areatrigger script for spawning 3 Hive'Ashi Drones
-- when entering tower in Southwind Village in Silithus
-- Thanks Xfurry for his core patch
DELETE FROM `dbscripts_on_areatrigger` WHERE `id` = 3146;
INSERT INTO `dbscripts_on_areatrigger` VALUES
(3146, 0, 31, 13136, 35, 0, 0, 0 | 0x08, 0, 0, 0, 0, 0, 0, 0, 0, ''),
(3146, 1, 10, 13136, 180000, 0, 0, 0, 0, 0, 0, 0, -7185.94, 443.29, 26.59, 4.8458, 'Hive\'Ashi Drones spawn 1'),
(3146, 1, 10, 13136, 180000, 0, 0, 0, 0, 0, 0, 0, -7180.59, 441.33, 26.68, 4.1798, 'Hive\'Ashi Drones spawn 2'),
(3146, 1, 10, 13136, 180000, 0, 0, 0, 0, 0, 0, 0, -7176.63, 437.42, 26.84, 3.9348, 'Hive\'Ashi Drones spawn 3');
xfurry commented 9 years ago

@cala thanks for feedback!

One issue that I faced on the design of the dbscripts_on_at is how to ensure the unique script runtime.

I'm thinking that we need to add SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE as a parameter. But we might also need some exec_param_unique_by_instanced_map in order to trigger intro dialogues only once per instance. However this needs to be stored in the DB instance data somehow. Poke @Schmoozerd for this, since he's the father of the current dbscripts system. :wink:

ghost commented 9 years ago

Respected @Xfurry, I hope you will not mind if I'm here, too, is placed. Note: I'm still a novice! Please strictly do not kick.

commit 0d707819f10eda4aa191439b74841b66e7f1cea2
Author: FollowerAI <FollowerAI@cataclysm.com>
Date:   Fri Jun 12 15:40:12 2015 +0600

diff --git a/commit-8250561 b/commit-8250561
new file mode 100644
index 0000000..4b6ff35
--- /dev/null
+++ b/commit-8250561
@@ -0,0 +1,136 @@
+commit 8250561ac71127fd12bf54eb1e751cbaa5f775f0
+Author: FollowerAI <FollowerAI@cataclysm.com>
+Date:   Fri Jun 12 15:32:57 2015 +0600
+
+       Script command for request various issue (Also can used in Cataclysm quests) and expands Send AI Event List for EAI and db_script system (also for require).
+
+diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp
+index 622516d..815b369 100644
+--- a/src/game/ScriptMgr.cpp
++++ b/src/game/ScriptMgr.cpp
+@@ -733,6 +733,14 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
+                 }
+                 break;
+             }
+             case SCRIPT_COMMAND_RESPAWN_SELF:               // 39
+                 break;
+             case SCRIPT_COMMAND_FOLLOW:                     // 40
+                 break;
+             case SCRIPT_COMMAND_SET_FLY:                    // 41
+                 break;
+             case SCRIPT_COMMAND_SEND_AI_EVENT_TARGET:       // 42
+                 break;
+             default:
+             {
+                 sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
+@@ -1959,6 +1967,58 @@ bool ScriptAction::HandleScriptStep()
+             MailDraft(m_script->sendMail.mailTemplateId).SendMailTo(static_cast<Player*>(pTarget), sender, MAIL_CHECK_MASK_HAS_BODY, deliverDelay);
+             break;
+         }
+         case SCRIPT_COMMAND_RESPAWN_SELF:                   // 39
+         {
+             // TODO - Remove this check after a while
+             if (pTarget && pTarget->GetTypeId() != TYPEID_UNIT && pSource && pSource->GetTypeId() == TYPEID_UNIT)
+             {
+                 sLog.outErrorDb("DB-SCRIPTS: Process table `%s` id %u, command %u target must be creature, but (only) source is, use data_flags to fix", m_table, m_script->id, m_script->command);
+                 pTarget = pSource;
+             }
+ 
+             if (LogIfNotCreature(pTarget))
+                 break;
+ 
+             ((Creature*)pTarget)->Respawn(m_script->respawn.respawn);
+ 
+             break;
+         }
+         case SCRIPT_COMMAND_FOLLOW:                       // 40
+         {
+             if (LogIfNotCreature(pSource))
+                 break;
+             if (LogIfNotUnit(pTarget))
+                 break;
+ 
+             Creature* pFollower = static_cast<Creature*>(pSource);
+             Unit* unitTarget = static_cast<Unit*>(pTarget);
+ 
+             pFollower->GetMotionMaster()->MoveFollow(unitTarget, Distance, Angle);
+ 
+             break;
+         }
+         case SCRIPT_COMMAND_FLY:                         // 41
+         {
+             if (LogIfNotCreature(pSource))
+                 return false;
+             if (m_script->setFly.setFly)
+                 ((Creature*)pSource)->SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM);
+                 ((Creature*)pSource)->SetLevitate(true);
+             else
+                 ((Creature*)pSource)->RemoveByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM);
+                 ((Creature*)pSource)->SetLevitate(false);
+             break;
+         }
+         case SCRIPT_COMMAND_SEND_AI_EVENT_TARGET:           // 42
+         {
+             if (LogIfNotCreature(pSource))
+                 return false;
+             if (LogIfNotUnit(pTarget))
+                 break;
+ 
+             ((Creature*)pSource)->AI()->SendAIEvent(AIEventType(m_script->sendAIEvent.eventType), pActionInvoker,(Unit*)pTarget, miscValue);
+             break;
+         }
+         default:
+             sLog.outErrorDb(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command);
+             break;
+diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h
+index 9b5069c..ea66d1c 100644
+--- a/src/game/ScriptMgr.h
++++ b/src/game/ScriptMgr.h
+@@ -117,6 +117,16 @@ enum ScriptCommand                                          // resSource, resTar
+                                                             // datalong: Send mailTemplateId from resSource (if provided) to player resTarget
+                                                             // datalong2: AlternativeSenderEntry. Use as sender-Entry
+                                                             // dataint1: Delay (>= 0) in Seconds
+     SCRIPT_COMMAND_RESPAWN_SELF             = 39,           // resSource = WorldObject, resTarget = Creature.
+     SCRIPT_COMMAND_FOLLOW                   = 40,           // resSource = Creature, resTarget Player/Creature.
+                                                             // datalong= 0: distance follow 1: angle follow.
+     SCRIPT_COMMAND_FLY                      = 41,           // resSource = Creature.
+                                                             // datalong = 0: remove levitate 1: set levitate.
+     SCRIPT_COMMAND_SEND_AI_EVENT_TARGET     = 42,           // resSource = Creature, resTarget = Unit. Also allow Send AI Event Creature Guid Target (Likely BUDDY_BY_GUID flag). Not only MAXIMAL_AI_EVENT_EVENTAI.
+                                                             // datalong = AIEventType
+                                                             // datalong2 = empty.
+     // SCRIPT_COMMAND_START_FOLLOW          = 43,           // resSource = Creature, resTarget = Player.
+                                                             // datalong = 0: set faction for escort 1: QuestId. Start Follow for Player on example quest_start_scripts.
+ };
+ 
+ #define MAX_TEXT_ID 4                                       // used for SCRIPT_COMMAND_TALK, SCRIPT_COMMAND_EMOTE, SCRIPT_COMMAND_CAST_SPELL, SCRIPT_COMMAND_TERMINATE_SCRIPT
+@@ -363,6 +373,30 @@ struct ScriptInfo
+             uint32 mailTemplateId;                          // datalong
+             uint32 altSender;                               // datalong2;
+         } sendMail;
+         
+         struct                                              // SCRIPT_COMMAND_RESPAWN_SELF (39)
+         {
+             uint32 empty;                                   // datalong
+             uint32 empty;                                   // datalong2
+         } respawn;
+         
+         struct                                              // SCRIPT_COMMAND_FOLLOW (40)
+         {
+             uint32 Distance;                                // datalong
+             uint32 Angle;                                   // datalong2
+         } moveFollow;
+         
+         struct                                              // SCRIPT_COMMAND_FLY (41)
+         {
+             uint32 setFly;                                  // datalong
+             uint32 empty;                                   // datalong2
+         } setFly;
+         
+         struct                                              // SCRIPT_COMMAND_SEND_AI_EVENT_TARGET (42)
+         {
+             uint32 eventType;                               // datalong
+             uint32 empty;                                   // datalong2
+         } sendAIEvent;
+ 
+         struct
+         {
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 2731113..e5b8a4d 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -219,7 +219,7 @@ void CreatureAI::SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32
         std::list<Creature*> receiverList;

         // Allow sending custom AI events to all units in range
-        if (eventType == AI_EVENT_CUSTOM_EVENTAI_A || eventType == AI_EVENT_CUSTOM_EVENTAI_B)
+        if (eventType == AI_EVENT_CUSTOM_EVENTAI_A || eventType == AI_EVENT_CUSTOM_EVENTAI_B || eventType == AI_EVENT_CUSTOM_EVENTAI_C || eventType == AI_EVENT_CUSTOM_EVENTAI_D || eventType == AI_EVENT_CUSTOM_EVENTAI_E || eventType == AI_EVENT_CUSTOM_EVENTAI_F || eventType == AI_EVENT_CUSTOM_EVENTAI_G || eventType == AI_EVENT_CUSTOM_EVENTAI_H || eventType == AI_EVENT_CUSTOM_EVENTAI_I || eventType == AI_EVENT_CUSTOM_EVENTAI_K || eventType == AI_EVENT_CUSTOM_EVENTAI_L || eventType == AI_EVENT_CUSTOM_EVENTAI_M)
         {
             MaNGOS::AnyUnitInObjectRangeCheck u_check(m_creature, fRadius);
             MaNGOS::CreatureListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(receiverList, u_check);
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index 9bbb2df..9f25375 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -70,10 +70,20 @@ enum AIEventType
     AI_EVENT_CUSTOM_EVENTAI_A   = 5,                        // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
     AI_EVENT_CUSTOM_EVENTAI_B   = 6,                        // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
     AI_EVENT_GOT_CCED           = 7,                        // Sender = CCed Npc, Invoker = Caster that CCed
-    MAXIMAL_AI_EVENT_EVENTAI    = 8,
+    AI_EVENT_CUSTOM_EVENTAI_C   = 8,                        // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_D   = 9,                        // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_E   = 10,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_F   = 11,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_G   = 12,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_H   = 13,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_I   = 14,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_K   = 15,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_L   = 16,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    AI_EVENT_CUSTOM_EVENTAI_M   = 17,                       // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
+    MAXIMAL_AI_EVENT_EVENTAI    = 18,

     // Internal Use
-    AI_EVENT_CALL_ASSISTANCE    = 10,                       // Sender = Attacked Npc, Invoker = Enemy
+    AI_EVENT_CALL_ASSISTANCE    = 19,                       // Sender = Attacked Npc, Invoker = Enemy

     // Predefined for SD2
     AI_EVENT_START_ESCORT       = 100,                      // Invoker = Escorting Player

1) SCRIPT_COMMAND_RESPAWN_SELF - Allow creature respawn. 2) SCRIPT_COMMAND_FOLLOW - Allow creature follow players and creatures. 3) SCRIPT_COMMAND_SET_FLY - Allow creature flying. Cataclysm quests http://www.wowhead.com/quest=28758 http://www.wowhead.com/quest=28712/enter-the-dragon-queen Alexstrasza the Life-Binder should set levitate and remove levitate. Deathwing and Calen also. 4) SCRIPT_COMMAND_SEND_AI_EVENT_TARGET - Send AI Event Target creature buddy entry and creature buddy guid. 5) Expands Send AI Event list - SD2 can also using EventAI events.

Rushor commented 9 years ago

FollowerAI: you are Ulduar no?

ghost commented 9 years ago

No, I am a person, not the instance.

xfurry commented 9 years ago

No, I am a person, not the instance.

I think he was asking you if you are the same person as the user Ulduar, which just deleted his profile a few weeks ago. :smile:

But I think this already answers the question

ghost commented 9 years ago

So, I see me alone you have left no. https://github.com/cmangos/mangos-wotlk/pull/153 rejected my pull. https://github.com/cmangos/mangos-wotlk/pull/148 Rejected. One mockery. https://github.com/scriptdev2/scriptdev2-cata/pull/27 rejected. https://github.com/scriptdev2/scriptdev2-cata/pull/30 rejected. https://github.com/scriptdev2/scriptdev2-cata/pull/25 rejected https://github.com/scriptdev2/scriptdev2-cata/pull/29 rejected. And so other. One mockery. One biased attitude. What I sense you something to offer?

@FollowerAI - they will not accept your patch. I've tried, believe me - nothing happened.

xfurry commented 9 years ago

SCRIPT_COMMAND_RESPAWN_SELF: -> this is ok. SCRIPT_COMMAND_FOLLOW: -> not ok. Not in this format. It will not work right if creature enters combat / evade. We already discussed this on IRC. SCRIPT_COMMAND_SET_FLY: -> this is ok, but I'd like to make some changes to the current patch. SCRIPT_COMMAND_SEND_AI_EVENT_TARGET: -> this is ok, but I'm not sure if this is really required. the Send_ai_event_around does the same thing, so let's discuss. Add more AI_EVENT_CUSTOM_EVENTAI_X -> ok, but not that many. Let's add just a few more. You don't actually need 10 more.

xfurry commented 9 years ago

@Ulduar I didn't reject anything. Some of the proposals are good but they are not perfect, so I simply didn't have the time to improve them and to push to master.

ghost commented 9 years ago
SCRIPT_COMMAND_RESPAWN_SELF: -> this is ok.

Okay.

SCRIPT_COMMAND_FOLLOW: -> not ok. Not in this format. It will not work right if creature enters combat / evade. We already discussed this on IRC.

With me you never said.

It will not work right if creature enters combat / evade. 

A not required. http://www.wowhead.com/quest=25325/through-the-dream db_script_on_gossip - SCRIPT_COMMAND_SUMMON_CREATURE Fandrall and start command follow (using data_flags 2). Aggro and evade handled not required for this case. Fandrall not assist player.

SCRIPT_COMMAND_SET_FLY: -> this is ok, but I'd like to make some changes to the current patch.

Why should?

SCRIPT_COMMAND_SEND_AI_EVENT_TARGET: -> this is ok, but I'm not sure if this is really required. the Send_ai_event_around does the same thing, so let's discuss.

Send AI Event creature guid target. Using buddy_guid. Send AI Event around and Send AI Event - not one and too. And you perfectly know it.

Add more AI_EVENT_CUSTOM_EVENTAI_X -> ok, but not that many. Let's add just a few more. You don't actually need 10 more.

five will be enough! Here I agree.

push to master.

Reqired only in Cataclysm.

@Ulduar: Please stop - I read your issue. On this basis, I did the patch. Do not turn the topic into the garbage.

ghost commented 9 years ago

It's time for me to contribute.

SCRIPT_COMMAND_RESPAWN_SELF: -> this is ok.

It is high time be added.

SCRIPT_COMMAND_FOLLOW: -> not ok. Not in this format. It will not work right if creature enters combat / evade. We already discussed this on IRC.

In IRC you talking to me, not with FollowerAI. Theme: the command needed. It has long been needed when you realize already what Cata - not Wotlk. I'll give you examples - Dragon Soul - Intro Event before Morchok.

 It will not work right if creature enters combat / evade. 

Aggro / Evade not a hindrance. Add, and I'll show you why.

SCRIPT_COMMAND_SEND_AI_EVENT_TARGET: -> this is ok, but I'm not sure if this is really required. the Send_ai_event_around does the same thing, so let's discuss.

Dragon Soul intro event - db_script_on_creature_death http://www.wowhead.com/npc=57160/ancient-water-lord and http://www.wowhead.com/npc=57158/earthen-destroyer Send AI Event Morchok. Morchok - on Receive AI Event Custom A (pSender == 57160 and pSender = 57158) ++EventCount. If (EventCount ==2). StartNextDialogueText. There yet of motion in the creatures there is. Morchok I write in SD2.

SCRIPT_COMMAND_SET_FLY: -> this is ok, but I'd like to make some changes to the current patch.

What other changes? SetByteValue there is, SetLevitate there is.

Add more AI_EVENT_CUSTOM_EVENTAI_X -> ok, but not that many. Let's add just a few more. You don't actually need 10 more.

When there is a creature guid, but having the same entry. I myself starting to think about adding 33 custom events.

P.S: I do not like to discuss the IRC, We never once reached a common denominator.

Grz3s commented 9 years ago
+     SCRIPT_COMMAND_FLY                      = 41,           // resSource = Creature.
+                                                             // datalong = 0: remove levitate 1: set levitate.
+     SCRIPT_COMMAND_SEND_AI_EVENT_TARGET     = 42,           // resSource = Creature, resTarget = Unit. Also allow Send AI Event Creature Guid Target (Likely BUDDY_BY_GUID flag). Not only MAXIMAL_AI_EVENT_EVENTAI.
+                                                             // datalong = AIEventType
+                                                             // datalong2 = empty.

these 2 ... i would like to see in wotlk ;)

ghost commented 9 years ago

I do not see application in Wotlk, only in Cata.

ghost commented 9 years ago

1)Need function SetNextWaypoint! Details: http://cmangos.net/thread-6885.html

Example 1: Twilight Siege Captain(guid 1) with can help db_script_on_creature_movement Send AI Event Target Custom A for Twilight Portal Guid 1.
Twilight Portal on Receive AI_EVENT_CUSTOM_EVENTAI_A   - Set Phase 1.
Example 2: Twilight Siege Captain(guid 2) with can help db_script_on_creature_movement Send AI Event Target Custom B for Twilight Portal Guid 2.
Twilight Portal on Receive AI_EVENT_CUSTOM_EVENTAI_B - Set Phase 2.
Example 3: Twilight Siege Captain(guid 3) with can help db_script_on_creature_movement Send AI Event Target Custom C for Twilight Portal Guid 3.
Twilight Portal on AI_EVENT_CUSTOM_EVENTAI_C - Set Phase 3.
Example 4: Twilight Siege Captain(guid 4) with can help db_script_on_creature_movement Send AI Event Target Custom D for Twilight Portal Guid 4.
Twilight Portal on AI_EVENT_CUSTOM_EVENTAI_D - Set Phase 4.
Example 5: Twilight Siege Captain(guid 5) with can help db_script_on_creature_movement Send AI Event Target Custom E for Twilight Portal Guid 5.
Twilight Portal on AI_EVENT_CUSTOM_EVENTAI_E - Set Phase 5.
http://ru.wowhead.com/npc=57259
a)Twilight Siege Breaker - on Receive AI_EVENT_CUSTOM_EVENTAI_A  - Set Next Waypoint 1 and Change Movement.
b)Twilight Siege Breaker - on Receive AI_EVENT_CUSTOM_EVENTAI_B  - Set Next Waypoint 2 and Change Movement.
c)Twilight Siege Breaker - on Receive AI_EVENT_CUSTOM_EVENTAI_C  - Set Next Waypoint 3 and Change Movement.
d)Twilight Siege Breaker - on Receive AI_EVENT_CUSTOM_EVENTAI_D  - Set Next Waypoint 4 and Change Movement.
e)Twilight Siege Breaker - on Receive AI_EVENT_CUSTOM_EVENTAI_E  - Set Next Waypoint 5 and Change Movement.
a1) Twilight Portal - Phase 1 - Just Summoned Twilight Siege Breaker - Send AI Event Custom EventAI A (inform about start next waypoints and set current waypoint)
a2) Twilight Portal - Phase 2 - Just Summoned Twilight Siege Breaker - Send AI Event Custom EventAI B (inform about start next waypoints and set current waypoint)
a3) Twilight Portal - Phase 3 - Just Summoned Twilight Siege Breaker - Send AI Event Custom EventAI C (inform about start next waypoints and set current waypoint)
a4) Twilight Portal - Phase 4 - Just Summoned Twilight Siege Breaker - Send AI Event Custom EventAI D (inform about start next waypoints and set current waypoint)
a5) Twilight Portal - Phase 5 - Just Summoned Twilight Siege Breaker - Send AI Event Custom EventAI E (inform about start next waypoints and set current waypoint)

Fine possible do without the SD2. This is not the only example! 2)Need function Override Enter Evade Mode. Details: https://github.com/scriptdev2/scriptdev2/issues/152 Need db_script_on_creature_enter_combat and db_script_on_creature_evade. Not for of one Ultraxion. This will fill the other hole.

This boss goes into SD2!

You know perfectly what it will never happen!

Why not use eventAI for Aggro and Evade? What are the limitations?

You know very well what limitations. P.S: More... more functions... more...

xfurry commented 9 years ago

@Ulduar instead of opening 100 pull requests at once, you should focus only on a few and get it right. Currently all your PRs are wrong. They are either conceptually wrong or have formatting / codestyle issues.

I will push the functions that I already agreed in the previous message. It will happen this week.

ghost commented 9 years ago

I have not enough knowledge. I'm trying on learn your code

xfurry commented 9 years ago

Would knowledge, no problem would have done well. Why is it wrong? Two of them are exactly correct. Travis Build Passed. You say that you do not have time.

I will explain what is the problem, but not today. Very busy now.

ghost commented 9 years ago

You can already and do not explain himself understood. My goal - to convey the necessary information to you. Well, attempt write a patch! This is worth it!

ghost commented 9 years ago
SCRIPT_COMMAND_SEND_AI_EVENT_TARGET: -> this is ok, but I'm not sure if this is really required. the Send_ai_event_around does the same thing, so let's discuss.

I see example for future: Hagara preevent in Dragon Soul - can be done in in combination SD2, EAI and db_scripts. EAI - battle timer for http://www.wowhead.com/npc=57817/stormborn-myrmidon http://www.wowhead.com/npc=57807/twilight-frost-evoker and http://www.wowhead.com/npc=57823/stormbinder-adept db_script - Hagara has waypoint movement depending on the event count. also db_script_on_creature_death for 57817, 57807, 57823. Send AI Event Custom A for Hagara. Hagara - SD2 side - on Receive AI Event Custom A - ++event count. And other. Anraphet summon event in Halls of Origination and other. P.S: YTDB has full sniffed data for Dragon Soul.

ghost commented 9 years ago

News: 1) EVENT_T_HP and EVENT_T_MANA need delete check

if (!m_creature->isInCombat() || !m_creature->GetMaxHealth())
                return false;

https://github.com/cmangos/mangos-cata/blob/master/src/game/CreatureEventAI.cpp#L226 You can see example (please read fully) https://github.com/ACID-Scripts/CATA/blob/master/acid_cata.sql#L1515 On 90 Percent Hp (npc not in combat anyway) Should receive ai event -- Brother Paxton Repeat: Event load out of combat. Not in combat. 2)Need ACTION_T_CALL_SCRIPT_RESET. Because EVENT_T_RECEIVE_AI_EVENT Brother Paxton should be repeatable. On current state It can not be repeated. Add repeatmin and repeatmax - well, I do not know, not whether this will lead. I do not understand the meaning of this check. 3) ACTION_T_ATTACK_START - db_script_on_creature_movement - Are you seriously propose to use this hack? Yes, there is a log spam goes. https://github.com/cmangos/issues/issues/157#issue-12586071 -- spam log issue. https://github.com/cmangos/issues/issues/561

You have SCRIPT_COMMAND_ATTACK so you can use that.
In eventAI that doesn't make too much sense, because you don't always have a 3rd party source that triggers the event. Moreover the attack should start because of faction & unit flags. There are very few cases where you need to enforce the attack.

And here the faction and flags if Worg neutral? Also someone told you that it is not enough where applicable? Also you can see sniff https://github.com/cmangos/issues/issues/263#issue-19949100 Hit fake damage. Thanks @X-Savior and other owner for details.

Grz3s commented 9 years ago
-- 157 (comment) -- spam log issue.

spam wont show up... if you will use command (ofc before attack) 31 SCRIPT_COMMAND_TERMINATE_SCRIPT (that will give u power to search if that creature is there or not) - and this check is used in db many times.. so problem with that spam - doesnt exist.

ghost commented 9 years ago

@Grz3s The problem still remains a. SCRIPT_COMMAND_TERMINATE_SCRIPT - i know. db_script_on_creature_movement - @X-Savior had no choice.

Grz3s commented 9 years ago

that issue was created: Created by @X-Savior on 2013-03-21 07:34:55: (march 2013) and you can see schmoo.. answered there.. I remember... i was ask by x-savior about that issue... and I fixed all db_script_on (event/quest/movement/gossip etc) .. was quite easy ... just to add that check. so problem dissapeared.. quite quick... ofc .. i dont know how it happened with other DBs than UDB, if they fixed that at all. -- can you explain this? -- i dont understan it. he had no choice ..with what?

ghost commented 9 years ago
-- can you explain this? -- i dont understan it.
he had no choice ..with what?

This is simple - EAI don't has ACTION_T_ATTACK_START on current state( Therefore, for the attack, he created db_script_on_creature_movement == workaround. he had no choice( Well, for each such case we can use db_script_on_creature_movement - but you can imagine that this is not a solution. Or variant two - write SD2 for any similar case. SD2 can all!

xfurry commented 9 years ago

Guys... This topic has become too big and it starts to not make sense anymore. I will implement the script commands that I promised above. For the other thins we can open a different ticket.

Grz3s commented 9 years ago

ok let me say final word... I think I understand your logic now. @Ulduar You just would like to have everything done via EAI.. or sd2 scripts... You not accepting db_scripts at all... calling them all (HACKS)...dont know why:

You want smth like smart_AI_scripts for TrinityCore... (ofc Im not sayin that this is something bad...probably is better than our stuff) But serious... can you imagine that all quest end scripts etc ...can be done only by EAI? how you going to do invidual scripts ... for example 20 guards in town - that some of them will have unique conversations with another npcs...or actions they do. DB_scripts are seriously good tool to work with .. you just need to accept them. C'mon man... can you see... than someone will change everything? and who will be redoing all scripts etc? How many ppl ... you see now here, that push stuff to core? how many ppl work on db stuff?? M8 open your eyes ... and be happy what was achieved till this moment... becouse soon ...you may see noone interested anymore....

And dont think me wrong... im happy to see your improvements... i was really happy when you explained to me.. how eventEi "throw event" works...etc..(u can see ... im using it almost all the time)

And you know what i would like to see? EAI action - send db_script..... so i could do stuff like: event=11 spawn + action send _db_script (with all our commands)

Anyway... think about what i said to you,.... and belive me.. db_scripts are not that bad ( you may think) Regards

ghost commented 9 years ago

You do not misunderstand me - I am grateful for your work! Thank you!

You just would like to have everything done via EAI.. or sd2 scripts... You not accepting db_scripts at all... calling them all (HACKS)...dont know why:

db script I use myself.

You want smth like smart_AI_scripts for TrinityCore... (ofc Im not sayin that this is something bad...probably is better than our stuff)

This question has already been. I'm trying to add features from there because they have their own examples to add.

DB_scripts are seriously good tool to work with .. you just need to accept them.

I know, I've used it many times where this was possible. For example you can see https://github.com/scriptdev2/scriptdev2-cata/issues/4

And dont think me wrong... im happy to see your improvements... i was really happy when you explained to me.. how eventEi "throw event" works...etc..(u can see ... im using it almost all the time)

I myself love this system! Very like. @Schmoozerd Thank you. P.S:

But serious... can you imagine that all quest end scripts etc ...can be done only by EAI?

Of course not. Throne of the Four Winds for example require full SD2, no EAI, no db_script there to help in any way. Very complex scenarios.

And you know what i would like to see? EAI action - send db_script.....
so i could do stuff like:
event=11 spawn + action send _db_script (with all our commands)

You can read topic http://cmangos.net/thread-590.html once I raised this question! It would be nice! This will allow me to call db_script without hacks.

Anyway...
think about what i said to you,.... and belive me.. db_scripts are not that bad ( you may think)
Regards

Thanks, regards.

How many ppl ... you see now here, that push stuff to core?
how many ppl work on db stuff??
M8 open your eyes ... and be happy what was achieved till this moment... becouse soon ...you may see noone interested anymore....

I know I'm trying to help the project than I can. From the outside it seems like something I require on the fact it is not. Regards.

xfurry commented 9 years ago

So, after so much time I managed to come up with a reasonable proposal of script commands that were requested and that we need. Here is what I'd like to push to the core: http://paste2.org/JMyDaPMG Please note that this isn't tested, but I don't think that there will be issues.

Kindly let me know your feedback (on the proposed commands only!) and if there are no major drawbacks I can push this to the core this week.

ghost commented 9 years ago
SCRIPT_COMMAND_DESPAWN_GO

What it is? Why only GO_JUST_DEACTIVATED. Maybe GAMEOBJECT_BYTES_1_SCRIPT_COMMAND It will be more effective? This will select Go State, Go Loot State and so on.

SCRIPT_COMMAND_SET_FLY

For Cataclysm useless, need additionally SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM); For correct fly anim and correct levitate state.

SCRIPT_COMMAND_FOLLOW

Why missing?

SCRIPT_COMMAND_FOLLOW: -> not ok. Not in this format. It will not work right if creature enters combat / evade. We already discussed this on IRC.

You to explained that it was not a problem.

 Expands Send AI Event list 

Why missing? Thanks for work.

xfurry commented 9 years ago

What it is? Why only GO_JUST_DEACTIVATED. Maybe GAMEOBJECT_BYTES_1_SCRIPT_COMMAND It will be more effective? This will select Go State, Go Loot State and so on.

If you read the comment, you'll see that this is a temporary issue. But GO_JUST_DEACTIVATED will do just fine for now.

For Cataclysm useless, need additionally SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM); For correct fly anim and correct levitate state.

I'm not 100% sure. Some creatures need this, others don't.

SCRIPT_COMMAND_FOLLOW

This is complicated. Will investigate later.

Expands Send AI Event list

This is not missing. I expanded this list with 4 more events. This should be enough for the moment.

However I think you missed the whole point of my comment. I asked you guys to test and let me know if there are any problems with the current proposal. We are not talking about the commands that are missing, but about the ones that I proposed.

Grz3s commented 9 years ago

hey @xfurry pls look on full test report: http://paste2.org/xP2XnbP9

cala commented 9 years ago

Thanks @Xfurry, that sounds very nice ! I'm afar this WE but I will test this the coming week and report back! :+1:

xfurry commented 9 years ago

Ok, so I can see that the buddy system doesn't allow us to use dead buddies. I need to see what we can do about this.

The Fly command is wrong on my side. I will come up with an update on this. We should only use SetLevitate + the byte flag if required. The SetCanFly is only handled by auras.

ghost commented 9 years ago
We should only use SetLevitate + the byte flag if required.

I told you about this a long time ago.

cala commented 9 years ago

Sorry for the late reply: I confirm @Grz3s results. I find the GO despawn command very useful. :+1: