Advertisement
tbyond

Untitled

Dec 22nd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1.  
  2.  
  3.  
  4. mob
  5. proc
  6. windeffect()
  7. set background = 1
  8. spawn()
  9. while(src.windeffect)
  10. new /Explosion(new /Effect/MysticWind(src.loc,1,9))
  11. sleep(rand(10,15))
  12.  
  13.  
  14.  
  15. Effect
  16.  
  17. var
  18. atom/orig // The point of origin for the explosion
  19. speed = 1 // The rate at which the explosion expands in ticks
  20. basepower = 2 // The strength of the explosion at ground zero
  21.  
  22. proc
  23. Apply(loc,power,dir) // The function to override in children classes to change behaviour of explosion.
  24. return power - 1
  25.  
  26. New(atom/p_orig, p_speed, p_basepower)
  27. orig = p_orig
  28. speed = p_speed
  29. basepower = p_basepower
  30.  
  31. //------------------------
  32. //Mystic Wind Effect
  33. //------------------------
  34.  
  35. MysticWind
  36. Apply(loc,power,dir)
  37. var/i
  38. var/turf/T
  39.  
  40. T = loc
  41. if(T)
  42. var/mob/M = locate() in T
  43. if(M)
  44. if(M.MaxHP<= usr.MaxHP)
  45. step(M,dir)
  46.  
  47. //Show the wind
  48. i = image('Shockwave.dmi',loc, dir = get_dir(orig,loc))
  49. world << i
  50. spawn(1)
  51. del(i)
  52. //Use the base expansion algorithm
  53. return ..()
  54.  
  55.  
  56.  
  57. Explosion
  58.  
  59. var
  60. Explosion/Queue/Q
  61.  
  62. New(Effect/theeffect)
  63. var/loc
  64. var/pow
  65. var/dir
  66. var/dist
  67. var/lastdist = 0
  68. var/D
  69.  
  70. Q = new()
  71.  
  72. var/dirlist[] = list(NORTH,SOUTH,EAST,WEST,NORTHWEST,NORTHEAST,SOUTHWEST,SOUTHEAST)
  73. var/newpow = theeffect.Apply(theeffect.orig,theeffect.basepower,0)
  74.  
  75. //Initialize the starting queue
  76. for(D in dirlist)
  77. Q.L.Add(D)
  78. Q.L.Add(get_step(theeffect.orig,D))
  79. Q.L.Add(newpow)
  80. Q.L.Add(1)
  81.  
  82. while(Q.L.len)
  83. dir = Q.Pop()
  84. loc = Q.Pop()
  85. pow = Q.Pop()
  86. dist = Q.Pop()
  87. if(lastdist != dist)
  88. if(theeffect.speed >= 0)
  89. sleep(theeffect.speed)
  90. lastdist = dist
  91.  
  92. if(pow > 0 && loc)
  93. //If there is only one bit set(ie: Cardinal direction)
  94. //this will return 0
  95. newpow = theeffect.Apply(loc,pow,dir)
  96.  
  97. if(dir & (dir-1))
  98. if(dir & NORTH)
  99. Q.L.Add(NORTH)
  100. Q.L.Add(get_step(loc,NORTH))
  101. Q.L.Add(newpow)
  102. Q.L.Add(dist+1)
  103. if(dir & SOUTH)
  104. Q.L.Add(SOUTH)
  105. Q.L.Add(get_step(loc,SOUTH))
  106. Q.L.Add(newpow)
  107. Q.L.Add(dist+1)
  108. if(dir & EAST)
  109. Q.L.Add(EAST)
  110. Q.L.Add(get_step(loc,EAST))
  111. Q.L.Add(newpow)
  112. Q.L.Add(dist+1)
  113. if(dir & WEST)
  114. Q.L.Add(WEST)
  115. Q.L.Add(get_step(loc,WEST))
  116. Q.L.Add(newpow)
  117. Q.L.Add(dist+1)
  118.  
  119.  
  120. Q.L.Add(dir)
  121. Q.L.Add(get_step(loc,dir))
  122. Q.L.Add(newpow)
  123. Q.L.Add(dist+1)
  124.  
  125.  
  126. Queue
  127. var/L[]
  128. New()
  129. L = new()
  130.  
  131. Del()
  132. del(L)
  133.  
  134. proc
  135. Pop()
  136. . = L[1]
  137. L.Cut(1,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement