Check if there are mobs alive
#1
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.
Reply
Thanks given by:
#2
i think OnTick do ForEachEntity and then if Entity:IsMob() then do some checking with Entity:GetUniqueID()
Reply
Thanks given by:
#3
(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?
Reply
Thanks given by:
#4
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 )
Reply
Thanks given by:
#5
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
Reply
Thanks given by:
#6
(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.
Reply
Thanks given by:
#7
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
Reply
Thanks given by:
#8
function OnTick()
	local LoopEntitys = function( Entity )
		if Entity:IsMob() then
			 --some code--
			 end
		else
                         wawe=2
	                 end
                end
         end
end
Shall it work?
Reply
Thanks given by:
#9
well now it is
if Entity:IsMob() then
   --the entity is a mob
else
   --the entity is not a mob
end
Reply
Thanks given by:
#10
What does Entity:GetUniqueID()? Does it get the network id of the mob?
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)