Description:
If an Area Trigger is set to SmartTrigger in areatrigger_scripts, it will no longer work as a quest exploration target (arriving at the trigger will not complete the objective).
Steps to reproduce the problem:
Branch(es):
BfA
TC rev. hash/commit:
TrinityCore rev. 947771e6bdbe 2018-11-25 14:28:44 +0100 (bfa branch) (Win64, RelWithDebInfo, Dynamic)
Operating system: Windows 10
This is intended and applies to all branches - returning true from OnTrigger hook disables ALL default actions such as quest credit, rest flag, teleport
@Shauren Is is possible to go around this somehow? I need the trigger to satisfy an objective, cast a spell on the player, and then teleport him
Do all of that in your script
@Shauren With SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS? It does not seem to work
That is mainly why I could not convert the script for the Beaten Corpse quest to SAI, 2.5 years ago.
https://github.com/TrinityCore/TrinityCore/blob/02757118f20e25c224bcbe1be792c3a5e5e4d81c/src/server/scripts/Kalimdor/zone_the_barrens.cpp#L58-L65
I guess there is no way to actually grant credit for that using SAI
So... what should I do?
The obvious solution is to use standard C++ scripting.
@illfated That is considerably more complicated, since I don't really know C++. Are there any guides or template scripts I could look at (specifically TC-related), to get an idea of the process?
All the files below /src/server/scripts/ should be practical examples in C++ scripting. If you need to start from scratch with a particular case, you can choose between posting a rough outline of what needs to be done, then ask for help with how it can be scripted in C++, or maybe go as far as opening a PR if you have got a starting point with some of the file contents already.
@illfated I'll have a look at those scripts, thank you. Also, is there any sort of cheatsheet with 'translations' of SAI events/actions to C++? That would be incredibly helpful
What I'm trying to create is a chain of custom quests. The objectives are fairly simple: go somewhere (most likely an area trigger), interact with objects, kill npcs, talk to npcs, etc. - fairly achievable with DB work and smart scripts (well, with the exception of the topic of this issue).
The only real difficulty lies in long-term tracking of these objectives (particularly of player choices in npc gossips, which is an essential part of the questline, for the RPG feel) and ordering (even timing at some points) events such as NPCs talking (in /say) to the player and each other, walking around, and performing specific actions in combat. There is also the matter of inducing spell effects, such as blackouts and teleportation, in the player.
Well, there are 2 ways to find out how that is handled.
1) look up old conversions from C++ to SAI (outdated code & PRs)
2) read how the source code does the job of translating SAI to core.
For point 1) you will simply have to dig in the PR history (completed PRs) to see how scripts were converted.
Point 2) is more about reading the contents of
@illfated Thank you again for the advice and the links
By the way, I saw some people write creature/quest scripts in lua instead of C++ - how is this possible?
TC does not use Lua yet, it has only been discussed briefly in a few issues and PRs as far as I know.
If you want to talk Lua programming, check out @Rochet2 and his repositories. Ask him for advice.
I used this last time, for some reason I was not able to receive credit if other objectives were not satisfied yet
Scourge Leader identified
Scourge Unit obliterated (100)
Injured Warsong Soldier rescued (3)
--
DELETE FROM `areatrigger_involvedrelation` WHERE `id` = 4963;
DELETE FROM `smart_scripts` WHERE `entryorguid` = 4963 AND `source_type` = 2;
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`,`event_param5`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_param4`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(4963,2,0,1,46,0,100,0,4963,0,0,0,0,15,11652,0,0,0,0,0,7,0,0,0,0,0,0,0,0,"Areatrigger (Plains of Nasam) - On Trigger - Quest Credit 'The Plains of Nasam'"),
-- Cooldown? Probably no or less than 15 sec https://www.youtube.com/watch?v=zwz0bzxTWUg
(4963,2,1,0,61,0,100,0,0,0,0,0,0,1,1,0,0,0,0,0,19,25465,0,0,0,0,0,0,0,"Areatrigger (Plains of Nasam) - On Link - Say Line 1 (Kel'Thuzad)");
DELETE FROM `areatrigger_scripts` WHERE `entry` = 4963;
INSERT INTO `areatrigger_scripts` (`entry`,`ScriptName`) VALUES
(4963,"SmartTrigger");
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 22 AND `SourceEntry` = 4963 AND `SourceId` = 2;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(22,1,4963,2,0,47,0,11652,10,0,0,0,0,"","Group 0: Execute SAI (Action 0) if quest 'The Plains of Nasam' is taken");
Most helpful comment
I guess there is no way to actually grant credit for that using SAI