Making Terrain using CPRL

Started by Someone, October 12, 2013, 05:42:57 AM

Previous topic - Next topic

Someone

is it possible for us to make a new terrain in a void using CPRL??

J


Someone

#2
can you give me the script?

J

Simply use the SetTerrain command, works fine no matter if the cell was void or terrain before calling the command.

Someone

set terrain is     x1 y1 n1 –  right?
so if we take 52,83 and height is 5
then

52 83 5 -

??

J

x y height SetTerrain
52 83 5 SetTerrain

Someone

oh wow,so the "-" is the place to put command

and what should i use ,when i put a unit on the core,the other command will active? use if ?

MagmaMcFry

#7

CurrentCoords 0 GetUnitCountInRange neq0 if
52 83 5 SetTerrain
100000 delay
endif


Using warp notation:


if (GetUnitCountInRange(CurrentCoords 0) neq0)
SetTerrain(52 83 5)
delay(100000)
endif

Crimson King

I'm looking at creating a script that can raise or lower terrain by 1 level in square big enough for a single unit. What I'd like it to do is have it pick random coords and raise or lower the terrain if the height is not equal to 5. How would I go about this?

albrittbrat

I believe this should do the trick, though I haven't tested it.
terrange is the range from the current coordinates of the CRPL tower
terrlevel is the level to set the terrain to
the code for the loop to set the terrain in a 3x3 is taken from Virgil's example code on the 'SetDigitalis' page on the wiki link

# Choose random coordinates in a specified range of current coordinates
# Set terrain in 3x3 square around chosen coordinates to 5 height
#------------------------------------------------------------------
$terrange:10
$terrlevel:5
CurrentCoords <-terrange RandCoordsInRange ->randCoords
<-randCoords ->randX ->randY
<-randY 2 add <-RandY 1 sub do
     <-randX 2 add <-randX 1 sub do
          I J <-terrlevel SetTerrain
     Loop
Loop

J

That shouldn't work. Change:
CurrentCoords <-terrange RandCoordsInRange ->randCoords
<-randCoords ->randX ->randY
to:
CurrentCoords <-terrange RandCoordsInRange ->randY ->randX

Crimson King

It works but it doesn't. It picks a random location and it changes the terrain height but it doesn't do a 3x3 square. I get columns drawn from the top of the map to the random coords.

J

Then change:

<-randY 2 add <-RandY 1 sub do
     <-randX 2 add <-randX 1 sub do
          I J <-terrlevel SetTerrain
     Loop
Loop
to:
<-RandX <-RandY <-terrlevel SetTerrain
<-RandX <-RandY 1 sub <-terrlevel SetTerrain
<-RandX <-RandY 1 add <-terrlevel SetTerrain
<-RandX 1 sub <-RandY <-terrlevel SetTerrain
<-RandX 1 sub <-RandY 1 sub <-terrlevel SetTerrain
<-RandX 1 sub <-RandY 1 add <-terrlevel SetTerrain
<-RandX 1 add <-RandY <-terrlevel SetTerrain
<-RandX 1 add <-RandY 1 sub <-terrlevel SetTerrain
<-RandX 1 add <-RandY 1 add <-terrlevel SetTerrain

kwinse

#13
Crimson King kept talking in my ear so I took a stab at one of his ideas:
$terrange:20
CurrentCoords <-terrange RandCoordsInRange ->randY ->randX
<-randX <-randY GetTerrain ->terrlevel
0 2 RandInt ->updown
<-updown 0 eq if
-1 ->updown
endif
<-terrlevel <-updown add ->terrlevel
<-terrlevel 1 max ->terrlevel
<-randX <-randY <-terrlevel SetTerrain
<-randX 1 add <-randY <-terrlevel SetTerrain
<-randX 2 add <-randY <-terrlevel SetTerrain
<-randX <-randY 1 add <-terrlevel SetTerrain
<-randX 1 add <-randY 1 add <-terrlevel SetTerrain
<-randX 2 add <-randY 1 add <-terrlevel SetTerrain
<-randX <-randY 2 add <-terrlevel SetTerrain
<-randX 1 add <-randY 2 add <-terrlevel SetTerrain
<-randX 2 add <-randY 2 add <-terrlevel SetTerrain
20 delay

Picks a random cell within $terrange, and sets the terrain height of a 3x3 cell to +1 or -1 of the random cell's height. I used upper left instead of center though (I unrolled the the loop before I saw your latest post J). Not that it matters much.

J

If you replace your replacement with mine it should take the center cell.