05-06-2013, 09:28 PM
I want to make a mob survival plugin, and I want it to check if there are any mob alive, and if no, set wawe to 2.
Check if there are mobs alive
|
05-06-2013, 09:28 PM
I want to make a mob survival plugin, and I want it to check if there are any mob alive, and if no, set wawe to 2.
05-06-2013, 09:30 PM
i think OnTick do ForEachEntity and then if Entity:IsMob() then do some checking with Entity:GetUniqueID()
05-06-2013, 09:33 PM
05-06-2013, 09:38 PM
OnTick() shouldn't do a ForEach anything, because that could slow the server down considerably.
I think you should wait with this plugin until there's proper mob AI, because then we'll have a full set of hooks for all entity-related needs, such as OnMobSpawning() etc. Another idea that could work even now is to count all the mobs at one moment with ForEachEntity(), then subtract one from this counter each time a mob is killed (OnTakeDamage() when damage is more than life left). This should give you a pretty accurate picture, providing that mobs don't spawn in the meantime. Anyway, still there's no way for you to disable mob spawning or to spawn more mobs from a plugin, so, as I said, better wait (and give Keyboard some motivation to do the AI )
05-06-2013, 09:38 PM
something like this
function OnTick() local LoopEntitys = function( Entity ) if Entity:IsMob() then if Entity:GetUniqueID() == "Something" --something here to check if it is the right mob. some code here to do stuff end end end end
05-06-2013, 09:42 PM
(05-06-2013, 09:38 PM)STR_Warrior Wrote: something like thisBut, I want to check if there isn't any mob and then execute the code I want. I think this code is for check if there is any mob, and if there is at least one, execute some code.function OnTick() local LoopEntitys = function( Entity ) if Entity:IsMob() then if Entity:GetUniqueID() == "Something" --something here to check if it is the right mob. some code here to do stuff end end end end
05-06-2013, 09:45 PM
you can make it coun't back until there is 0 but as xoft said you'd better wait until there is a better AI
05-07-2013, 12:00 AM
function OnTick() local LoopEntitys = function( Entity ) if Entity:IsMob() then --some code-- end else wawe=2 end end end endShall it work?
05-07-2013, 12:03 AM
well now it is
if Entity:IsMob() then --the entity is a mob else --the entity is not a mob end
05-07-2013, 02:30 AM
What does Entity:GetUniqueID()? Does it get the network id of the mob?
|
« Next Oldest | Next Newest »
|