BST/SMN mobs don't spawn pets

Forum rules
NO LONGER BEING MAINTAINED!
Post Reply
observor
Posts: 2
Joined: Wed Jul 23, 2014 10:47 pm

BST/SMN mobs don't spawn pets

Post by observor » Thu Feb 19, 2015 10:14 pm

Hi everyone.

I set up an instance of darkstar for some friends and we've been modifying it to our needs with great success, but this one has me a bit stumped.

BST/SMN/PUP enemies are spawned but they do not spawn pets. I've checked several mobs in the wild and none appear to be capable. This is an issue because a few of us would like to do the old fashioned BLM pet solo.

I've examined the scripts for each zone in attempting to find the cause of this and noticed that the luas for the appropriate mobs don't seem to have any actions that could spawn a pet. Also interesting (and very confusing to me) is that some zones (for example Newton Movalpolos) only have scripts for a very limited number of mobs (Newton Movalpolos only has a script for the Bugbear Matman) but the zones seem to spawn all of the appropriate mobs -- except for the pets.

I also looked in the mysql database for clues and it seems like values for setting up the pets are available to the server. I'm not too familiar with mysql so I haven't done much more than try to see what information is available.


At this point I'm asking for assistance in locating the (script? source?) where a pet-using mob attempts to spawn its pet in hopes of adding some print statements and figuring out where the problem is coming from. If anyone has any ideas about what could cause this I'd be delighted to hear them but I'm content to work on it on my own but just need some direction.

Thanks for reading.

observor
Posts: 2
Joined: Wed Jul 23, 2014 10:47 pm

Re: BST/SMN mobs don't spawn pets

Post by observor » Sat Feb 21, 2015 5:56 pm

So I've continued my search for a solution and found some code that looks relevant.

First:

Code: Select all

 225             if(m_PSpecialSkill != NULL && TrySpecialSkill())
 226             {
 227                 // I spawned a pet
 228             }
this is in darkstar/src/map/ai/ai_mob_dummy.cpp lines 225-228

It appears as though the mob checks to see whether it has a special ability and then carries it out.

Second:

Code: Select all

2121 bool CAIMobDummy::TrySpecialSkill()
2122 {
2123     if(m_PSpecialSkill == NULL) return false;
2124     if(!m_MobAbilityEnabled) return false;
2125
2126     if((m_PMob->m_specialFlags & SPECIALFLAG_HIDDEN) && !m_PMob->IsNameHidden())
2127     {
2128         return false;
2129     }
2130
2131     if(m_PSpecialSkill->getValidTargets() & TARGET_SELF)
2132     {
2133         m_PBattleSubTarget = m_PMob;
2134     }
2135     else if(m_PBattleTarget != NULL)
2136     {
2137         // distance check for special skill
2138         float currentDistance = distance(m_PMob->loc.p, m_PBattleTarget->loc.p);
2139
2140         if(currentDistance <= m_PSpecialSkill->getDistance())
2141         {
2142             m_PBattleSubTarget = m_PBattleTarget;
2143         }
2144         else
2145         {
2146             return false;
2147         }
2148     }
2149     else
2150     {
2151         return false;
2152     }
2153
2154     if(luautils::OnMobSkillCheck(m_PBattleSubTarget, m_PMob, m_PSpecialSkill) == 0)
2155     {
2156         ActionSpecialSkill();
2157         return true;
2158     }
2159
2160     return false;
2161 }
This is the same file, lines 2121-2161. It seems to be checking whether or not the mob is eligible to use its 'SpecialSkill' based on whether it's available, whether it's pointed towards an appropriate target, whether the target is in range, etc. I'm wondering if the self-targeting portion could be a potential source of the problem.

Third:

Code: Select all

163     int32 OnMobSkillCheck(CBaseEntity* PChar, CBaseEntity* PMob, CMobSkill* PMobSkill);                             //           triggers before mob weapon skill is used, returns 0 if the move is valid
This is in darkstar/src/map/lua/luautils.h line 163. It's the declaration for the function call on line 2154 in example #2.

Fourth:

Code: Select all

2783 int32 OnMobSkillCheck(CBaseEntity* PTarget, CBaseEntity* PMob, CMobSkill* PMobSkill)
2784 {
2785     lua_prepscript("scripts/globals/mobskills/%s.lua", PMobSkill->getName());
2786
2787     if (prepFile(File, "onMobSkillCheck"))
2788     {
2789         return 1;
2790     }
2791
2792     CLuaBaseEntity LuaBaseEntity(PTarget);
2793     Lunar<CLuaBaseEntity>::push(LuaHandle,&LuaBaseEntity);
2794
2795     CLuaBaseEntity LuaMobEntity(PMob);
2796     Lunar<CLuaBaseEntity>::push(LuaHandle,&LuaMobEntity);
2797
2798     CLuaMobSkill LuaMobSkill(PMobSkill);
2799     Lunar<CLuaMobSkill>::push(LuaHandle,&LuaMobSkill);
2800
2801     if( lua_pcall(LuaHandle,3,LUA_MULTRET,0) )
2802     {
2803         ShowError("luautils::onMobSkillCheck (%s): %s\n",PMobSkill->getName(), lua_tostring(LuaHandle,-1));
2804         lua_pop(LuaHandle, 1);
2805         return 1;
2806     }
2807     int32 returns = lua_gettop(LuaHandle) - oldtop;
2808     if (returns < 1)
2809     {
2810         ShowError("luautils::onMobSkillCheck (%s): 1 return expected, got %d\n", File, returns);
2811         return 0;
2812     }
2813     uint32 retVal = (!lua_isnil(LuaHandle,-1) && lua_isnumber(LuaHandle,-1) ? (int32)lua_tonumber(LuaHandle,-1) : -5);
2814     lua_pop(LuaHandle, 1);
2815     if (returns > 1)
2816     {
2817         ShowError("luautils::onMobSkillCheck (%s): 1 return expected, got %d\n", File, returns);
2818         lua_pop(LuaHandle, returns-1);
2819     }
2820     return retVal;
2821 }
This is in darkstar/src/map/lua/luautils.cpp lines 2783-2821. It is the actual function that performs the check to determine whether the specified 'SpecialSkill' can be used after the other checks. This seems like the most likely source of issues to me.


My first thought is to put print statements above each return statement in the second example but I am concerned that I will generate an enormous block of output from all the random checks that will be very difficult to parse for clues. I also don't have a machine available at the moment to try this out; there are regular users on the server and I don't want to kick them all off so I can break it repeatedly. :)

I will have a machine available soon but as you can see I'm still a bit uncertain about how best to go about this. If anyone has any particular insights or advice I'd appreciate them greatly.

Thanks for reading.

lautan
Developer
Posts: 164
Joined: Mon Jul 30, 2012 6:17 pm

Re: BST/SMN mobs don't spawn pets

Post by lautan » Sun Mar 22, 2015 7:05 pm

This still an issue? I was the one who implemented this.

User avatar
maxtherabbit
Developer
Posts: 57
Joined: Wed Jun 12, 2013 11:26 pm

Re: BST/SMN mobs don't spawn pets

Post by maxtherabbit » Sun Mar 22, 2015 7:12 pm

welcome back lautan

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: BST/SMN mobs don't spawn pets

Post by whasf » Sun Mar 22, 2015 7:21 pm

lautan wrote:This still an issue? I was the one who implemented this.
Yeah it's been broken for a while.
-- Whasf

lautan
Developer
Posts: 164
Joined: Mon Jul 30, 2012 6:17 pm

Re: BST/SMN mobs don't spawn pets

Post by lautan » Sat Apr 04, 2015 11:20 pm

This is now fixed.

Post Reply