Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.70 KB | None | 0 0
  1. @name Forest Gen
  2. @inputs
  3. @outputs CurrentCount Cleanup [AllProps For]:array
  4. @persist [For SnowArray GrassArray Exist AllProps]:array Gen A A2 Radius Count Grass Snow IX
  5. @trigger
  6.  
  7. runOnTick(1)
  8. runOnChat(1)
  9.  
  10. E=entity()
  11.  
  12. if(first()|dupefinished())
  13. {
  14. #For:pushString("models/foliage/tree01.mdl")
  15. #For:pushString("models/foliage/tree05.mdl")
  16. #For:pushString("models/foliage/tree10.mdl")
  17. #For:pushString("models/foliage/tree11.mdl")
  18. #For:pushString("models/foliage/tree12.mdl")
  19. #For:pushString("models/foliage/tree13.mdl")
  20. #For:pushString("models/foliage/tree15.mdl")
  21. For:pushString("models/foliage/bush01.mdl")
  22. For:pushString("models/foliage/bush01b.mdl")
  23. For:pushString("models/foliage/bush01c.mdl")
  24. SnowArray:pushString("models/foliage/pine_2m.mdl")
  25. SnowArray:pushString("models/foliage/pine_3m.mdl")
  26. SnowArray:pushString("models/foliage/pine_7m.mdl")
  27. SnowArray:pushString("models/foliage/pine_9m.mdl")
  28. GrassArray:pushString("models/props_foliage/ah_grass_512x512_001.mdl")
  29. #GrassArray:pushString("models/props_foliage/ah_grass_512x512_001_flowers.mdl")
  30.  
  31. Count=256
  32. Radius=4096
  33. Grass=0
  34. Snow=0
  35. }
  36.  
  37. if(chatClk(owner()))
  38. {
  39. if(owner():lastSaid():lower()=="!gen")
  40. {
  41. hideChat(1)
  42. if(!Gen)
  43. {
  44. print("Generating...")
  45. Gen=1
  46. A=0
  47. }
  48. else
  49. {
  50. print("Already Generating")
  51. }
  52.  
  53. timer("ErrorCheck",8128*4)
  54. }
  55.  
  56. if(owner():lastSaid():lower()=="!stop")
  57. {
  58. hideChat(1)
  59. print("Generation Stopped")
  60. Gen=0
  61. A=0
  62. }
  63.  
  64. if(owner():lastSaid():lower()=="!clean")
  65. {
  66. hideChat(1)
  67. Cleanup=1
  68. Gen=0
  69. A=0
  70. }
  71.  
  72. if(owner():lastSaid():lower():sub(1,7)=="!count ")
  73. {
  74. hideChat(1)
  75. if(!Gen)
  76. {
  77. Count=clamp(owner():lastSaid():lower():sub(8):toNumber(),16,1024)
  78. print("Count changed to "+Count)
  79. }
  80. else
  81. {
  82. print("You can't change that while generating!")
  83. }
  84. }
  85.  
  86. if(owner():lastSaid():lower():sub(1,8)=="!radius ")
  87. {
  88. hideChat(1)
  89. if(!Gen)
  90. {
  91. Radius=clamp(owner():lastSaid():lower():sub(9):toNumber(),16,16384)
  92. print("Radius changed to "+Radius)
  93. }
  94. else
  95. {
  96. print("You can't change that while generating!")
  97. }
  98. }
  99. }
  100.  
  101. if(changed(Gen)&!Gen)
  102. {
  103. Exist:clear()
  104. A=0
  105. }
  106.  
  107. if(Gen)
  108. {
  109. if(Exist:count()<Count){if(findCanQuery()){A+=1}}
  110. else{print("Done "+AllProps:count()) Gen=0 stoptimer("ErrorCheck")}
  111.  
  112. if(changed(A))
  113. {
  114. for(I=A,A)
  115. {
  116. if(Grass)
  117. {
  118. rangerHitEntities(0)
  119. rangerHitWater(1)
  120. Vec=E:pos()+vec(randint(-Radius,Radius),randint(-Radius,Radius),1024)
  121. Rang=rangerOffset(50000,Vec,vec(0,0,-1))
  122. Pos=Rang:pos()
  123. Z=clamp((1-(Rang:hitNormal():z())*320),-2,8)
  124. #Z=0
  125. findIncludeClass("gmod_wire_hologram")
  126. findInSphere(Pos,256)
  127. Closest=findClosest(Pos)
  128. Distance=round(Closest:pos():distance(Pos))
  129. #Closest:setColor(vec(255,0,0))
  130.  
  131. if(Pos:isInWorld())
  132. {
  133. if(Distance>128)
  134. {
  135. if(Rang:hitTexture()=="**displacement**")
  136. {
  137. if(positive(Rang:hitNormal()):z()>=0.2)
  138. {
  139. if(Rang:matType()=="grass")
  140. {
  141. if(holoCanCreate())
  142. {
  143. A2+=1
  144. Holo=holoCreate(A2,Pos-vec(0,0,Z),vec(1),Rang:hitNormal():toAngle()+ang(90,0,randint(0,0)),vec(255),GrassArray[randint(1,GrassArray:count()),string])
  145. #holoAng(A2,holoEntity(A2):angles():setYaw(randint(0,360)))
  146. Exist:insertEntity(1,Holo)
  147. AllProps:insertEntity(1,Holo)
  148. stoptimer("ErrorCheck")
  149. timer("ErrorCheck",8128*4)
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
  157. elseif(Snow)
  158. {
  159. rangerHitEntities(0)
  160. rangerHitWater(1)
  161. Vec=E:pos()+vec(randint(-Radius,Radius),randint(-Radius,Radius),1024)
  162. Rang=rangerOffset(50000,Vec,vec(0,0,-1))
  163. Pos=Rang:pos()
  164. Z=clamp((1-Rang:hitNormal():z())*360,6,36)
  165. findIncludeClass("prop_physics")
  166. findInSphere(Pos,1024)
  167. Closest=findClosest(Pos)
  168. Distance=round(Closest:pos():distance(Pos))
  169.  
  170. if(Pos:isInWorld()&Pos:z()>E:pos():z())
  171. {
  172. if(Distance>(Closest:boxSize():x()+Closest:boxSize():y())/3)
  173. {
  174. #print(Rang:hitTexture())
  175. if(Rang:hitTexture()=="**displacement**")
  176. {
  177. #print(positive(Rang:hitNormal()))
  178. if(positive(Rang:hitNormal()):z()>=0.9)
  179. {
  180. if(Rang:matType()=="snow")
  181. {
  182. if(propCanCreate())
  183. {
  184. Prop=propSpawn(SnowArray[randint(1,SnowArray:count()),string],Pos-vec(0,0,Z),ang(randint(-2.5,2.5),randint(0,360),randint(-2.5,2.5)),1)
  185. Prop:setSkin(2)
  186. Prop:setColor(255,0,0)
  187. Exist:insertEntity(1,Prop)
  188. AllProps:insertEntity(1,Prop)
  189. stoptimer("ErrorCheck")
  190. timer("ErrorCheck",8128*4)
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. else
  199. {
  200. rangerHitEntities(0)
  201. rangerHitWater(1)
  202. Vec=E:pos()+vec(randint(-Radius,Radius),randint(-Radius,Radius),1024)
  203. Rang=rangerOffset(50000,Vec,vec(0,0,-1))
  204. Pos=Rang:pos()
  205. Z=clamp((1-Rang:hitNormal():z())*360,-4,8)
  206. findIncludeClass("prop_physics")
  207. findInSphere(Pos,1024)
  208. Closest=findClosest(Pos)
  209. Distance=round(Closest:pos():distance(Pos))
  210.  
  211. if(Pos:isInWorld())
  212. {
  213. if(Distance>((Closest:boxSize():x()+Closest:boxSize():y())/5))
  214. {
  215. #print(Rang:hitTexture())
  216. if(Rang:hitTexture()=="**displacement**")
  217. {
  218. #print(positive(Rang:hitNormal()))
  219. if(positive(Rang:hitNormal()):z()>=0.9)
  220. {
  221. if(Rang:matType()=="grass")
  222. {
  223. if(propCanCreate())
  224. {
  225. RAN=randint(1,For:count())
  226. if(RAN==1)
  227. {
  228. Z=-16
  229. }
  230. elseif(RAN==3)
  231. {
  232. Z=72
  233. }
  234. elseif(RAN==4)
  235. {
  236. Z=36
  237. }
  238. elseif(RAN==5)
  239. {
  240. Z=64
  241. }
  242. #Prop=propSpawn(For[RAN,string],Pos+vec(0,0,Z),ang(randint(-2.5,2.5),randint(0,360),randint(-2.5,2.5)),1)
  243. Prop=propSpawn("models/props_junk/PopCan01a.mdl",Pos-vec(0,0,16),ang(randint(-2.5,2.5),randint(0,360),randint(-2.5,2.5)),1)
  244. IX+=1
  245. #Entity=holoCreate(number index,vector position,vector scale,angle ang,vector color,string model)
  246. holoCreate(IX,Prop:pos(),vec(1),Prop:angles(),vec(255),For[RAN,string])
  247. Prop:setColor(vec(255,0,0))
  248. Exist:insertEntity(1,Prop)
  249. AllProps:insertEntity(1,Prop)
  250. stoptimer("ErrorCheck")
  251. timer("ErrorCheck",8128*4)
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }
  261.  
  262. if(clk("ErrorCheck"))
  263. {
  264. print("Error: Ran out of areas to generate in")
  265. print("Generation Stopped at "+AllProps:count()+" props")
  266. Gen=0
  267. }
  268. }
  269.  
  270. if(Cleanup)
  271. {
  272. if(AllProps:count())
  273. {
  274. AllProps[1,entity]:propDelete()
  275. AllProps:shift()
  276. }
  277. else
  278. {
  279. Cleanup=0
  280. print("Done Cleaning")
  281. }
  282. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement