3P Maps

Started by ThirdParty, October 21, 2013, 10:02:06 PM

Previous topic - Next topic

Azraile

Have you tested the script on 252x252 maps before?

J

If the map is too large, the script will be stopped when it reaches the limit of opcodes. If you still can optimize the script or add '1 Delay' somewhere in the loop.

Azraile

I don't know enough about the scrip stuff to fix something like that, I'll see if the 1 dillay works though

Azraile

where would the 1 delay go?

J

Added an extra line of code to the script in the quote to make it wait one frame halfway, note that this makes it look worse but it hopefully fixes your problem. I didn't test it.
Quote from: ThirdParty on May 14, 2014, 09:43:24 PM
No.  You want:# Ocean.crpl
# Created by: ThirdParty
# Created on: 10/15/2013
# ------------------------------------------
$currentTide:15

once
CreateList ->edgeListX
CreateList ->edgeListY
do(MapHeight 0)
do(MapWidth 0)
# The edges of the map have been marked with walls.
# Note that the edge list must be built in the final version, it can't be stored in advance.
if(i eq0 or(j eq0) or(i eq(MapWidth sub(1))) or(j eq(MapHeight sub(1))))
AppendToList(<-edgeListX i) AppendToList(<-edgeListY j)
endif

# All low-lying areas should begin the game flooded.
if(not(GetVoid(i j)))
SetCreeper(i j max(sub(<-currentTide GetTerrain(i j)) 0))
endif
loop
if(I floor(MapHeight 2 div) eq) 1 Delay endif
loop
endonce

# Seepage to/from edges.  Note that this needs to be done every frame or we get annoying flickering.
do(GetListCount(<-edgeListX) 0)
GetListElement(<-edgeListX i) ->tX
GetListElement(<-edgeListY i) ->tY
SetCreeper(
<-tX <-tY
add(
mul(GetCreeper(<-tX <-tY) 0.96)
mul(max(sub(<-currentTide GetTerrain(<-tX <-tY)) 0) 0.04)
)
)
loop


Azraile

nope still only fills down to about 100 out of 256 on the map x.x

J

Only to about 100? That fix was only for if it got past ~130. Added 2 more wait spots, that should work better, but looks even worse :P
Quote from: ThirdParty on May 14, 2014, 09:43:24 PM
No.  You want:# Ocean.crpl
# Created by: ThirdParty
# Created on: 10/15/2013
# ------------------------------------------
$currentTide:15

once
CreateList ->edgeListX
CreateList ->edgeListY
do(MapHeight 0)
do(MapWidth 0)
# The edges of the map have been marked with walls.
# Note that the edge list must be built in the final version, it can't be stored in advance.
if(i eq0 or(j eq0) or(i eq(MapWidth sub(1))) or(j eq(MapHeight sub(1))))
AppendToList(<-edgeListX i) AppendToList(<-edgeListY j)
endif

# All low-lying areas should begin the game flooded.
if(not(GetVoid(i j)))
SetCreeper(i j max(sub(<-currentTide GetTerrain(i j)) 0))
endif
loop
if(I floor(MapHeight 2 div) eq I floor(MapHeight 4 div) eq or I floor(MapHeight 4 div 3 mul) eq or) 1 Delay endif
loop
endonce

# Seepage to/from edges.  Note that this needs to be done every frame or we get annoying flickering.
do(GetListCount(<-edgeListX) 0)
GetListElement(<-edgeListX i) ->tX
GetListElement(<-edgeListY i) ->tY
SetCreeper(
<-tX <-tY
add(
mul(GetCreeper(<-tX <-tY) 0.96)
mul(max(sub(<-currentTide GetTerrain(<-tX <-tY)) 0) 0.04)
)
)
loop


btw, 2000 posts!

Azraile

woot...

and looks don't mater if it works.

Azraile

AWSOME it works... it makes some 'waves' of sorts but they fade away quickly eugh

Grayzzur

Quote from: Azraile on May 20, 2014, 03:52:20 PM
AWSOME it works... it makes some 'waves' of sorts but they fade away quickly eugh
Right. There's a limit to how many CRPL opcodes the game engine will run each frame. It cuts you off when you pass that, which caused your script to simply stop. The "1 delay" command puts off the rest of the script until the next game frame, when your limit is reset. So yes, it will look like waves. If your loops are that big and there's no way to optimize them, then the wave effect with the delay is the only workaround.

That's in there to keep a bad CRPL core from locking up the entire game engine and making the game freeze/crash.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Lost in Nowhere

Of course, you could also divide up the operations between multiple cores so that none of them go over the limit, but that has a tendency to be difficult to get to work and/or cause excessive lag.
Don't die! :)