SAI Scripting questions

I’ve a problem to make SmartAI for the quest Arcane Legacy, quest ID=25766, must have a killcredit when, after launch the trap, spawn a soul with ID=41232, and must kill this soul with a spell ID=77303 that instantkill all at 4 yard, tahn my soul, and i’ve a credit. I hope was the correct way. Someone can help me?

Start. Sharing. Code.

Ok sorry im new with this world /emoticons/default_smile.png. The quest is in more phase, if i don’t bad watch, the step are:

-Click on Item in my inventory

-When the GOB are on the mob, he died, and spawn a soul/wisp

-Killcredit

I try to create the first phase, when click on item and spawn wisp

GOB—>ID=203217

Spell of GOB —>ID=77303

Wisp ID---->77305

– Highborne Sorcerer SAI
SET @ENTRY := 34932;
UPDATE creature_template SET AIName=‘SmartAI’ WHERE entry = @ENTRY;
DELETE FROM smart_scripts WHERE entryorguid IN(@ENTRY,@ENTRY100+0,@ENTRY100+1);
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,0,0,8,0,100,0,77303,0,0,0,87,@ENTRY100+0,@ENTRY100+1,0,0,0,0,1,0,0,0,0,0,0,0,“Highborne Sorcerer - On Spellhit ‘<Spell not found!>’ - Run Random Script”),
(@ENTRY100+0,9,0,0,0,0,100,0,0,0,0,0,12,41232,1,60000,0,0,0,1,0,0,0,0,0,0,0,“Highborne Sorcerer - On Script - Summon Creature ‘Bound Highborne Spirit’”),
(@ENTRY
100+1,9,0,0,0,0,100,0,0,0,0,0,12,41231,6,20000,0,0,0,1,0,0,0,0,0,0,0,“Highborne Sorcerer - On Script - Summon Creature ‘Enraged Highborne Spirit’”);

Sorry for my english

Edit 2: I resolved with 2 smartai, one on creature dead, otherone on creature spawned, and work. Now last 2 issue, this creature must follow me and say some word when spawned

Edit 3: Now i’m at 90% of fixing quest, i’ve doing all, when i use item in my bag, kill NPC and spawn a Soul that give me a credit, follow me and say some text. The last issue is that when i use the Item, not always spawn creature ID=41232 but sometimes can spawn other creature hostile ID=41231. I look the action SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST, but haven’t succes, can you explain me how work? Tnx

Edit 4: I create an ACTIONLIST for the spawn of 2 creatures, but this mob don’t spawn. Here my script, some help?

I’m sorry but I have no idea what you’re trying to do…

How to set [COLOR=rgb(51,51,51)]UNIT_FIELD_BYTES_2? There is [COLOR=rgb(51,51,51)]SMART_ACTION_SET_UNIT_FIELD_BYTES_1 but no action for [COLOR=rgb(51,51,51)]UNIT_FIELD_BYTES_2. /emoticons/default_huh.png[COLOR=rgb(51,51,51)] I want set it to 2 = STATE_RANGED (prepared ranged weapon).

You can’t set UNIT_FIELD_BYTES_2 through SAI, but you can set the sheath state (which seems to be what you’re looking for) using the [COLOR=rgb(51,51,51)]SMART_ACTION_SET_SHEATH action_type. This action_type calls Unit::SetSheath, which then on its turn calls SetByteValue to edit the UNIT_FIELD_BYTES_2.

[COLOR=rgb(51,51,51)]The reason you can’t directly edit the bytes2 field is because it’s pretty useless when you think of when it’s needed, as seen in these enumerators:

[COLOR=rgb(51,51,51)]

[CODE]// high byte (3 from 0…3) of UNIT_FIELD_BYTES_2
enum ShapeshiftForm
{
FORM_NONE = 0x00,
FORM_CAT = 0x01,
FORM_TREE = 0x02,
FORM_TRAVEL = 0x03,
FORM_AQUA = 0x04,
FORM_BEAR = 0x05,
FORM_AMBIENT = 0x06,
FORM_GHOUL = 0x07,
FORM_DIREBEAR = 0x08,
FORM_STEVES_GHOUL = 0x09,
FORM_THARONJA_SKELETON = 0x0A,
FORM_TEST_OF_STRENGTH = 0x0B,
FORM_BLB_PLAYER = 0x0C,
FORM_SHADOW_DANCE = 0x0D,
FORM_CREATUREBEAR = 0x0E,
FORM_CREATURECAT = 0x0F,
FORM_GHOSTWOLF = 0x10,
FORM_BATTLESTANCE = 0x11,
FORM_DEFENSIVESTANCE = 0x12,
FORM_BERSERKERSTANCE = 0x13,
FORM_TEST = 0x14,
FORM_ZOMBIE = 0x15,
FORM_METAMORPHOSIS = 0x16,
FORM_UNDEAD = 0x19,
FORM_MASTER_ANGLER = 0x1A,
FORM_FLIGHT_EPIC = 0x1B,
FORM_SHADOW = 0x1C,
FORM_FLIGHT = 0x1D,
FORM_STEALTH = 0x1E,
FORM_MOONKIN = 0x1F,
FORM_SPIRITOFREDEMPTION = 0x20
};

// low byte (0 from 0…3) of UNIT_FIELD_BYTES_2
enum SheathState
{
SHEATH_STATE_UNARMED = 0, // non prepared weapon
SHEATH_STATE_MELEE = 1, // prepared melee weapon
SHEATH_STATE_RANGED = 2 // prepared ranged weapon
};

#define MAX_SHEATH_STATE 3

// byte (1 from 0…3) of UNIT_FIELD_BYTES_2
enum UnitPVPStateFlags
{
UNIT_BYTE2_FLAG_PVP = 0x01,
UNIT_BYTE2_FLAG_UNK1 = 0x02,
UNIT_BYTE2_FLAG_FFA_PVP = 0x04,
UNIT_BYTE2_FLAG_SANCTUARY = 0x08,
UNIT_BYTE2_FLAG_UNK4 = 0x10,
UNIT_BYTE2_FLAG_UNK5 = 0x20,
UNIT_BYTE2_FLAG_UNK6 = 0x40,
UNIT_BYTE2_FLAG_UNK7 = 0x80
};

// byte (2 from 0…3) of UNIT_FIELD_BYTES_2
enum UnitRename
{
UNIT_CAN_BE_RENAMED = 0x01,
UNIT_CAN_BE_ABANDONED = 0x02
};[/CODE]

If the NPC is gets aggro it will stop but not attack during it’s waypoint.

-- Gakra SAI SET @ENTRY := 299441; UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=@ENTRY; DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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,0,1,11,0,100,0,0,0,0,0,53,1,299441,0,99001,1000,0,1,0,0,0,0,0,0,0,"Gakra - On Respawn - Start Waypoint"), (@ENTRY,0,1,0,61,0,100,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gakra - On Respawn - Say Line 0"), (@ENTRY,0,2,0,4,0,100,0,0,0,0,0,20,1,0,0,0,0,0,2,0,0,0,0,0,0,0,"Gakra - On Aggro - Start Attacking");

Try calling [COLOR=rgb(51,51,51)]SMART_ACTION_WP_PAUSE before calling [COLOR=rgb(51,51,51)]SMART_ACTION_AUTO_ATTACK. You also might want to try [COLOR=rgb(51,51,51)]SMART_ACTION_ATTACK_START instead.

Still wont work, NPC will still stand there and not attack. And will only resume it’s waypoint after the NPC is dead.

-- Gakra SAI SET @ENTRY := 299441; UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=@ENTRY; DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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,0,1,11,0,100,0,0,0,0,0,53,1,299441,0,99001,1000,0,1,0,0,0,0,0,0,0,"Gakra - On Respawn - Start Waypoint"), (@ENTRY,0,1,0,61,0,100,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gakra - On Respawn - Say Line 0"), (@ENTRY,0,2,0,4,0,100,0,0,0,0,0,49,1,0,0,0,0,0,2,0,0,0,0,0,0,0,"Gakra - On Aggro - Start Attacking"), (@ENTRY,0,3,0,40,0,100,0,3,299441,0,0,54,7000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gakra - On Waypoint 3 Reached - Pause Waypoint");

I meant that you call [COLOR=rgb(51,51,51)]SMART_ACTION_WP_PAUSE on aggro, and then link it to [COLOR=rgb(51,51,51)]SMART_ACTION_ATTACK_START.

Oh oops lol. Any way I found another way to do it. I set used [COLOR=rgb(51,51,51)]SMART_ACTION_ATTACK_START on aggro and ACTION_SET_REACT_STATE (2) on aggro. But I also had to set UNIT_FLAGS to 32832. Thanks for the help /emoticons/default_biggrin.png

How can I make an npc to react when player type “/salute” on him?

I’m trying to make an npc give a quest credit on salute emote received but it doesn’t work.

I have try with [COLOR=rgb(51,51,51)]SMART_EVENT_RECEIVE_EMOTE(22) and emote id [COLOR=rgb(51,51,51)]66 and 113 but have no success. /emoticons/default_huh.png[COLOR=rgb(51,51,51)]

[FONT=Arial]EDIT[/FONT][COLOR=rgb(51,51,51)]: I figured it out. Player emote salute is text emote with id 78. /emoticons/default_wink.png

(@ENTRY,0,0,0,22,0,100,0,78,5000,5000,0,33,creditidhere,0,0,0,0,0,7,0,0,0,0,0,0,0,“on receive salute give credit”);

try this untaught, good luck.

hmmm day late and dollar short… your edit is very faint for me to see, sorry about that.

New guy here, hopefully this won’t be painful! I’ve been pulling my hair out trying to figure out why this will not work: I am attempting to have an NPC whose stand_state is dead (though the NPC is very much alive) change to standing upon accepting a quest. The problem is that, no matter how I approach this, he will not freaking STAND UP. For reference, the NPC is Kernobee in Gnomeregan who, upon accepting his escort quest “A Fine Mess,” should stop playing dead, stand up, and begin following you.

– Kernobee SAI
SET @ENTRY := 7850;
UPDATE creature_template SET AIName=“SmartAI” WHERE entry=@ENTRY;
DELETE FROM smart_scripts WHERE entryorguid=@ENTRY 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,0,0,19,0,100,0,2904,0,0,0,90,0,0,0,0,0,0,1,0,0,0,0,0,0,0,“Kernobee - On Quest ‘A Fine Mess’ Taken - Set Flag Standstate Stand Up”);

I have him running Event 19 (Event_Accepted_Quest) with QuestID 2904 (A Fine Mess), Action 90 (Action_Set_Unit_Field_Bytes_1) with arguments 0 and 0 (Unit_Stand_State_Stand) and (Unit_Stand_State_Stand_Type) respectively for “Unit field bytes 1” and “Type 0/2/3.” Target is set to 1 (Target_Self), though I’ve tried Target_Creature_GUID with his entry and GUID and that also failed to work. [His GUID and entry are 30135 and 7850 respectively]. What on earth am I doing wrong here? Everything looks correct, but I have to be missing something.

EDIT: I might also point out that I’ve scripted his quest in C++ (but have removed the code and recompiled with a clean, unaltered build for working with SAI - 60C214E99CF0 2014-04-21 22:24:50 -0400 [COLOR=rgb(51,51,51)](master branch) (Win32, Release), DB: TDB 335.53), but am disappointed with how disorganized it is - it has been a long time since I’ve worked in C++ and my code probably looks like crap, but it does get the job done. The only snag is that I cannot get the Alarm-a-bomb 2600 to work properly, but that is for another day. I sort of know what I’m doing here with C++ scripting, but SmartAI is kicking my butt.

The code itself is looking fine to me. Values are correct…

  1. Are you sure you removed the scriptname in the database? If it has its scriptname set, the ainame will be ignored.

  2. Check your DB error log if that will point you anywhere.

  3. If both the above points don’t give anything back, change the action_type to something like an emote or talk (SMART_ACTION_TALK) action in order to test if the event is called.

Color me dumb, but, when you say " Are you sure you removed the scriptname in the database? If it has its scriptname set, the ainame will be ignored" you’re talking about the creature_template field where the type of AI gets inserted, correct? If not, where might one find the scriptname for an entry? Sorry to be so remedial about some of this; it’s still all getting absorbed a little slowly. /emoticons/default_smile.png I’m just thankful for the assistance!

The scriptname field in creature_templates! Yes, it is blank and the ainame field is set to SmartAI. The DB error log is blank, and I’ve changed the action type to Action_Follow (29) and set the target to Target_Action_Invoker (7) and he follows my character, albeit in a very erratic fashion.

For reference, here is the C++ version of what I was trying to do here:

bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) OVERRIDE
{
if (quest->GetQuestId() == QUEST_A_FINE_MESS)
{
if (npc_kernobeeAI* kernobeeAI = CAST_AI(npc_kernobee::npc_kernobeeAI, creature->AI()))
{
creature->SetStandState(UNIT_STAND_STATE_STAND);
creature->AI()->Talk(SAY_KERNOBEE_0);
kernobeeAI->StartFollow(player, FACTION_KERNOBEE, quest);
}
}
return true;
}

Some of it was ported from the MaNGOS implementation, but the rest of his AI is completely rebuilt. I’m still learning how to get an NPC to interact with another (for example, having this quest-accept cause the Alarmabomb to enter the room and begin following Kernobee), so if SmartAI scripting is not the way to go, any pointers on how to accomplish that in C++ would be greatly appreciated, as Kernobee is completely done in that respect (Alarmabomb is still a WIP - I just cant get him to snap to attention and start following Kernobee). If you would like to see the rough draft of the C++ script, let me know; Alarmabomb is, like I said, untested, but Kernobee seems to working as he should.

Woops, forgot to reply after I read your reply. My bad.

I indeed meant the creature_template.ScriptName field.

I’ve been digging into some of the code (I already did by my first reply without any success) and I still can’t figure out what the problem is. The code itself all looks like it’s perfectly fine, so I’d assume there’s something going wrong in the core part. I suggest you attempt adjusting the SMART_ACTION_SET_UNIT_FIELD_BYTES_1 handler so that, for example, when it calls Unit::SetByteFlag, it also makes the specific unit say a line. If this happens, try calling Unit::SetStandState with UNIT_STAND_STATE_STAND parameter and see how that turns out. Other then this I’m out of idea’s for now, sorry.

Hello guys i need help…
I have this SAI for Lieutenant Walden questTender for the first quest of worgens Lockdown! and have problems with it.

– Lieutenant Walden SAI
SET @ENTRY := 34863;
UPDATE creature_template SET AIName=“SmartAI” WHERE entry=@ENTRY;
DELETE FROM smart_scripts WHERE entryorguid=@ENTRY 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,0,1,20,0,100,0,14078,0,0,0,75,59073,2,0,0,0,0,7,0,0,0,0,0,0,0,“On Quest Reward (Lockdown), cast 59073 on player (to change to phase 2)”),
(@ENTRY,0,1,0,61,0,100,0,14078,0,0,0,103,0,0,0,0,0,0,7,0,0,0,0,0,0,0,“On Quest Reward (Lockdown), Force Character Save to DB”);

the problem is that it change the phase to 3 and when i try to get close to Prince Liam (in phase 2) to deliver the quest i going to phase one again (i think that isn’t save the player phase or is not work very well the second line of that SAi )

I do not understand why if this same code work on other repack… what it diferent in my database? spell_area? core? someone can tell if this can be a core problem that make the action 103 not work for me? thanks for read BTW

Could the problem be overcome when the player are going to be save with the action 103 the structure of my data base characters? or a table?

thanks gus i found the problem solution… is in the table spell_area.!!!