Cuberite Forum
Check if there are mobs alive - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Check if there are mobs alive (/thread-874.html)

Pages: 1 2 3


Check if there are mobs alive - tonibm19 - 05-06-2013

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.


RE: Check if there are mobs alive - NiLSPACE - 05-06-2013

i think OnTick do ForEachEntity and then if Entity:IsMob() then do some checking with Entity:GetUniqueID()


RE: Check if there are mobs alive - tonibm19 - 05-06-2013

(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?


RE: Check if there are mobs alive - xoft - 05-06-2013

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 )


RE: Check if there are mobs alive - NiLSPACE - 05-06-2013

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



RE: Check if there are mobs alive - tonibm19 - 05-06-2013

(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.


RE: Check if there are mobs alive - NiLSPACE - 05-06-2013

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


RE: Check if there are mobs alive - tonibm19 - 05-07-2013

function OnTick()
	local LoopEntitys = function( Entity )
		if Entity:IsMob() then
			 --some code--
			 end
		else
                         wawe=2
	                 end
                end
         end
end
Shall it work?


RE: Check if there are mobs alive - NiLSPACE - 05-07-2013

well now it is
if Entity:IsMob() then
   --the entity is a mob
else
   --the entity is not a mob
end



RE: Check if there are mobs alive - tonibm19 - 05-07-2013

What does Entity:GetUniqueID()? Does it get the network id of the mob?