[lua] allow phys blu spells to inflict added effect on 0 damage - #11205
[lua] allow phys blu spells to inflict added effect on 0 damage#11205lapislosh wants to merge 2 commits into
Conversation
|
I'll double check how core is handling it, you could be right. |
|
You are right in that it returns two parameters back out to core, that would be here (luautils.cppp) int32 OnSpellCast(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell)
{
TracyZoneScoped;
if (PSpell == nullptr)
{
ShowError("luautils::OnSpellCast: Spell not found!");
return 0;
}
auto onSpellCast = getSpellCachedFunction(PSpell, "onSpellCast");
if (!onSpellCast.valid())
{
return 0;
}
auto result = onSpellCast(PCaster, PTarget, PSpell); // <---- actual call out to lua
if (!result.valid())
{
sol::error err = result;
ShowError("luautils::onSpellCast: %s", err.what());
ReportErrorToPlayer(PCaster, err.what());
return 0;
}
int32 retVal = result.get_type(0) == sol::type::number ? result.get<int32>(0) : 0;
return retVal;
}However, since it only checks the first (0th) result the 2nd one is discarded. I don't think your change will do anything noticable.
The second result from the lua return would be I suppose in theory this could be faster, but its probably immeasurable. Does that all make sense to you now? |
|
Ok, updated with only the 17 phys added effect spells changed now. Tested a bit and didn't see it spitting out any errors due to the extra arg so I think you're correct that it's fine. |
|
Hm I'm guessing it's mad about this in Spell.lua which only expects 1 return value, which I don't reaallllyy want to touch for something like this. ---@field onSpellCast? fun(PCaster: CBaseEntity, PTarget: CBaseEntity, PSpell: CSpell): integer? |
|
I added a commit to allow that for now. Blue magic is going to get a rewrite/update soonish so I don't expect you to take on the burden of fixing that |


I affirm:
What does this pull request do?
Allows BLU spells to inflict their additional effects even if the spell hits for 0 - this will typically be against Stoneskin, as no spell can do 0 damage just normally. The old code doesn't work properly because it assumes a 0-damage hit is a miss, while the new code explicitly checks to see if any hits landed.
Siknoz test attempting to sleep an earth elemental with stoneskin up:

Steps to test these changes
Find a troll in Mt Zhayolm or anywhere
!mobskill 1744 for diamondhide
Use headbutt or pinecone bomb or something on it and ensure the additional effect lands