[DiscordArchive] Is there an existing script assigned to the encounter you’re working on?
[DiscordArchive] Is there an existing script assigned to the encounter you’re working on?
Archived author: KJack • Posted: 2023-10-29T22:04:40.506000+00:00
Original source
I am starting to suspect a bug in ApplySpellImmune when `apply` is false. I added some (temporary, don't worry!) error debug commands to it and I don't think the else for loop is running correctly.
```c++
void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType)
{
LOG_ERROR("scripts.ai", "Unit::ApplySpellImmune: {} {} {} {}", spellId, op, type, apply);
if (apply)
{
// xinef: immunities with spellId 0 are intended to be applied only once (script purposes mosty)
if (spellId == 0 && std::find_if(m_spellImmune[op].begin(), m_spellImmune[op].end(), spellIdImmunityPredicate(type)) != m_spellImmune[op].end())
return;
SpellImmune immune;
immune.spellId = spellId;
immune.type = type;
immune.blockType = blockType;
m_spellImmune[op].push_back(std::move(immune));
}
else
{
for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
{
LOG_ERROR("scripts.ai", "Should {} (type {}) be removed?", itr->spellId, itr->type);
if (itr->spellId == spellId && itr->type == type)
{
m_spellImmune[op].erase(itr);
LOG_ERROR("scripts.ai", "Yes!");
break;
}
else
{
LOG_ERROR("scripts.ai", "No...");
}
}
}
}
```
My code:
```c++
me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_FREEZE, false);
me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SNARE, false);
me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_ROOT, false);
```
Logging output:
```
npc_zealot_zathAI::Constructor
Unit::ApplySpellImmune: 0 5 13 false
Unit::ApplySpellImmune: 0 5 11 false
Unit::ApplySpellImmune: 0 5 7 false
```
So the function is getting the `apply` = `false` correctly, but no logging output from that loop...
Archived author: KJack • Posted: 2023-10-29T22:04:44.345000+00:00
Original source
sorry for wall of text
Archived author: KJack • Posted: 2023-10-29T22:07:43.507000+00:00
Original source
there are no simple problems, i swear
Archived author: Kitzunu • Posted: 2023-10-29T22:15:05.560000+00:00
Original source
Lovely
Archived author: KJack • Posted: 2023-10-29T22:15:24.242000+00:00
Original source
https://tenor.com/view/wreckitralph-fixi...f-19395989
Archived author: Kitzunu • Posted: 2023-10-29T22:15:48.019000+00:00
Original source
https://tenor.com/view/bob-the-builder-g...f-21863917
Archived author: Kitzunu • Posted: 2023-10-29T22:16:44.681000+00:00
Original source
Why even have an option to remove in applyspellimmune
Archived author: Kitzunu • Posted: 2023-10-29T22:16:48.876000+00:00
Original source
Doesnt make sense ngl
Archived author: Kitzunu • Posted: 2023-10-29T22:16:58.920000+00:00
Original source
removespellimmune
Archived author: Kitzunu • Posted: 2023-10-29T22:17:00.229000+00:00
Original source
Pog