Jump to content

give an analysis of this code (Thank you)


AttePatte
 Share

Recommended Posts

on spawn of a zombie:
	if "%Spawn Reason%" is "Natural":
		wait 1 second
		loop zombies in radius 5 of last spawned zombie:
			loop all players:
				set path targets of loop-zombie to location of loop-player
				apply speed 1 without any particles to loop-zombie for 10 seconds
				if block below last spawned zombie is stone or deepslate or gravel:
					chance of 25%:
						kill the last spawned zombie
			
every 30 seconds in "world":
	loop all players:
		loop zombies in radius 75 of loop-player:
			set path targets of loop-zombie-1 to location of loop-player
			apply speed 2 without any particles to loop-zombie-1 for 10 seconds
			block below loop-zombie is stone or deepslate or gravel:
				chance of 25%:
					kill the loop-zombie

Im trying to avoid looping often, because it lags the server quite a lot. If you didn't get it already
I am trying to make it so zombies will start to pathfind towards the player as lag free as possible, but after
hours and hours this is the only one that works. Now I am a beginner at skript stuff and I don't know
many code languages. I have to loop the zombie every 30 seconds because they will only pathfind for like 3 seconds
and I have to keep making them pathfind. Now If I looped the zombies every 3 seconds it would kill the
server with lag in and with some players online in just 10 minutes or so. Any negative/positivie/negative feedback would
be kinda nice. Thanks. Bye

Link to comment
Share on other sites

There isn't (almost) any lag while there is only 1 player online.. could this be because the zombies have to pathfind to multiple players and its confusing it somehow and causing lag? I have no clue why this is the case, but I do know that looping tends to cause lag. I would like for anyone to comment on my post! Thank you

  • Like 1
Link to comment
Share on other sites

I kind of fixed it!. THANK YOU for replying. I just made it so it loops a random player out of all players
and then sets the path targets of the zombies to that player. It's not the same as the zombies going for all of the players at the same time, but it's something

Link to comment
Share on other sites

10 hours ago, AttePatte said:

I kind of fixed it!. THANK YOU for replying. I just made it so it loops a random player out of all players
and then sets the path targets of the zombies to that player. It's not the same as the zombies going for all of the players at the same time, but it's something

Great np for posting i saw it and thanks for clarifying its random but with alot of players theres going to be zombies pathfinding to more than 1 player at a time if thats how the skript is working which is what i see

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share



×
×
  • Create New...