What's new

SQL 6xx Phasemask in SmartAI

dokuro

Veteran Member
Verified Member
31
2020
6
Location
Paris
Phasemask_01.jpg


Phasemask, not to be confused with Phases (ACTION_SET_INGAME_PHASE_MASK), are to AI what Phases are for a player or a mobs.

According to an event, the phases are used to project the player into an alternative space and superimposed on different mobs and gobs for a coordinated meme.

Phasemask are a bit similar but in the field of AI, that is to say that a default mob executes its SmartAI code in Phasemask 0, it may be interesting for a particular event to make it execute another AI defined here in Phasemask 1 or Phasemask 2.

Some example situations:

You can script a mob with several specialties, for example at the agro a mage this will behave randomly as using the fire spells or the frost spells
A quest will ask you to interact with an NPC who could respond favorably or unfavorably to your request

For this example I will base myself on he quest Make yourself useful! , this one asks us to stir up lazy workers so that they get back to work, they will react in 2 ways: either they accept and credit you the quest or they refuse and attack you.

For this mob we will therefore have 3 different states: 1 by default and 2 related to the quest and will activate randomly after a gossip menu

Phasemask 0: the normal state which will be used to manage the mob normally ie without having taken the quest

Line 10: default combat skill
Line 40: after the gossip removes the aura that kept it lying down
Line 50: after the gossip switches the mob randomly to Phasemask 1 or Phasemask 2

after that the mob will no longer run the smartAI Phasemask 0 but only the Phasemask 1 or 2

Phasemask 1: The mob peacefully accepts your order

Line 100: gives you the credit of the quest
Line 105: close the gossip menu window
Line 110: makes a comment that it goes back to work
Line 115: fast forward to simulate returning to work
Line 120: despawn

Phasemask 2: The mob takes your request very badly

Line 150: change the faction of the mob to make it aggressive
Line 152 154 155: these lines change the faction by 3 different mobs (id) within a radius of 20m, otherwise its would be too easy: p
Line 160: a little message to let you know that it will make you regret your request
Line 165: his combat skill in Phasemask 2

Then it is necessary to think of the re initialization for various cases: You have moved away and the mob leaves the fight, you are dead, ... it will be detected by an EVENT_RESET
Line 170: hands over the original faction to the mob
Line 175: switch the mob back to Phasemask 0

You will notice that lines 170 and 175 are in Phasemask 2 since indeed this initialization can only happen after the end of initialization 2

Line 180: gives the elongated aura to the mob when it has returned to its original position. It runs in Phasemask 0 since it comes after the action of line 175

The code for the lazy PNJ:

-- Travailleur paresseux SAI
SET @ENTRY := 47292;
UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`[email protected];
DELETE FROM `smart_scripts` WHERE `entryorguid`[email protected] AND `source_type`=0;
INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(@ENTRY,0,10,0,4,0,100,1,0,0,0,0,11,14890,0,0,0,0,0,2,0,0,0,0,0,0,0,"Coup désarçonnant"),
(@ENTRY,0,40,0,62,0,100,0,12238,0,0,0,28,32951,0,0,0,0,0,1,0,0,0,0,0,0,0,"Rendez-vous utile ! 27969 : retire aura"),
(@ENTRY,0,50,0,62,0,100,0,12238,0,0,0,37,1,2,0,0,0,0,1,0,0,0,0,0,0,0,"Rendez-vous utile ! 27969 : RND phase"),
(@ENTRY,0,100,105,1,1,100,1,0,0,3000,3000,33,47127,0,0,0,0,0,7,0,0,0,0,0,0,0," - phase 1 : Rendez-vous utile ! 27969 : credit"),
(@ENTRY,0,105,110,61,1,100,0,12238,0,0,0,72,0,0,0,0,0,0,7,0,0,0,0,0,0,0," - phase 1 : Rendez-vous utile ! 27969 : fermer gossip"),
(@ENTRY,0,110,115,61,1,100,1,12238,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0," - phase 1 : Rendez-vous utile ! 27969 : blabla"),
(@ENTRY,0,115,120,61,1,100,0,12238,0,0,0,46,15,0,0,0,0,0,1,0,0,0,0,0,0,0," - phase 1 : Rendez-vous utile ! 27969 : avance"),
(@ENTRY,0,120,0,61,1,100,0,12238,0,0,0,41,2000,0,0,0,0,0,1,0,0,0,0,0,0,0," - phase 1 : Rendez-vous utile ! 27969 : despawn"),
(@ENTRY,0,150,0,60,2,100,1,0,0,3000,3000,2,1924,0,0,0,0,0,1,0,0,0,0,0,0,0,"phase 2 : Rendez-vous utile ! 27969 : faction 1924"),
(@ENTRY,0,152,0,60,2,100,1,0,0,3000,3000,2,1924,0,0,0,0,0,9,47690,0,20,0,0,0,0,"phase 2 : Rendez-vous utile ! 27969 : faction 1924 pour pnj 47690"),
(@ENTRY,0,154,0,60,2,100,1,0,0,3000,3000,2,1924,0,0,0,0,0,9,47291,0,20,0,0,0,0,"phase 2 : Rendez-vous utile ! 27969 : faction 1924 pour pnj 47291"),
(@ENTRY,0,155,0,60,2,100,1,0,0,3000,3000,2,1924,0,0,0,0,0,9,47974,0,20,0,0,0,0,"phase 2 : Rendez-vous utile ! 27969 : faction 1924 pour pnj 47974"),
(@ENTRY,0,160,0,60,2,100,1,0,0,3000,3000,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,"phase 2 : Rendez-vous utile ! 27969 : blabla"),
(@ENTRY,0,165,0,0,2,100,0,0,0,2500,2500,11,14890,0,0,0,0,0,2,0,0,0,0,0,0,0,"phase 2 : Coup désarçonnant"),
(@ENTRY,0,170,0,25,2,100,0,0,0,0,0,2,190,0,0,0,0,0,1,0,0,0,0,0,0,0," - phase 2 : reset faction"),
(@ENTRY,0,175,0,25,2,100,0,0,0,0,0,22,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"reset phase mask 0"),
(@ENTRY,0,180,0,21,0,100,0,12238,0,0,0,75,32951,0,0,0,0,0,1,0,0,0,0,0,0,0,"Rendez-vous utile ! 27969 : reset aura");

In green: we randomly activate Phasemask 1 or 2. Other possible Action: ACTION_SET_EVENT_PHASE, ACTION_INC_EVENT_PHASE
In blue define the Phasemask (s) for this line by opening the window in red

Imgur: The magic of the Internet

Credit to : Stitch from Aquayoup
 
Last edited by a moderator:
Top