Jump to content

TheCodingDuck_

Member
  • Posts

    95
  • Joined

  • Last visited

Posts posted by TheCodingDuck_

  1. 13 hours ago, AttePatte said:

    Thank you for replying and for your time. The skript is very embarassing and it has a lot of nonsense which you will laugh at.

    I would be super thankful if you could tell me a better way to approach this lag problem so we could find a solution. I have been so far just lowering numbers, adding 'kill the loop-zombie' and 'if' statements all over the skript. It is VERY impractical and I know I have been looking at this the wrong way and REPEATING the same pattern that leads to this very laggy code. I sometimes think that it's ridiculous how I keep on working on this same zombie skript while the answer could be obvious. On the other hand I think that pathfinding is not working that well but why does it lag when there are more than 2-3 players? So I deeply apologise for the horrible mess I have created and spent my time on... maybe I just wanted to create something special and enjoyable, something fun! I think that end goal blinded me the goal of making a server which people enjoy hours upon hours a day. So i think that lead me to use the same laggy methods that ended me with this code. 

    So again. That is why it is so horrible and that is WHY I want YOU to consider these mentioned things before you laugh at me, before you laugh at this. I have worked on other things such as scoreboards, abilities with cooldowns so I have not wasted all of my time on this. 

    every 20 seconds in "world": #If i have it pathfinding zombies every second it will lag... obviosly and this is a poor method. The zombies aren't pathfinding all the time just
    	set {p} to a random player out of all players
    	loop zombies in radius 55 of {p}: #The radius has varied from 35 to 65 but I suspect that it affects performance
    		if {p}'s world is not "nether" or "the_end": #This is so that it doesn't make zombies pathfind to somewhere that isn't the overworld
    			if distance between {p} and loop-zombie is greater than 15: #pretty obvious, but it's so that it doesn't make zombies that are close pathfind for no reason
    				if distance between {p} and loop-zombie is greater than 60: #This is so that zombies in caves or far away would 'despawn'
    					chance of 25%: #i put this for... idk
    						kill the loop-zombie
    				if block below loop-zombie is stone or Deepslate or Tuff or Cobbled Deepslate: #so zombies underground wouldn't multiply to hundreds but instead courages the zombies to spawn and multiply aboveground
    					chance of 25%:
    						kill the loop-zombie
    				if distance between {p} and loop-zombie is less than 60: #I think what affects performance is zombies having to pathfind from far away..?
    					set path targets of loop-zombie to location of {p} #This, I think is SkBee method
    					apply speed 3 without any particles to loop-zombie for 16 seconds
    					chance of 25%:
    						summon 2 zombies at location of loop-zombie #Multiply thingie
    						wait 3 minutes #For example if zombies have been around one player for too long they will die thus allowing zombies to spawn near other players
    						kill the loop-zombie #This whole code works with few players, desirably with 10 or less but as said it starts to lag at 3+ players

     

    I'll attempt to improve this for you, untested btw

    on join:
    	while player is online: # Will have a constant loop until they leave, waiting the time specified below
    		wait 1 second
    		world of player isn't "nether" or "the_end"
    		loop all zombies:
    			abs((x-coordinate of player)-(x-coordinate of loop-value)) < 50 # The radius, absolute value of player's x - abs of zombie's x
    			                                                                # EX: abs(50-60) would be abs(-10) which is 10 distance
    			abs((z-coordinate of player)-(z-coordinate of loop-value)) < 50 # same for z value
    			
    			# The zombie is within 50 blocks
    			set path targets of loop-value to player
    			apply speed 3 without any particles to loop-value for 16 seconds
    			set {_} to random number between 1 and 100 # Using "chance of" with skript is a horrible idea, instead check if {_} is between 1 and x
    			if {_} is between 1 and 2: # 2% start chance, edit if you want, this triggers every second so would recommend this or below
    									   # Not required to be an integer, 2.63 is valid for example. Anything more than 2 decimals is ignored. 
    				summon 1 zombie at location of loop-value #Multiply thingie

     

  2. There should be an item in your inventory which you can right click to continue to your server. This SHOULD only happen once a day and is just a minor inconvenience that helps keep Minehut free for anyone.

×
×
  • Create New...