mobs lua onMobInitialize functions not working

Post Reply
vergotear
Posts: 5
Joined: Wed Apr 03, 2013 5:17 pm

mobs lua onMobInitialize functions not working

Post by vergotear » Sat Jul 13, 2013 5:43 am

I tried to script a few NM pops that weren't scripted.
Some of them are just copy paste from other mobs / npc lua files with just the mobid changed.
trade, spawning and starting enmity from qmx.lua works. OnEngage or Onfight functions like popping pets work, hiding pop spot after mob dead too.
But noticed that stuff in onMobInitialize didn't work, like

Code: Select all

-----------------------------------
-- onMobInitialize Action
-----------------------------------
function onMobInitialize( mob )
    -- Add regen and gain effects..
	mob:addStatusEffect( EFFECT_REGEN, 50, 3, 0 );
	mob:addStatusEffect( EFFECT_REGAIN, 7, 3, 0 );
end
Then I went and fought NMs like Nidhogg with those kind of passive buffs and yes it didn't regen or tp regain, and it seems to be the case with all mob luas.

Currently using a build of rev 3707 on local test server. Using Visual Studio 2010 express to compile.
Edit: even with a clean download from SVN, build and sql tables, mobs aren't receiving the effects in onMobInitialize.

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

Re: mobs lua onMobInitialize functions not working

Post by lautan » Sat Jul 13, 2013 12:35 pm

I made some changes recently and status effects should not be added on mob initialize. You could add them on mob spawn but native status effects shouldn't be added in lua. These have to be added in the mob_pool_mods table. I have moved some of them myself but haven't moved them all.

Edit: I should clarify status effects are removed before a mob spawns. This is to prevent duplicate status effects from leaking in. Adding status effects in onMobSpawn will work fine.

vergotear
Posts: 5
Joined: Wed Apr 03, 2013 5:17 pm

Re: mobs lua onMobInitialize functions not working

Post by vergotear » Sat Jul 13, 2013 2:06 pm

Ok thanks for the clarification.
But looking at the mobs lua, there's quite a number of mobs that will need fixing or adding to the mob_pool_mods.
And now looking at the mob_pool_mods. The ModId which numbers or file should i use for reference, the same ones for items?

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: mobs lua onMobInitialize functions not working

Post by kjLotus » Sat Jul 13, 2013 3:42 pm

lautan wrote:I made some changes recently and status effects should not be added on mob initialize. You could add them on mob spawn but native status effects shouldn't be added in lua. These have to be added in the mob_pool_mods table. I have moved some of them myself but haven't moved them all.

Edit: I should clarify status effects are removed before a mob spawns. This is to prevent duplicate status effects from leaking in. Adding status effects in onMobSpawn will work fine.
still want oninitialize to work, there are other things that can be useful for that

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: mobs lua onMobInitialize functions not working

Post by atom0s » Mon Jul 15, 2013 1:03 pm

Spawning mobs should just call both onMobInitialize then onMobSpawn to rectify the issue. As it stands now onMobInitialize only happens once when zones are loaded, defeating the current purpose of the function. Most HNMs are currently using onMobInitialize to set Regen/Regain/etc. buffs and stuff that wont be reapplied on respawns.

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: mobs lua onMobInitialize functions not working

Post by kjLotus » Mon Jul 15, 2013 1:29 pm

atom0s wrote:Spawning mobs should just call both onMobInitialize then onMobSpawn to rectify the issue. As it stands now onMobInitialize only happens once when zones are loaded, defeating the current purpose of the function.
that's exactly what initialize is for - applying things that should only be applied once, such as setting up links or setting up monster vars

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: mobs lua onMobInitialize functions not working

Post by atom0s » Tue Jul 16, 2013 9:24 am

Sounds more like things don't save after the first death though.

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: mobs lua onMobInitialize functions not working

Post by kjLotus » Tue Jul 16, 2013 9:42 am

atom0s wrote:Sounds more like things don't save after the first death though.
everything is saved unless it's a status effect or explicitly removed in the death script. in the case of the OP, i think someone just broke onMobInitialize or something

Post Reply