Utility to convert SAI comments to proper style

Output file in which all current comments are converted to fit the proper code style so everything is easier to understand. Download: http://fbe.am/pHP (updated 19-12-2013).

Git repository of development (written in C#): https://github.com/Discover-/SAI-Comment-Converter

P.S. It’s worth adding that this script will show that quite a few scripts in the database currently just won’t work because there is data in there which makes no sense. A few quick examples:

Using SMART_TARGET_NONE instead of SMART_TARGET_POSITION → won’t do ANYTHING.

It’s worth mentioning there’s 14 of these cases in the current code.

UPDATE smart_scripts SET comment=“Val’kyr Arbiter - On Script - Move To ” WHERE source_type=9 AND entryorguid=30501000 AND id=0;

Not sure what the hell the person who wrote this was thinking, but 256 is certainly not a valid stand state type. Old comment states it’s the “wipe aggro” flag…

UPDATE smart_scripts SET comment=“Greater Felfire Diemetradon - On Spellhit ‘Tag Greater Felfire Diemetradon’ - Set Flag <Unknown bytes1 (UnitStandStateType)>” WHERE source_type=0 AND entryorguid=21462 AND id=2;

Same as above. In this case the comment states it should make the unit hover.

UPDATE smart_scripts SET comment=“Bjorn Halgurdsson - On Evade - Set Flag <Unknown bytes1 (UnitStandStateType)>” WHERE source_type=0 AND entryorguid=24238 AND id=16;

This is supposed to give quest credit according to the old comment; it uses SMART_ACTION_ADD_POWER…

UPDATE smart_scripts SET comment=“Rusty Cage - On Gameobject State Changed - Add 0 ” WHERE source_type=1 AND entryorguid=191544 AND id=1;

Someone who thought you could use SET_INVINCIBILITY_HP_LEVEL with parameters 0,0 to ‘reset’ it. Not the case…

UPDATE `smart_scripts` SET `comment`="High Priest Mu'funu - On Script - Set Invincibility Hp <Unsupported parameters>" WHERE `source_type`=9 AND `entryorguid`=2875200 AND `id`=4;

nice feature, it helps troubleshooting. maybe add a similar check on core startup?

That’s not really the purpose. The purpose is to generate a query which updates all comments to a proper format.

This post is more like a big LOL at those weird scripts.

Yeah kind of. Perhaps an idea to create an utility to scan all smart scripts for faulty cases (incorrect use of parameters, for example)? I’m building this functionality into my own SAI-Editor soon.

I will look at them tonight

UPDATE [COLOR=rgb(0,136,0)]smart_scripts SET [COLOR=rgb(0,136,0)]comment[COLOR=rgb(102,102,0)]=[COLOR=rgb(0,136,0)]“Bjorn Halgurdsson - On Evade - Set Flag <Unknown bytes1 (UnitStandStateType)>” WHERE [COLOR=rgb(0,136,0)]source_type[COLOR=rgb(102,102,0)]=[COLOR=rgb(0,102,102)]0 AND [COLOR=rgb(0,136,0)]entryorguid[COLOR=rgb(102,102,0)]=[COLOR=rgb(0,102,102)]24238 AND [COLOR=rgb(0,136,0)]id[COLOR=rgb(102,102,0)]=[COLOR=rgb(0,102,102)]16[COLOR=rgb(102,102,0)];

[COLOR=rgb(102,102,0)]This is an issue with your program.

UPDATE smart_scripts SET comment=“Rusty Cage - On Gameobject State Changed - Add 0 ” WHERE source_type=1 AND entryorguid=191544 AND id=1;

[COLOR=rgb(102,102,0)]This is an issue with your program.

UPDATE smart_scripts SET comment=“High Priest Mu’funu - On Script - Set Invincibility Hp ” WHERE source_type=9 AND entryorguid=2875200 AND id=4;

I don’t know of 0 is valid param values for this. I’ve never used it.

First two were fixed a while ago and the the invincibility one was a mistake on my side. Updating post with newest SQL on a clean and updated TDB.

I just fixed the first two last night

New download link to latest output: http://fbe.am/pHP

Reviewing and pushing today.

Maybe this isn’t the right thread to suggest this, but how about doing the same sort of utility for the conditions table? I see a lot of entries in that table with no comment at all (shows NULL). I figured that you could do that as an easy modification to this SAI project.

It wouldn’t be an easy modification as the base of the application can be written in just under a few minutes, it’s all the converting that is different for each and every action_type, targt_type, event_flags, etc. that makes it quite a big project. However I do agree and have written it on my TODO, so thanks. /emoticons/default_smile.png

P.S. It was the right thread to suggest this in. /emoticons/default_wink.png

Cool. I just happened to spot about 8 conditions that are being ignored in my database, and I think they have NULL comments. I haven’t taken the time to go researching what they were supposed to be doing, so I’ve ignored the “ignoring” messages (seemed appropriate).

Yeah that’s also one of the reasons I wanted to do this for SAI. There’s a LOT of incorrect comments, or even blank ones, while the comment column exists for a reason and actually should make it a whole lot easier to read. Going to work on the Condition-Comment-Converter in a little while, thanks for the suggestion. /emoticons/default_smile.png

Commit this project was pushed: https://github.com/TrinityCore/TrinityCore/commit/9ac96fd702d8ed23491d13eda2238312120cf52f

Sometimes, it only takes a fresh perspective to see what is right in front of us. I’ve been there too many times.

https://github.com/Discover-/Condition-Comment-Converter