Detecting if a mob is spawned

Post Reply
Joe
Posts: 33
Joined: Sun Jan 20, 2013 4:18 pm

Detecting if a mob is spawned

Post by Joe » Wed Jan 30, 2013 10:10 am

Is there any way to detect whether a particular mob has been spawned? I've been trying to figure it out and am currently stumped... I would greatly appreciate any info to get me pointed in the right direction. Thanks.

Joe
Posts: 33
Joined: Sun Jan 20, 2013 4:18 pm

Re: Detecting if a mob is spawned

Post by Joe » Wed Jan 30, 2013 4:01 pm

I'm no longer stuck on this as I figured out a way around my problem from earlier, but if anyone knows if detecting whether certain mobs are spawned via a Lua script is possible I'd still like to know how...

Thanks.

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

Re: Detecting if a mob is spawned

Post by kjLotus » Wed Jan 30, 2013 4:49 pm

all the commands that can be done to a baseentity (mobs included) are in lua_baseentity.h. if there isn't one, you'd have to make your own binding for it (which isn't really too hard: copy and paste something else related to mobs, add a line in .h and the lunar declares at the bottom of the .cpp, and then find a way to find if it's dead or not in the core. likely something to do with their current ACTION or animation)

sorry i don't have anything better to offer, i don't really deal much in the way of mobs in the scripts

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: Detecting if a mob is spawned

Post by PrBlahBlahtson » Wed Jan 30, 2013 7:49 pm

GetMobAction(########) might work for you.

See the qm1 in Dragon's Aery for ways this can be used. If you need to check what's returned from a mob, I usually just modify Cure or something to print(GetMobAction(#)) and check my server log. There's names for the different states somewhere in the core. I believe they all start with ACTION_

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

Re: Detecting if a mob is spawned

Post by kjLotus » Wed Jan 30, 2013 8:31 pm

PrBlahBlahtson wrote: There's names for the different states somewhere in the core. I believe they all start with ACTION_
correct

ai_general.h line 37

Joe
Posts: 33
Joined: Sun Jan 20, 2013 4:18 pm

Re: Detecting if a mob is spawned

Post by Joe » Wed Jan 30, 2013 9:57 pm

I really appreciate the responses, my earlier 'fix' didn't end up working out and I was back to detecting if the mobs had been spawned. Was planning on adding a new binding but noticed the other posts concerning GetMobAction... GetMobAction( mobid) == ACTION_NONE worked perfectly! Thanks!

Post Reply