Skip to content

[DRAFT] Scripts/Scarlet Enclave: Gift Of The Harvester#23114

Closed
Sorikoff wants to merge 8 commits into
TrinityCore:3.3.5from
Sorikoff:3.3.5-giftoftheharvester
Closed

[DRAFT] Scripts/Scarlet Enclave: Gift Of The Harvester#23114
Sorikoff wants to merge 8 commits into
TrinityCore:3.3.5from
Sorikoff:3.3.5-giftoftheharvester

Conversation

@Sorikoff

@Sorikoff Sorikoff commented Mar 14, 2019

Copy link
Copy Markdown
Contributor

Changes proposed:

  • Move spell Gift of the Harvester out from hacks to a SpellScript.
  • Implement GameObjectAI for item Gift of the Harvester (animation before cast), therefore dropping Data3 value (spell casted in this case).

Target branch(es): 3.3.5

Tests performed: Does build. Could work-in-game.

Known issues and TODO list: (add/remove lines as needed)

Comment thread src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp Outdated
@@ -0,0 +1,3 @@
INSERT INTO `spell_script_names` VALUES
(52479, 'spell_gift_of_the_harvester');
UPDATE `gameobject_template` SET `Data3`=0,`AIName`='',`ScriptName`='gift_of_the_harvesterAI' WHERE `entry`=190769;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why data3=0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because spell will be casted early, but animation is missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Animations are not implemented for al most all gobs type, better to keep the original value and wait for a generic solution.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a footnote: Aokromes always used to tell me that gameobject_template.Data* are sniffed data and should not be changed.

@Killyana Killyana Mar 30, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the sequence used by the gob (and probably any trap) https://gist.github.com/Killyana/05753c48ad36b49905924f4ed1811cca
01:59:23 - the gob is summoned
01:59:24 - the spell 52479 is cast by the gob
01:59:24 - SMSG_GAMEOBJECT_CUSTOM_ANIM
01:59:26 - SMSG_GAMEOBJECT_DESPAWN_ANIM
01:59:26 - SMSG_DESTROY_OBJECT
We have already an issue #23109 about this.
So no need to change the data or use extra code to activate the gob animation.

-- Faction must be updated
UPDATE `gameobject_template_addon` SET `faction`=1610  WHERE `entry`=190769;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, then I am going to revert gob changes (spell script is still welcome I believe).

Comment thread src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
Comment thread src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp Outdated
Comment thread sql/updates/world/3.3.5/9999_99_99_99_world.sql

void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
uint32 spellId = urand(0, 1) ? SPELL_MINER_GHOUL_TRANSFORM : SPELL_MINER_GHOST_TRANSFORM;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the random uint32 picker, not urand

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAND

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw why the hell is RAND inside CreatureAIImpl.h ??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this fd64cb2?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No pratical change ._.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep
@Keader the concept is: if there is a helper designed to do something, use it

@jackpoz

jackpoz commented Mar 15, 2019

Copy link
Copy Markdown
Member

Maybe set the PR as draft if it's not complete yet. You might want to include a crashlog in Debug mode too to let others see what's causing the crash

_scheduler.Schedule(2s, [this](TaskContext /*context*/)
{
me->SendCustomAnim(0);
me->CastSpell(nullptr, SPELL_GIFT_OF_THE_HARVESTER, true);

@Keader Keader Mar 15, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"me" cant be nullptr or schedule not even will be executed.
weird because 52479 Gift of the Harvester has conditions in DB, so implicit target need handle with this.
You debuged it already?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing _scheduler.CancellAll on death/removefromworld maybe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You think this might be the reason of crashes?

@Keader Keader Mar 15, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it is needed? (before scheduler) should avoid crash (i think)

_scheduler.SetValidator([this] { return me != nullptr; });

Looks like when TaskSchedule is running, object is despawned already.
So, looks like 2 sec time is wrong, or object need more time before despawn.

@jackpoz jackpoz Mar 15, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not "me" being null, look at stack frame 17

@Keader Keader Mar 15, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me = caster
and caster is null at this point: https://gist.github.com/Sorikoff/3d1ed6ee2e5573198fb99c8c1ebaf940#file-gistfile1-txt-L17
So while this schedule is executing, object (me/caster) despawn.

Or objects still use a little trigger creature to cast spells?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#17 0x0000555557b81f42 in WorldObject::CastSpell (this=0x7fff82615c00, target=0x0, spellId=52479

"this" is "me" and it's not null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok... but why caster is null in #2?
if i remember right, all objects use a world trigger to cast spells, idk if is current behavior still.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's a bug when the caster is a gameobject

@Keader

Keader commented Mar 15, 2019

Copy link
Copy Markdown
Contributor

@Shauren Taskscheduler work like "assync basic events" right?
I mean, if owner of event become null, scheduled events can be executed?

@Sorikoff

Copy link
Copy Markdown
Contributor Author

@ccrs

ccrs commented Mar 15, 2019

Copy link
Copy Markdown
Contributor

@Keader TaskScheduler can execute both synchronously and asynchronously, it depends which method is used to schedule the task
TaskScheduler::Async
TaskScheduler::Schedule

@jackpoz

jackpoz commented Mar 15, 2019

Copy link
Copy Markdown
Member

I mean, if owner of event become null, scheduled events can be executed?

this is 0x7fff82615c00 so it's not null. The null is deep down the callstack, probably some GetCaster() calls expecting the caster to still be there. Debugging it should show it.

@Keader

Keader commented Mar 15, 2019

Copy link
Copy Markdown
Contributor

EventMap can have same behavior?
i mean, can execute a event if event_owner is despawned/despawning?

@ccrs

ccrs commented Mar 15, 2019

Copy link
Copy Markdown
Contributor

both, eventmap and taskscheduler rely on Unit::Update, if its not called, both do nothing.
IIRC dead creatures do NOT call Unit::Update

@jackpoz

jackpoz commented Mar 23, 2019

Copy link
Copy Markdown
Member

any followup on this @Sorikoff ? did you find the cause of the crash

Edit: check the comment at #23114 (comment)

Please set this PR as draft until all issues has been solved

void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
uint32 spellId = RAND(SPELL_MINER_GHOUL_TRANSFORM, SPELL_MINER_GHOST_TRANSFORM);
GetCaster()->CastSpell(GetHitUnit(), spellId, true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetCaster() returns Unit* so ofc it will return NULL when the caster is a GameObject

Unit* GetCaster() const;

Try GetGObjCaster() instead (and NULL check it too)

GameObject* GetGObjCaster() const;

After that set a breakpoint here and debug it to ensure everything works as expected

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm now. Thanks a lot!

@Sorikoff Sorikoff changed the title Scripts/Scarlet Enclave: Gift Of The Harvester [DRAFT] Scripts/Scarlet Enclave: Gift Of The Harvester Mar 24, 2019
@Sorikoff

Copy link
Copy Markdown
Contributor Author

I will continue later on.

@Sorikoff Sorikoff closed this Mar 31, 2019
@jackpoz

jackpoz commented Mar 31, 2019

Copy link
Copy Markdown
Member

Hi, is this PR closed now ?

@Sorikoff

Copy link
Copy Markdown
Contributor Author

Yep. More generic fixes are needed.

@Sorikoff Sorikoff deleted the 3.3.5-giftoftheharvester branch April 13, 2019 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants