Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.48 KB | None | 0 0
  1. const int SFX_MOLDORM_SKITTER = 66; //The moldorm skittering SFX
  2. const int SFX_LTTP_BOUNCE = 67; //The bounce SFX
  3.  
  4. ffc script Moldorm{
  5. void run(int enemyid){
  6. int i; int j; int k;
  7. npc ghost = Ghost_InitAutoGhost(this, enemyid);
  8. int TailID = ghost->Attributes[0];
  9. int Combo = ghost->Attributes[10];
  10. Ghost_Transform(this, ghost, GH_INVISIBLE_COMBO, -1, 2, 2);
  11. Ghost_SetHitOffsets(ghost, 4, 4, 4, 4);
  12. ghost->CollDetection = true;
  13. npc tail = CreateNPCAt(TailID, Ghost_X+8, Ghost_Y+8);
  14. tail->HP = 1000;
  15. int TrackX[120];
  16. int TrackY[120];
  17. for(i=0; i<120; i++){
  18. TrackX[i] = Ghost_X+16;
  19. TrackY[i] = Ghost_Y+16;
  20. }
  21. int Spacing[5] = {0, 22, 18, 16, 12};
  22. int Radius[5] = {14, 10, 10, 5, 0};
  23. int BounceFrames[5];
  24. int BounceAngle[5];
  25. int PushArray[2];
  26. int Vars[16] = {0, 0, TrackX, TrackY, Spacing, BounceFrames, BounceAngle, PushArray, Radius, -1, 0, 0};
  27. k = 0;
  28. Vars[1] = Angle(Ghost_X+8, Ghost_Y+8, Link->X, Link->Y);
  29. ghost->CollDetection = false;
  30. //int Step = 100;
  31. int lastk = 0;
  32. while(true){
  33. int Duration = 120;
  34. int Multiplier = 1;
  35. if(Vars[10]>0)
  36. Multiplier = 1.5;
  37. Duration = 120*Multiplier;
  38. for(i=0; i<Duration; i++){
  39. Multiplier = 1;
  40. if(Vars[10]>0)
  41. Multiplier = 1.5;
  42. int VX = VectorX(2, Vars[1]);
  43. int VY = VectorY(2, Vars[1]);
  44. if((VX<0&&!Ghost_CanMove(DIR_LEFT, 1, 0))||(VX>0&&!Ghost_CanMove(DIR_RIGHT, 1, 0)))
  45. VX = -VX;
  46. if((VY<0&&!Ghost_CanMove(DIR_UP, 1, 0))||(VY>0&&!Ghost_CanMove(DIR_DOWN, 1, 0)))
  47. VY = -VY;
  48. Vars[1] = Angle(0, 0, VX, VY);
  49. Ghost_MoveAtAngle(Vars[1], 2*Multiplier, 0);
  50. Vars[1] = WrapDegrees(Vars[1]+(2*k)*Multiplier);
  51. Moldorm_Waitframe(this, ghost, tail, Vars);
  52. }
  53. if(Vars[10]>0)
  54. k = Rand(-1, 1);
  55. else
  56. k = Rand(-2, 2);
  57. if(lastk==0&&k==0)
  58. k = Choose(-1, 1);
  59. lastk = k;
  60. }
  61. }
  62. void Moldorm_Waitframe(ffc this, npc ghost, npc tail, int Vars){
  63. int i; int j; int k;
  64. //Vars[0] = Flash frames
  65. //Vars[1] = Angle
  66. int Combo = ghost->Attributes[10];
  67. int TrackX = Vars[2];
  68. int TrackY = Vars[3];
  69. int Spacing = Vars[4];
  70. int BounceFrames = Vars[5];
  71. int BounceAngle = Vars[6];
  72. int PushArray = Vars[7];
  73. int Radius = Vars[8];
  74. //Vars[9] = Currently Bouncing
  75. //Vars[10] = Speedup counter
  76. //Vars[11] = SFX counter;
  77. Vars[11] = (Vars[11]+1)%360;
  78. if(Vars[10]>0){
  79. if(Vars[11]%8==0){
  80. Game->PlaySound(SFX_MOLDORM_SKITTER);
  81. }
  82. Vars[10]--;
  83. }
  84. else if(Vars[11]%12==0){
  85. Game->PlaySound(SFX_MOLDORM_SKITTER);
  86. }
  87. DEATHWORM(Ghost_X+16, Ghost_Y+16, TrackX, TrackY);
  88. int Pos = Spacing[1]+Spacing[2]+Spacing[3]+Spacing[4];
  89. int X; int Y; int Angle;
  90. int CSet = Ghost_CSet;
  91. if(Vars[0]>0){
  92. CSet = 9-(Vars[0]>>1);
  93. Vars[0]--;
  94. }
  95. Pos = Spacing[1]+Spacing[2]+Spacing[3]+Spacing[4];
  96. X = TrackX[Pos];
  97. Y = TrackY[Pos];
  98. Screen->FastCombo(2, X-8, Y-8, Combo+4, CSet, 128);
  99. if(tail->isValid()){
  100. tail->DrawYOffset = -1000;
  101. if(tail->HP<1000){
  102. Ghost_HP = Max(1, Ghost_HP+(tail->HP-1000));
  103. Vars[0] = 32;
  104. Vars[10] = 300;
  105. }
  106. tail->X = X-8;
  107. tail->Y = Y-8;
  108. tail->HP = 1000;
  109. tail->Stun = 4;
  110. }
  111. for(int i=3; i>=0; i--){
  112. Pos -= Spacing[i+1];
  113. X = TrackX[Pos];
  114. Y = TrackY[Pos];
  115. if(BounceFrames[i]>0){
  116. DrawComboC(2, X, Y, Combo+i, 2, 2, CSet, 32+4*Sin(BounceFrames[i]*5.625*8), 32+4*Sin(BounceFrames[i]*5.625*8), 0, 0, 0, -1, 0, true, 128);
  117. if(i==0){
  118. Angle = WrapDegrees(Vars[1]-45);
  119. Screen->FastCombo(2, X-8+VectorX(12+4*Sin(BounceFrames[i]*5.625*8), Angle), Y-8+VectorY(12+4*Sin(BounceFrames[i]*5.625*8), Angle), Combo+8+AngleDir8(Angle), CSet, 128);
  120. Angle = WrapDegrees(Vars[1]+45);
  121. Screen->FastCombo(2, X-8+VectorX(12+4*Sin(BounceFrames[i]*5.625*8), Angle), Y-8+VectorY(12+4*Sin(BounceFrames[i]*5.625*8), Angle), Combo+8+AngleDir8(Angle), CSet, 128);
  122. }
  123. if(BounceFrames[i]>16){
  124. PushArray[0] += VectorX(3, BounceAngle[i]);
  125. PushArray[1] += VectorY(3, BounceAngle[i]);
  126. }
  127. BounceFrames[i]--;
  128. Link->HitDir = 8;
  129. }
  130. else{
  131. DrawComboC(2, X, Y, Combo+i, 2, 2, CSet, -1, -1, 0, 0, 0, -1, 0, true, 128);
  132. if(i==0){
  133. Angle = WrapDegrees(Vars[1]-45);
  134. Screen->FastCombo(2, X-8+VectorX(12, Angle), Y-8+VectorY(12, Angle), Combo+8+AngleDir8(Angle), CSet, 128);
  135. Angle = WrapDegrees(Vars[1]+45);
  136. Screen->FastCombo(2, X-8+VectorX(12, Angle), Y-8+VectorY(12, Angle), Combo+8+AngleDir8(Angle), CSet, 128);
  137. }
  138. if(Link->Action!=LA_GOTHURTLAND&&Vars[9]==-1&&i<3){
  139. lweapon sword = Screen->LoadLWeapon(1);
  140. if(Distance(CenterLinkX(), CenterLinkY(), X, Y)<Radius[i]){
  141. Game->PlaySound(SFX_LTTP_BOUNCE);
  142. DamageLinkPierce(ghost->WeaponDamage);
  143. Link->HitDir = 8;
  144. BounceFrames[i] = 32;
  145. BounceAngle[i] = Angle(X, Y, CenterLinkX(), CenterLinkY());
  146. Vars[9] = i;
  147. }
  148. else if(sword->isValid()){
  149. if(sword->ID==LW_SWORD&&Distance(CenterX(sword), CenterY(sword), X, Y)<Radius[i]+8){
  150. Game->PlaySound(SFX_LTTP_BOUNCE);
  151. BounceFrames[i] = 32;
  152. BounceAngle[i] = Angle(X, Y, CenterLinkX(), CenterLinkY());
  153. Vars[9] = i;
  154. }
  155. }
  156. }
  157. }
  158. }
  159. if(Vars[9]>-1){
  160. if(BounceFrames[Vars[9]]==0)
  161. Vars[9] = -1;
  162. }
  163. HandlePushArray(PushArray, 0);
  164. if(!Ghost_Waitframe(this, ghost, false, false)||Ghost_HP<=1){
  165. Moldorm_DeathAnimation(this, ghost, tail, Vars);
  166. Quit();
  167. }
  168. }
  169. void Moldorm_DeathAnimation(ffc this, npc ghost, npc tail, int Vars){
  170. __DeathAnimStart(this, ghost);
  171. __DeathAnimSFX(ghost->ID, ghost->X);
  172. lweapon explosion;
  173. int i; int j; int k; int m;
  174. //Vars[0] = Flash frames
  175. //Vars[1] = Angle
  176. int Combo = ghost->Attributes[10];
  177. int TrackX = Vars[2];
  178. int TrackY = Vars[3];
  179. int Spacing = Vars[4];
  180. int BounceFrames = Vars[5];
  181. int BounceAngle = Vars[6];
  182. int PushArray = Vars[7];
  183. int Radius = Vars[8];
  184. //Vars[9] = Currently Bouncing
  185. if(tail->isValid()){
  186. tail->Y = -32;
  187. tail->HP = -1000;
  188. }
  189. int X; int Y; int Angle; int Dist;
  190. int CSet = Ghost_CSet;
  191. for(m=4; m>=0; m--){
  192. for(k=0; k<4; k++){
  193. int Pos;
  194. if(m>0)
  195. Pos += Spacing[1];
  196. if(m>1)
  197. Pos += Spacing[2];
  198. if(m>2)
  199. Pos += Spacing[3];
  200. if(m>3)
  201. Pos += Spacing[4];
  202. Angle = Rand(360);
  203. Dist = Rand(0, Radius[m]);
  204. X = TrackX[Pos]-8+VectorX(Dist, Angle);
  205. Y = TrackY[Pos]-8+VectorY(Dist, Angle);
  206. explosion = CreateLWeaponAt(LW_BOMBBLAST, X, Y);
  207. explosion->CollDetection = false;
  208. for(j=0; j<16; j++){
  209. Pos = Spacing[1]+Spacing[2]+Spacing[3]+Spacing[4];
  210. for(i=4; i>=0; i--){
  211. if(i<4)
  212. Pos -= Spacing[i+1];
  213. if(i<=m){
  214. X = TrackX[Pos];
  215. Y = TrackY[Pos];
  216. if(i<4){
  217. DrawComboC(2, X, Y, Combo+i, 2, 2, CSet, -1, -1, 0, 0, 0, -1, 0, true, 128);
  218. if(i==0){
  219. Angle = WrapDegrees(Vars[1]-45);
  220. Screen->FastCombo(2, X-8+VectorX(12, Angle), Y-8+VectorY(12, Angle), Combo+16, CSet, 128);
  221. Angle = WrapDegrees(Vars[1]+45);
  222. Screen->FastCombo(2, X-8+VectorX(12, Angle), Y-8+VectorY(12, Angle), Combo+17, CSet, 128);
  223. }
  224. }
  225. else{
  226. Screen->FastCombo(2, X-8, Y-8, Combo+4, CSet, 128);
  227. }
  228. }
  229. }
  230. Ghost_WaitframeLight(this, ghost);
  231. }
  232. }
  233. }
  234. __DeathAnimEnd(this, ghost);
  235. }
  236.  
  237. }
  238.  
  239. const int MAX_PUSH = 4;
  240.  
  241. void HandlePushArray(int PushArray, int Imprecision){
  242. for(int i=0; i<MAX_PUSH&&PushArray[0]<=-1; i++){
  243. if(CanWalk(Link->X, Link->Y, DIR_LEFT, 1, false)){
  244. Link->X--;
  245. PushArray[0]++;
  246. }
  247. else if(Imprecision>0&&Abs(GridY(Link->Y+8)-Link->Y)<Imprecision&&CanWalk(Link->X, GridY(Link->Y+8), DIR_LEFT, 1, false)){
  248. Link->Y = GridY(Link->Y+8);
  249. Link->X--;
  250. PushArray[0]++;
  251. }
  252. else{
  253. PushArray[0] = 0;
  254. }
  255. }
  256. for(int i=0; i<MAX_PUSH&&PushArray[0]>=1; i++){
  257. if(CanWalk(Link->X, Link->Y, DIR_RIGHT, 1, false)){
  258. Link->X++;
  259. PushArray[0]--;
  260. }
  261. else if(Imprecision>0&&Abs(GridY(Link->Y+8)-Link->Y)<Imprecision&&CanWalk(Link->X, GridY(Link->Y+8), DIR_RIGHT, 1, false)){
  262. Link->Y = GridY(Link->Y+8);
  263. Link->X++;
  264. PushArray[0]++;
  265. }
  266. else{
  267. PushArray[0] = 0;
  268. }
  269. }
  270. for(int i=0; i<MAX_PUSH&&PushArray[1]<=-1; i++){
  271. if(CanWalk(Link->X, Link->Y, DIR_UP, 1, false)){
  272. Link->Y--;
  273. PushArray[1]++;
  274. }
  275. else if(Imprecision>0&&Abs(GridX(Link->X+8)-Link->X)<Imprecision&&CanWalk(GridX(Link->X+8), Link->Y, DIR_UP, 1, false)){
  276. Link->X = GridX(Link->X+8);
  277. Link->Y--;
  278. PushArray[0]++;
  279. }
  280. else{
  281. PushArray[1] = 0;
  282. }
  283. }
  284. for(int i=0; i<MAX_PUSH&&PushArray[1]>=1; i++){
  285. if(CanWalk(Link->X, Link->Y, DIR_DOWN, 1, false)){
  286. Link->Y++;
  287. PushArray[1]--;
  288. }
  289. else if(Imprecision>0&&Abs(GridX(Link->X+8)-Link->X)<Imprecision&&CanWalk(GridX(Link->X+8), Link->Y, DIR_DOWN, 1, false)){
  290. Link->X = GridX(Link->X+8);
  291. Link->Y++;
  292. PushArray[0]++;
  293. }
  294. else{
  295. PushArray[1] = 0;
  296. }
  297. }
  298. }
  299.  
  300. void DEATHWORM(int X, int Y, int WormX, int WormY){
  301. int Length = SizeOfArray(WormX);
  302. int OldX = WormX[0];
  303. int OldY = WormY[0];
  304. int Step = Round(Distance(X, Y, WormX[0], WormY[0]));
  305. if(Step>=1){
  306. for(int i=Length-1; i>Step; i--){
  307. WormX[i] = WormX[i-Step];
  308. WormY[i] = WormY[i-Step];
  309. }
  310. for(int i=0; i<=Step; i++){
  311. WormX[i] = X+VectorX(i, Angle(X, Y, OldX, OldY));
  312. WormY[i] = Y+VectorY(i, Angle(X, Y, OldX, OldY));
  313. }
  314. }
  315. // for(int i=0; i<Length; i++){
  316. // Screen->PutPixel(6, WormX[i], WormY[i], Cond(i%2==0, 0x01, 0x0F), 0, 0, 0, 128);
  317. // }
  318. }
  319.  
  320. void DamageLinkPierce(int Damage){
  321. Damage*=4;
  322. if(Link->Item[I_RING3])
  323. Damage = Damage/8;
  324. else if(Link->Item[I_RING2])
  325. Damage = Damage/4;
  326. else if(Link->Item[I_RING1])
  327. Damage = Damage/2;
  328. Link->Action = LA_GOTHURTLAND;
  329. Link->HP -= Damage;
  330. Game->PlaySound(SFX_OUCH);
  331. // eweapon e = FireEWeapon(EW_SCRIPT10, Clamp(Link->X+InFrontX(Link->Dir, 12), 2, 238), Clamp(Link->Y+InFrontY(Link->Dir, 12), 2, 158), 0, 0, Damage, -1, -1, EWF_UNBLOCKABLE);
  332. // e->Dir = Link->Dir;
  333. // e->DrawYOffset = -1000;
  334. // SetEWeaponLifespan(e, EWL_TIMER, 1);
  335. // SetEWeaponDeathEffect(e, EWD_VANISH, 0);
  336. }
  337.  
  338. void DrawComboC(int layer, int cx, int cy, int tile, int blockw, int blockh, int cset, int xscale, int yscale, int rx, int ry, int rangle, int frame, int flip, bool transparency, int opacity){
  339. int w = xscale;
  340. if(xscale==-1)
  341. w = blockw*16;
  342. int h = yscale;
  343. if(yscale==-1)
  344. h = blockh*16;
  345. Screen->DrawCombo(layer, cx-w/2, cy-h/2, tile, blockw, blockh, cset, xscale, yscale, rx-w/2, ry-h/2, rangle, frame, flip, transparency, opacity);
  346. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement