Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script engine improvements #409

Closed
xfurry opened this issue Apr 24, 2014 · 66 comments
Closed

Script engine improvements #409

xfurry opened this issue Apr 24, 2014 · 66 comments
Assignees
Labels
Type: Feature Request Issue is a CMaNGOS Extensions request.

Comments

@xfurry
Copy link
Member

xfurry commented Apr 24, 2014

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: scriptdev2/scriptdev2#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
Copy link

ghost commented Apr 24, 2014

Very timely! Thanks!

@Schmoozerd
Copy link
Member

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
Copy link

ghost commented Apr 24, 2014

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
Copy link
Member Author

xfurry commented May 4, 2014

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

@xfurry
Copy link
Member Author

xfurry commented May 4, 2014

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
Copy link
Member Author

xfurry commented Sep 18, 2014

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

@ghost
Copy link

ghost commented Oct 12, 2014

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

@xfurry
Copy link
Member Author

xfurry commented Oct 12, 2014

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...? 😟
My patch has a few issues, and I can see that nobody is bothered about them.

@ghost
Copy link

ghost commented Oct 13, 2014

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
Copy link
Member Author

xfurry commented Oct 13, 2014

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
Copy link

ghost commented Oct 13, 2014

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
Copy link
Member Author

xfurry commented Oct 13, 2014

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? 😉

@ghost
Copy link

ghost commented Oct 14, 2014

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
Copy link
Member Author

xfurry commented Oct 14, 2014

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
Copy link

ghost commented Oct 14, 2014

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
Copy link

cala commented Dec 18, 2014

@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. 😄

-- 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
Copy link
Member Author

xfurry commented Dec 18, 2014

@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. 😉

@ghost
Copy link

ghost commented Jun 12, 2015

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
Copy link

Rushor commented Jun 12, 2015

FollowerAI: you are Ulduar no?

@ghost
Copy link

ghost commented Jun 12, 2015

No, I am a person, not the instance.

@xfurry
Copy link
Member Author

xfurry commented Jun 12, 2015

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. 😄

But I think this already answers the question

@ghost
Copy link

ghost commented Jun 12, 2015

So, I see me alone you have left no.
cmangos/mangos-wotlk#153
rejected my pull.
cmangos/mangos-wotlk#148
Rejected. One mockery.
scriptdev2/scriptdev2-cata#27
rejected.
scriptdev2/scriptdev2-cata#30
rejected.
scriptdev2/scriptdev2-cata#25
rejected
scriptdev2/scriptdev2-cata#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
Copy link
Member Author

xfurry commented Jun 12, 2015

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
Copy link
Member Author

xfurry commented Jun 12, 2015

@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
Copy link

ghost commented Jun 12, 2015

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
Copy link

ghost commented Jun 13, 2015

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
Copy link
Member

Grz3s commented Jun 13, 2015

+     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
Copy link

ghost commented Jun 19, 2015

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 scriptdev2/scriptdev2-cata#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
Copy link
Member Author

xfurry commented Jul 2, 2015

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
Copy link

ghost commented Jul 2, 2015

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
Copy link
Member Author

xfurry commented Jul 3, 2015

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.

xfurry referenced this issue in unified-db/Database Jul 4, 2015
pls update your SD2
@Grz3s
Copy link
Member

Grz3s commented Jul 5, 2015

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

@cala
Copy link

cala commented Jul 5, 2015

Thanks @xfurry, that sounds very nice ! I'm afar this WE but I will test this the coming week and report back! 👍

@xfurry
Copy link
Member Author

xfurry commented Jul 8, 2015

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
Copy link

ghost commented Jul 9, 2015

We should only use SetLevitate + the byte flag if required.

I told you about this a long time ago.

@cala
Copy link

cala commented Jul 19, 2015

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

@xfurry
Copy link
Member Author

xfurry commented Jul 19, 2015

I think I remember now...
@Grz3s could you please share a movie of those DK area npcs. I need to see exactly how they behave in order to make this right. I think I know what needs to be done, but a video will spare some testing time on my side.

@xfurry
Copy link
Member Author

xfurry commented Jul 27, 2015

Here is the updated version: http://paste2.org/b1xfseIB
This will make everything work. Only one question remains: do we want to have the addUnitState(UNIT_STAT_IGNORE_PATHFINDING) together with the fly command or should we make it separate. Please confirm if it makes sense to have it as a separate command.

@xfurry
Copy link
Member Author

xfurry commented Jul 28, 2015

Poke @Grz3s and @cala about the comment above.
I'd like to get this implemented and closed asap.

@Grz3s
Copy link
Member

Grz3s commented Jul 28, 2015

hey @xfurry .. i just came back from my 2 weeks holliday..I'll look at this ASAP.
about your question ...
is this not the same
cmangos/mangos-wotlk@c4a46d8
?
BTW:
what happened with Respawn command?:)

@cala
Copy link

cala commented Jul 28, 2015 via email

@xfurry
Copy link
Member Author

xfurry commented Jul 28, 2015

what happened with Respawn command?:)

Will open a new topic about that. We might need to add some extra data_flag to target dead creatures.

@Grz3s
Copy link
Member

Grz3s commented Jul 29, 2015

hey @xfurry
patch tested

  • despawn gameobject works fine
-- TESTS for new command 40 - DESPAWN OBJECT
DELETE FROM dbscripts_on_creature_movement WHERE id = 2140904; 
INSERT INTO dbscripts_on_creature_movement (id, delay, command, datalong, datalong2, buddy_entry, search_radius, data_flags, dataint, dataint2, dataint3, dataint4, x, y, z, o, comments) VALUES
(2140904,1,28,8,0,0,0,0,0,0,0,0,0,0,0,0,'STATE_KNEEL'),
(2140904,6,0,2,0,0,0,0,2000005488,0,0,0,0,0,0,0,''),
(2140904,7,25,0,0,0,0,0,0,0,0,0,0,0,0,0,'RUN OFF'),
-- echo.TEST ON
(2140904,7,40,0,0,184798,50,7,0,0,0,0,0,0,0,0,'despawn object'),
-- echo.TEST OFF 
(2140904,8,28,0,0,0,0,0,0,0,0,0,0,0,0,0,'STATE_STAND');
  • fly works also fine ;) ( also if you remember .. prev. after 1st wp.(becouse mmaps) .. they went down to the ground continuing wps there -- this works now fine -- all in air)
    tested with:
 -- TESTS for new command 39 - FLY
DELETE FROM dbscripts_on_creature_movement WHERE id IN (2840602,2840603);
INSERT INTO dbscripts_on_creature_movement (id, delay, command, datalong, datalong2, buddy_entry, search_radius, data_flags, dataint, dataint2, dataint3, dataint4, x, y, z, o, comments) VALUES
(2840602,1,24,26308,0,0,0,0x08,0,0,0,0,0,0,0,0,'mount'),
-- echo.TEST ON -- levitate
(2840602,2,39,1,0,0,0,0,0,0,0,0,0,0,0,0,'fly ON'),  
(2840603,2,39,0,0,0,0,0,0,0,0,0,0,0,0,0,'fly OFF'),
-- echo.TEST OFF 
-- echo.TEST ON -- fly
-- (2840602,2,39,1,0,0,0,0x08,0,0,0,0,0,0,0,0,'ignore pathfinding ON'), 
-- (2840603,2,39,0,0,0,0,0x08,0,0,0,0,0,0,0,0,'ignore pathfinding OFF'),
-- echo.TEST OFF
(2840603,3,24,0,0,0,0,0x08,0,0,0,0,0,0,0,0,'unmount');

👍

@xfurry
Copy link
Member Author

xfurry commented Jul 29, 2015

So, let me understand: we don't need that ignore pathfinding option?

@Grz3s
Copy link
Member

Grz3s commented Jul 29, 2015

if u'll explain what this should do..(or what will not work without it) than i can tell you.. :)..
anyway as i said before ... fly worked well without using it.

@xfurry
Copy link
Member Author

xfurry commented Jul 29, 2015

Well, technically, that flag should make the creature not use the move maps. Sometimes flying creatures have issues on this.
I will run a few tests myself first, before pushing this.

@xfurry
Copy link
Member Author

xfurry commented Jul 31, 2015

@Grz3s here is a proposal for respawn command: http://paste2.org/GFZ9jJOt
Here is the updated version of previous patch: http://paste2.org/tmxJ93hK

@Schmoozerd
Copy link
Member

Hi guys :)
I just stumbled about this topic and naturally i read it ;)

@xfurry nice patches, please add a little bit more documentation to hte SEND_AI_EVENT command (to be clear to the user about sender, invoker and receiver)

For the second patch, i have one concern: be sure the database fields for the data_flags are big enough for 0x80-1

@xfurry
Copy link
Member Author

xfurry commented Aug 2, 2015

Hi @Schmoozerd
I will check the DB field. Still waiting for the final sign off from @Grz3s

Since you are here, maybe you would also have some thoughts on #260 😁

@Grz3s
Copy link
Member

Grz3s commented Aug 2, 2015

I thought that i explained all on irc..
Not much to say here:
all new commands work on tests that i showed you.
even updated ver. for respawn (one that u gave me on irc) -- so even despawned buddys can be respawned

BTW:
script_commands.txt should contain some info about:

40 SCRIPT_COMMAND_DESPAWN_GO -- cannot be used on gobjects Type=1 buttons ...(command doesnt work on them - they shouldnt despawn at all - and thats correct ;)

41 SCRIPT_COMMAND_RESPAWN_SELF: (your second patch - not above one)

  • I would change it for SCRIPT_COMMAND_RESPAWN -- we can use it on buddys also ;)
  • and note: if we'll use buddy - flag 0x40 must be added.

@cala
Copy link

cala commented Aug 3, 2015

@xfurry : I tested your latest patch this evening. Both FLY and DESPAWN GO commands are working very well (tested on WotLK core), as said Grz3s. Very good job. 👍

@ghost
Copy link

ghost commented Aug 12, 2015

Why closed? Although already unimportant

xfurry added a commit to cmangos/mangos-tbc that referenced this issue Aug 16, 2015
SCRIPT_COMMAND_SET_FLY - enable / disable levitate
SCRIPT_COMMAND_DESPAWN_GO - despawn a gameobject
SCRIPT_COMMAND_RESPAWN - respawn a dead or despawned creature. Requires SCRIPT_FLAG_BUDDY_IS_DESPAWNED in order to target dead or despawned creatures

Also add additional custom events for eventAI

Thanks to @Grz3s, @cala, @Ulduar and @Schmoozerd for feedback

Close cmangos/issues#409

(based on commits [12899] - c25f772 and [12902] - 16191d4)

Signed-off-by: evil-at-wow <evil.at.wow@gmail.com>
xfurry added a commit to cmangos/mangos-classic that referenced this issue Aug 29, 2015
SCRIPT_COMMAND_SET_FLY - enable / disable levitate
SCRIPT_COMMAND_DESPAWN_GO - despawn a gameobject
SCRIPT_COMMAND_RESPAWN - respawn a dead or despawned creature. Requires SCRIPT_FLAG_BUDDY_IS_DESPAWNED in order to target dead or despawned creatures

Also add additional custom events for eventAI

Thanks to @Grz3s, @cala, @Ulduar and @Schmoozerd for feedback

Close cmangos/issues#409

(based on commits [12899] - c25f772 and [12902] - 16191d4)

Signed-off-by: evil-at-wow <evil.at.wow@gmail.com>

(based on commit [s2321] - 6a77e69)

Signed-off-by: Cala <calaftp@free.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Request Issue is a CMaNGOS Extensions request.
Projects
None yet
Development

No branches or pull requests

5 participants