Cuberite Forum

Full Version: Check if there are mobs alive
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
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.
i think OnTick do ForEachEntity and then if Entity:IsMob() then do some checking with Entity:GetUniqueID()
(05-06-2013, 09:30 PM)STR_Warrior Wrote: [ -> ]i think OnTick do ForEachEntity and then if Entity:IsMob() then do some checking with Entity:GetUniqueID()
Sorry but I'm a noob and I don't understand it. How do i do it?
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 Wink )
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:38 PM)STR_Warrior Wrote: [ -> ]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
But, 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.
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
function OnTick()
	local LoopEntitys = function( Entity )
		if Entity:IsMob() then
			 --some code--
			 end
		else
                         wawe=2
	                 end
                end
         end
end
Shall it work?
well now it is
if Entity:IsMob() then
   --the entity is a mob
else
   --the entity is not a mob
end
What does Entity:GetUniqueID()? Does it get the network id of the mob?
Pages: 1 2 3