Advertisement
Guest User

dada

a guest
Sep 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.84 KB | None | 0 0
  1. //SET THE GLOBAL VAR IN SCRIPT
  2. ///DAY CYCLE CONSTS :
  3. globalvar MORNING ; MORNING = 0 ;
  4. globalvar EVENING ; EVENING = 1 ;
  5. globalvar MIDDAY ; MIDDAY = 2 ;
  6. globalvar NIGHT ; NIGHT = 3 ;
  7. globalvar SUNRISE; SUNRISE = 4 ;
  8.  
  9. global.player_priorRoom = noone ;
  10. global.player_priorX = 0 ;
  11. global.player_priorY = 0 ;
  12. global.prior_viewX = 0 ;
  13. global.prior_viewY = 0 ;
  14. global.fps = true ;
  15. //SOUND CONTROLLER
  16. //Sound Volume = value 0 to 10
  17. global.soundOn= true ;
  18. global.currentVolume = 0 ;
  19. global.volume = 3 ;
  20. global.currentSound = 0 ;
  21. global.steps_per_hour = room_speed * 4 ; //4 secs
  22. global.shadow_angle = 0.5 ;
  23. global.shadow_height = 0.5;
  24. global.shadow_alpha = 0.1 ;
  25. global.shadow = true ;
  26. //DAY CYCLE
  27. global.day_type = MORNING ;
  28. global.time_of_day = 0 ;
  29. global.raining = false ;
  30.  
  31. //global surf for the blackout of night or any other shader color transformation
  32. global.current_room = room ;
  33. global.value = 995 ;
  34. // THE VALUE IS USED FOR TESTING PURPOSES
  35.  
  36. //
  37. //GLOBAL SURFACE CHECK SCRIPT
  38. //CHECK TO SEE IF SURFACE EXISTS OR IF ROOM HAS CHANGED
  39. if (! surface_exists(global.surf ) or global.current_room != room
  40. or (surface_get_width(global.surf ) != room_width
  41. and surface_get_height(global.surf) != room_height ))
  42. {
  43. if (surface_exists(global.surf))
  44. {
  45. surface_free(global.surf ) ;
  46.  
  47. global.surf = surface_create(room_width, room_height ) ;
  48. global.current_room = room ;
  49. }
  50. else
  51. { global.surf = surface_create(room_width, room_height ) ;
  52. globa.current_room =room ;
  53. }
  54. surface_reset_target () ; // script clear / free targetted surface
  55. //END SCRIPT
  56. //CREATE OBJ
  57. //OBJ TIME OF THE DAY PARENT IS OBJENV
  58. // create surface and setup day clock
  59.  
  60. if (instance_number(objTimeOfDay)>1)
  61. {
  62. instance_destroy() ;
  63. }
  64. time_of_day = 15 ;
  65. alpha = 0.0 ;
  66. scriptGlobalSurfaceCheck() ;
  67. //GET REF FROM PREVIOUS SCRIPT
  68. global.current_room = room ;
  69.  
  70. day_type = MORNING ;
  71. //FIRST VALUE FOR DAY
  72. alarm[0] = global.Step_per_hour ;
  73. change_steps = 3 ;
  74. change = change_steps ;
  75. draw_surface = true ;
  76. global.time_of_day = time_of_day ;
  77. global.day_type = day_type ;
  78. //END OF SCRIPT
  79.  
  80. //DESTROY EVENT
  81. instance_destroy();
  82.  
  83. instance_destroy();
  84.  
  85. //ALARM STEP EVENT
  86. //update informations for the new hour of the day
  87. //HOUR UPDATE
  88. alarm[0] = global.steps_per_hour ;
  89. time_of_day += 1 ;
  90. //CHANGE THE 24 clock to back to 0
  91. if (time_of_day > 23) then { time_of_day== 0 ;}
  92.  
  93. //SUNRISE EVENT
  94. if (time_of_day < 7 ) and day_type <>4)
  95. {
  96. day_type = 4 ;
  97. global.shadow_alpha = 0.0 ;
  98. }
  99. //NIGHT
  100. else if (time_of_day>=18 and time_of_day < 24 )
  101. {
  102. day_type = 3 ;
  103. alpha += 1/6 ;
  104. global.shadow_alpha = 0.5 ; //1/6 ;
  105. }
  106. //MORNING
  107. else if (time_of_day == 7 and time_of_day < 12 and day_type <> 1 )
  108. {
  109. day_type = 1 ;
  110. alarm[1] = 1 ;
  111. global.shadow_alpha = 0.1 ;
  112. }
  113. //MIDDAY
  114. else if (time_of_day > 12 and time_of_day < 18 and day_type <> 2 )
  115. {
  116. day_type = 2 ;
  117. alarm[1] = 1 ;
  118. global.shadow_alpha = 0.2;
  119. }
  120. //SHADOW PARAMS
  121. var temp = (time_of_day - 6 ) * 15 ; //12 hours is 180 degrees
  122. global.shadow_angle = cos(degtorad(temp));
  123. global.shadow_height = clamp(abs(sin(degtorad(temp))) * 0.5, 0.5, 0.5);
  124. global.time_of_day = time_of_day ;
  125. global.day_type = day_type ;
  126.  
  127.  
  128. //ALARM 1
  129. //better transtion for morning hourse
  130. if (alpha > 0.0)
  131. {
  132. alpha -= 0.01;
  133. alarm[1] = 1 ;
  134. }
  135.  
  136. //step objTimeof Day
  137. //update surface drawing lighted objects
  138. scriptGlobalSuraceCheck();
  139. surface_set_target(global.surf);
  140. if ((day_type ==1 and alpha <= 0) or room== rmRoom)
  141. {
  142. draw_surface = false ;
  143. }
  144. else if ((day_type == 2 or day_type == 3 or (daytype == 1 and alpha > 0 ))
  145. {
  146. draw_surface = true ;
  147. draw_set_colour(c_black ) ;
  148. draw_set_alpha(alpha ) ;
  149. draw_rectangle(0,0,room_width,room_height,false ) ;
  150. draw_set_blend_mode(bm_subtract);
  151. draw_set_color(c_black);
  152. draw_set_alpha(0.2 ) ;
  153.  
  154. with(objLightSourceShadow)
  155. {
  156. draw_set_color(c_white) ;
  157. draw_set_alpha(lightcolorIntensity);
  158. if (sprite_index == objTorchLight)
  159. {
  160. //draw innerline
  161. draw_circle(x+offset_x[0], y+offset_y[0],lightinerradius+offset_y[1],false);
  162. draw_set_alpha(lightcolorintensity+0.5);
  163. //draw outerline
  164. draw_circle(x+offset_x[3], y+offset_y[2],lightinerradius+offset_y[0],false)
  165. draw_set_blend_mode(bm_normal);
  166. draw_set_color(lightcolor);
  167. draw_set_alpha(lightcolorintensity + 0.2) ;
  168. draw_circle(x+offset_x[3],y + offset_y[2], lightouterradius + offset_y[0], false ) ;
  169. draw_set_blend_mode(bm_subtract);
  170. }
  171. else if (sprite_index == sprTorch)
  172. {
  173. draw_set_color(c_white) ;
  174. }
  175. else
  176. {
  177. draw_circle(x+source_x + offset_x[3], y + source_y + offset_y[2], lightinnerradius + offset_y[0], false) ; // Color
  178. draw_set_blend_mode(bm_subtract);
  179. }
  180. }
  181. with(objPlayerCharacter)
  182. {
  183. draw_set_color(lightcolor) ;
  184. draw_set_alpha(lightcolorintensity) ;
  185. draw_circle(x+offset_x[0], y-10 + offset_y[1], lightouterradius + offset_y[2], false ) ;
  186. draw_circle(x+offset_x[2], y-10 + offset_y[3], lightinnerradius + offset_y[1], false ) ;
  187.  
  188. }
  189. with(objLightSourceDraw)
  190. {
  191. draw_set_color(c_white) ;
  192. draw_set_alpha(image_alpha ) ;
  193. draw_circle_colour(x,y,lightradius, lightinnercolor, lightoutercolor, false ) ;
  194. draw_set_alpha(lightcolorintensity ) ;
  195. draw_set_color(lightcolor ) ;
  196. draw_circle_colour(x,y, lightradius, lightinnercolor, lightoutercolor, false) ;
  197. }
  198. }
  199. draw_set_colour(c_white) ;
  200. draw_set_blend_mode(bm_normal);
  201. draw_set_alpha(1.0) ;
  202. surface_reset_target();
  203. {
  204.  
  205. //DRAW SURFACE OBJTIMEOFDAY
  206. if (!surface_exists(global.surf)
  207. {
  208. global.surf = surface_create(room_width, room_height ) ;
  209. draw_surface(global.Surf, 0 ,0 ) ;
  210. else
  211. {
  212. if (view_crrent == 0 )
  213. {
  214. if (draw_surface)
  215. {
  216. draw_surface(global.surf, 0 , 0 ) ;
  217. }
  218. }
  219.  
  220. //END
  221. //NEW OBJ : OBJLIGHTSOURCESHADOW
  222. // create properties
  223. /*
  224.  
  225. children : objFirePit
  226. children : objAction
  227. */
  228. //inherit events
  229. lightcolor = make_colour_rgb(255,255,255) ;
  230. lgihtcolorIntensity = 0.1 ;
  231. lightinnerraidus = 30 ;
  232. lightouterradius = 50 ;
  233. lightoffset = 2 ;
  234. scrSetOffsets(lightoffset);
  235. alarm[0] = random_range(0.1, 0.2) * room_speed ;
  236. source_x = 0;
  237. source_y = 0 ;
  238. /*
  239. OBJ = objLightSourceDraw
  240.  
  241. parent = objShadowFixed
  242.  
  243. //ALARM 0
  244.  
  245. //ADD THE OBJCHARACTERPLAYER :
  246.  
  247. */
  248. lightcolor = c_white
  249. lgithcolorIntensity = .5 ;
  250. lgihtoffset = 1;
  251. lightouterradius = 40 ;
  252. lightinnerradius = 25;
  253. scrSetOffsets(lightoffset) ;
  254. alarm[0] = random_range(.1, .2 ) * room_speed ;
  255. //ADD THE MAIN CHARACTER ALARM NUMBER WHATEVER
  256. scrSetOffsets(lightoffset) ;
  257.  
  258. alarm[0] = random_range(0.05, 0.1) * room_speed ;
  259.  
  260. //END OF TUT 1
  261. //START FIREFLIES LOGIC
  262. //new obj : objirefly
  263. /* parent : objLightSourceDraw
  264. create event : */
  265. event_inherited();
  266. surface_y =0 ;
  267. vspeed = random_range ( -0.1, 0.1 );
  268. hspeed = random_range ( -0.1, 0.1 );
  269. lifespan = random_range ( 0.35, 0.5 )* room_speed ; // 3.5 - 5 secs
  270. fadestep = 0 ;
  271. lifespan_max = lifespan ;
  272. lightcolorIntensity = .2 ;
  273. image_blend = make_colour_rgb(255,255,0 );
  274. lightcolor = make_colour_rgb(255,255,0 ) ;
  275.  
  276. //step event
  277. event_inherited()
  278. ;
  279. depth = -1 * surface_y ;
  280. fadestep ++ ;
  281. lifespan = -1 ;
  282. if (lifespan < 0)
  283. {
  284. instance_destroy() ; }
  285.  
  286. var calc = sqr(fadestep / lifespan_max ) / fadestep ;
  287. image_alpha -= calc ;
  288. image_blend = make_colour_rgb(255*image_alpha, 255 * image_alpha, 0 ) ;
  289. // THIS BLEND THE COLOR DEPENDING ON ITS ALPHA VALUE
  290. //BACK TO OBJTIMEOFDAY ADDITION
  291. //add to STEP EVENT
  292. //after "with (objChaaracterPlayer)
  293. /with (objLightSourceDraw )
  294. { draw_set_color(c_white ) ;
  295. draw_set_alpha ( image_alpha) ;
  296. draw_circle_colour(x, y , lightradius , lightinnercolor, lightoutercolor, false ) ;
  297. draw_set_alpha(lightcolor ) ;
  298. draw_set_color(lightcolor);
  299. draw_circle_colour(x,y,lightradisu, lightinnercolor, lightoutercolor ,false ) ;
  300. }
  301. }
  302.  
  303. //ADD TO OBJGRASS CREATE EVENT
  304. var rustling = false; //affected by day night cycle
  305. //CHECK THE OBJBOB = OBJPLAYERCHARACTER COLISION
  306. if (animation == false )
  307. {
  308. animation = true ;
  309. if (other.move_x > 0 )
  310.  
  311. { sprite _index = sprLeafaRight ;
  312. else if (other.move_x < 0 )
  313. {
  314. sprite_index = sprLeafLeft;
  315. else
  316. {
  317. if (other.move_y ! = 0 )
  318. { sprite_index = sprLeafDown;}
  319. else
  320. { sprite_index = sprLeafUp ;
  321. }
  322. }
  323. image_index = 0 ;
  324. //STARTS THE ANIMATION
  325. if (other.move_y != 0 or other.move_x != 0 ) //BASICALLY MOVING IN ANY IDRECTION
  326. {
  327. image_speed = 4 / room_speed ; //SET 4 SECS
  328. }
  329. else
  330. {
  331. animation = false ;
  332. //IF WE ARENT MOVING DOESNT TRIGGER THE ANIMATION OF THE GRASS
  333. }
  334.  
  335. //LEAF PARTICULE RANDOMIZED
  336. if (other.running )
  337. {
  338. if (choose(0,0 ,1 ) == 1 )
  339. {
  340. var o = instance_create(other.x , other.y , objLeaf ) ;
  341. o.hspeed = other.move_x * random_range(0.05, 0.2 ) ;
  342. }
  343. }
  344. rustling = true ;
  345. }
  346. //ObjGrass
  347. //time of day Event STEP
  348. if (global.day_type == 2 )
  349. {
  350. if (random(1000) > global.value or //rare firefly
  351. (rustling and random(100) > 90 )) //rustling
  352. {
  353. var object = instance_create(x + irandom_range(-5, 5), y + irandom_range--10, -5), y + irandom
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement