[bb] Crater Code by H. T. U. [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:38

Previous topic - Next topic

BlitzBot

Title : Crater Code
Author : H. T. U.
Posted : 1+ years ago

Description : A handy function that easily makes a nice round crater.  Assumes terrain sections are 1x1 Blitz units (add Step to change).  Also fun to tinker with, and easy to add particles, crater ring, etc.

entity=entity crater is created around
terrain=terrain in which the crater is formed
radius=crater's radius (default is 1)
th=maximum height of any terrain section (default is 100)
hardness=hardness of the ground, 1 is completely soft, 0 is completely solid (default is 1)


Code :
Code (blitzbasic) Select
Function crater(entity,terrain,radius#=1,th#=100,hardness#=1)
ex#=EntityX(entity)
ez#=EntityZ(entity)

For x=-radius To radius
For z=-radius To radius
If Sqr(x*x+z*z)<=radius And hardness<>0
d#=Sqr(x*x+z*z)

h#=TerrainHeight(terrain,ex+x,ez+z)

scale#=th/hardness

h=h+d/scale-radius/scale
If h<0 Then h=0
ModifyTerrain terrain,ex+x,ez+z,h,True
EndIf
Next
Next
End Function


Comments :


Guy Fawkes(Posted 1+ years ago)

 Nice man! =) Been lookin for 1 of these forever! =D Thanks man! =)~DarkShadowWing~