NPC Spells Cast %
Moderator: Team Members
Forum rules
READ THE FORUM STICKY THREADS BEFORE ASKING FOR HELP!
Most information can be found there, and if not, the posts will help you determine the information required to get assistance from the development team.
Incomplete Help Requests will be locked or deleted.
READ THE FORUM STICKY THREADS BEFORE ASKING FOR HELP!
Most information can be found there, and if not, the posts will help you determine the information required to get assistance from the development team.
Incomplete Help Requests will be locked or deleted.
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
NPC Spells Cast %
Before I start digging into the source, are we definitely talking a percentage? So if the cast_percentage is set to 2, then during a turn a random is rolled and it should fire 2% of the time? I swear I changed it to 2 and reloaded, during a 60 second fight I got hit like 10 damn times which seems impossible.
Resident Dirty Hippy
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
Well I see where the difference is in what I expected and what is actually happening. ProcessSpell in the brain is firing 3-4 times a second. I am not sure yet if that should actually be happening.
Resident Dirty Hippy
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: NPC Spells Cast %
i dont think that is correct eitherif its the same spell fireing 3-4 times per second, it should only fire as fast as the spell is designed forGangrenous wrote: Fri May 10, 2019 6:15 am Well I see where the difference is in what I expected and what is actually happening. ProcessSpell in the brain is firing 3-4 times a second. I am not sure yet if that should actually be happening.
so for example Incinarate takes 1 second to cast and has an 8 second recast, which means it should only be getting cast 1 every 9 seconds
but to be complete in my diagnosis, lol, I need to know the name of the spell your looking at
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
It is a custom spell, I am still looking into the code to see why. I change spell data such as recast, duration, call frequency but those checks are still being done at the same rate. Combat is being process around every 2000ms on my server. My thinking is that spells should not be processed any faster than that. I mean if you are processing combat at that rate, you should not want a spell firing off 8 times when combat is only processed once in the same amount of time.
Resident Dirty Hippy
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
Okay from doing a little bit of searching, in NPC_AI.cpp
BrainThink
That ProcessSpell returns a bool, that is where the check against the GetCastPercentage is done. Since BrainThink is called so much, that is the consideration here. Seems like that could need a change? On a large battle that seems like a ton of checks, not sure if it is needed just yet.
Also in NPC_AI, further down, this is where the GetCastPercentage is done.
BrainThink
Code: Select all
if(!m_body->IsCasting() && (!HasRecovered() || !ProcessSpell(target, distance))) {
LogWrite(NPC_AI__DEBUG, 7, "NPC_AI", "%s is attempting melee on %s.", m_body->GetName(), target->GetName());
m_body->FaceTarget(target);
ProcessMelee(target, distance);
}Also in NPC_AI, further down, this is where the GetCastPercentage is done.
Code: Select all
if(rand()%100 > m_body->GetCastPercentage() || m_body->IsStifled() || m_body->IsFeared())Resident Dirty Hippy
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
Looks like around line 42 of NPC_AI.cpp this should be changed.
Around line 100 I change it to look like this.
Code: Select all
m_spellRecovery = Timer::GetCurrentTime2();Code: Select all
if(!m_body->IsCasting()) {
LogWrite(NPC_AI__DEBUG, 7, "NPC_AI", "%s is attempting melee on %s.", m_body->GetName(), target->GetName());
m_body->FaceTarget(target);
ProcessMelee(target, distance);
if (HasRecovered)
ProcessSpell(target, distance);
}
Last edited by Gangrenous on Fri May 10, 2019 12:41 pm, edited 2 times in total.
Resident Dirty Hippy
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
That prevented the mob from being able to constantly cast, this stops it and makes it obey recast rules but the checks are still way too often. If there are 4 checks a second at maybe 5% it does not take any time at all to get a hit. If indeed the npc needs to get a spell roll check on every melee check then the spell chance needs to be a float and drop below 1%.
Resident Dirty Hippy
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
This helps spell it out.
Within 9 seconds it rolled below a 0 with a 1% spawn cast time. So if you take a simple mob that may cast something like poison, even at 1% chance it is going to be casting it very often if it has recovered from the spell.
You do not have the required permissions to view the files attached to this post.
Resident Dirty Hippy
- Gangrenous
- Posts: 812
- Joined: Sun Apr 24, 2016 6:54 am
- Characters: Dinsmoor
Re: NPC Spells Cast %
Well I also found that there is a crash in LuaFunctions when there is a spell call frequency is set, maybe special conditions but I need to go down this rabbit hole now.
This is after reverting past changes, so these are not related. It appears to be during removing a spell effect that is running per tick. Once the spell is wearing off and it tries to delete it, a crash.
Crashing at safe_delete(spell)
This is after reverting past changes, so these are not related. It appears to be during removing a spell effect that is running per tick. Once the spell is wearing off and it tries to delete it, a crash.
Code: Select all
void LuaInterface::DeletePendingSpells(bool all) {
MSpellDelete.lock();
if(spells_pending_delete.size() > 0){
int32 time = Timer::GetCurrentTime2();
map<LuaSpell*, int32>::iterator itr;
vector<LuaSpell*> tmp_deletes;
vector<LuaSpell*>::iterator del_itr;
for(itr = spells_pending_delete.begin(); itr != spells_pending_delete.end(); itr++){
if(all || time >= itr->second)
tmp_deletes.push_back(itr->first);
}
LuaSpell* spell = 0;
for(del_itr = tmp_deletes.begin(); del_itr != tmp_deletes.end(); del_itr++){
spell = *del_itr;
spells_pending_delete.erase(spell);
safe_delete(spell);
}
}
MSpellDelete.unlock();
}
You do not have the required permissions to view the files attached to this post.
Resident Dirty Hippy
Who is online
Users browsing this forum: No registered users and 0 guests