Advertisement
ywkls

Cane of Somaria Script

Nov 28th, 2020
28
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //No moving platforms for you, Somaria!
  2. const int SOMARIA_SCRIPT = 104;
  3. const int SPR_SOMARIA_BEAM = 20;
  4. const int SOMARIA_COMBO = 28324;
  5. const int SPR_SOMARIA = 109;
  6. const int SFX_PUSH_SOMARIA = 50;
  7. const int PRESSURE_PLATE_SCRIPT = 105;
  8.  
  9. item script Run_Somaria{
  10. void run(int Damage){
  11. int Damage = 7;
  12. lweapon somaria = FireLWeapon(LW_SCRIPT10,Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
  13. __DirtoRad(Link->Dir), 0, Damage, SPR_SOMARIA, SFX_SWORD, 0);
  14. SetLWeaponLifespan(somaria,LWL_TIMER,15);
  15. SetLWeaponMovement(somaria,LWM_MELEE,0,LWMF_TRACKER);
  16. SetLWeaponDeathEffect(somaria,LWD_VANISH,0);
  17. Link->Action= LA_ATTACKING;
  18. if(CountFFCsRunning(SOMARIA_SCRIPT)==0){
  19. int Args[8] = {Damage, SPR_SOMARIA_BEAM, SFX_BEAM};
  20. NewFFCScript(SOMARIA_SCRIPT, Args);
  21. }
  22. }
  23. }
  24.  
  25. bool Is_Switch(int loc){
  26. return ComboFIT(loc,CF_BLOCKTRIGGER,CT_NONE);
  27. }
  28.  
  29. const int SFX_SWITCH_PUSH= 91;//Sound effect of pushing a switch
  30. const int I_ITEM_SOMARIA= 0;//Item id of Cane of Somaria
  31. const int CF_SOMARIA= 103;//Combo flag for objects affects by Somaria switch. Defaults to CF_SCRIPT5
  32.  
  33. ffc script Somaria_Block{
  34. void run(int damage, int spr, int sfx){
  35. lweapon spark;
  36. this->Data = SOMARIA_COMBO;
  37. this->X = Link->X+InFrontX(Link->Dir,2);
  38. this->Y = Link->Y+InFrontY(Link->Dir,2);
  39. int Pushing = -1;
  40. int PushCooldown;
  41. int i;
  42. bool Pressed;
  43. int ComboArray[176];
  44. for(i= 0;i<=175;i++){
  45. ComboArray[i]= -1;
  46. if(Is_Switch(i))
  47. ComboArray[i]= Screen->ComboD[i];
  48. }
  49. int loc;
  50. int Sfx_Timer;
  51. int Push_Counter;
  52. int Switch_Spot;
  53. while(true){
  54. while(Link->X+16< this->X
  55. || Link->X> this->X+16
  56. || Link->Y> this->Y+16
  57. || Link->Y+16< this->Y){
  58. if(Link->PressB){
  59. if(GetEquipmentB()==I_ITEM_SOMARIA){
  60. for(i=0;i<=3;i++)
  61. spark= FireLWeapon(LW_SCRIPT1,this->X+InFrontX(i,2),this->Y+InFrontY(i,2),
  62. __DirtoRad(i),100,damage,spr,sfx,LWF_PIERCES_ENEMIES);
  63. for(i= 0;i<=175;i++){
  64. if(ComboArray[i]!=-1)
  65. Screen->ComboD[i]=ComboArray[i];
  66. if(Pressed){
  67. if(Screen->ComboF[i]==CF_SOMARIA)
  68. Screen->ComboD[i]--;
  69. }
  70. }
  71. if(Switch_Spot)
  72. Screen->ComboD[Switch_Spot]=ComboArray[Switch_Spot];
  73. this->Data = GH_INVISIBLE_COMBO;
  74. this->Flags[FFCF_ETHEREAL]= true;
  75. Waitframes(30);
  76. Quit();
  77. }
  78. }
  79. if(IsSideview()){
  80. if(!OnSidePlatform(this->X,this->Y))
  81. this->Y++;
  82. if(Link->Y+16< this->Y
  83. &&Link->Y>this->Y-18){
  84. if(Link->X+16> this->X
  85. && Link->X< this->X+16){
  86. if(GetEquipmentB()!=I_ROCSFEATHER)
  87. Link->Jump=0;
  88. else{
  89. if(!Link->PressB
  90. && !Link->InputB)
  91. Link->Jump=0;
  92. }
  93. }
  94. }
  95. }
  96. loc = ComboAt(this->X+8,this->Y+8);
  97. if(Is_Switch(loc)){
  98. Screen->ComboD[loc]++;
  99. Game->PlaySound(SFX_SWITCH_PUSH);
  100. Switch_Spot= loc;
  101. if(!Pressed){
  102. for(i= 0;i<=175;i++){
  103. if(Screen->ComboF[i]==CF_SOMARIA)
  104. Screen->ComboD[i]++;
  105. }
  106. Pressed= true;
  107. }
  108. }
  109. else{
  110. if(loc!=Switch_Spot){
  111. if(ComboArray[Switch_Spot]!=-1){
  112. Screen->ComboD[Switch_Spot]=ComboArray[Switch_Spot];
  113. Switch_Spot= 0;
  114. if(Pressed){
  115. for(i= 0;i<=175;i++){
  116. if(Screen->ComboF[i]==CF_SOMARIA)
  117. Screen->ComboD[i]--;
  118. }
  119. Pressed= false;
  120. }
  121. }
  122. }
  123. }
  124. Waitframe();
  125. }
  126. while(Pushing==-1){
  127. if(Link->PressB){
  128. if(GetEquipmentB()==I_ITEM_SOMARIA){
  129. for(i=0;i<=3;i++)
  130. spark= FireLWeapon(LW_SCRIPT1,this->X+InFrontX(i,2),this->Y+InFrontY(i,2),
  131. __DirtoRad(i),100,damage,spr,sfx,LWF_PIERCES_ENEMIES);
  132. for(i= 0;i<=175;i++){
  133. if(ComboArray[i]!=-1)
  134. Screen->ComboD[i]=ComboArray[i];
  135. if(Pressed){
  136. if(Screen->ComboF[i]==CF_SOMARIA)
  137. Screen->ComboD[i]--;
  138. }
  139. }
  140. if(Switch_Spot)
  141. Screen->ComboD[Switch_Spot]=ComboArray[Switch_Spot];
  142. this->Data = GH_INVISIBLE_COMBO;
  143. this->Flags[FFCF_ETHEREAL]= true;
  144. Waitframes(30);
  145. Quit();
  146. }
  147. }
  148. if(Link->X+16 >=this->X && Link->X < this->X
  149. && (Link->PressRight||Link->InputRight)
  150. && (Between(Link->Y+8,this->Y,this->Y+16)
  151. ||Between(Link->Y+1,this->Y,this->Y+16)
  152. ||Between(Link->Y+15,this->Y,this->Y+16))){
  153. if(!Screen->isSolid(this->X+17,this->Y)
  154. && !Screen->isSolid(this->X+17,this->Y+8)
  155. && !Screen->isSolid(this->X+17,this->Y+15)){
  156. if(Push_Counter<=5){
  157. Link->PressRight = false;
  158. Link->InputRight = false;
  159. Push_Counter++;
  160. }
  161. else{
  162. Game->PlaySound(SFX_PUSH_SOMARIA);
  163. Pushing = DIR_RIGHT;
  164. }
  165. }
  166. else{
  167. Link->PressRight = false;
  168. Link->InputRight = false;
  169. }
  170. }
  171. else if(Link->X <=this->X+16 && Link->X+16 > this->X+16
  172. && (Link->PressLeft||Link->InputLeft)
  173. && (Between(Link->Y+8,this->Y,this->Y+16)
  174. ||Between(Link->Y+1,this->Y,this->Y+16)
  175. ||Between(Link->Y+15,this->Y,this->Y+16))){
  176. if(!Screen->isSolid(this->X-1,this->Y)
  177. && !Screen->isSolid(this->X-1,this->Y+8)
  178. && !Screen->isSolid(this->X-1,this->Y+15)){
  179. if(Push_Counter<=5){
  180. Link->PressLeft = false;
  181. Link->InputLeft = false;
  182. Push_Counter++;
  183. }
  184. else{
  185. Game->PlaySound(SFX_PUSH_SOMARIA);
  186. Pushing = DIR_LEFT;
  187. }
  188. }
  189. else{
  190. Link->PressLeft = false;
  191. Link->InputLeft = false;
  192. }
  193. }
  194. else if(Link->Y+16 >=this->Y && Link->Y <= this->Y
  195. && (Link->PressDown||Link->InputDown)
  196. && (Between(Link->X+8,this->X,this->X+16)
  197. ||Between(Link->X+1,this->X,this->X+16)
  198. ||Between(Link->X+15,this->X,this->X+16))){
  199. if(!Screen->isSolid(this->X,this->Y+17)
  200. && !Screen->isSolid(this->X+8,this->Y+17)
  201. && !Screen->isSolid(this->X+15,this->Y+17)){
  202. if(Push_Counter<=5){
  203. Link->PressDown = false;
  204. Link->InputDown = false;
  205. Push_Counter++;
  206. }
  207. else{
  208. Game->PlaySound(SFX_PUSH_SOMARIA);
  209. Pushing = DIR_DOWN;
  210. }
  211. }
  212. else{
  213. Link->PressDown = false;
  214. Link->InputDown = false;
  215. }
  216. }
  217. else if(Link->Y <=this->Y+16&& Link->Y+16 > this->Y+16
  218. && (Link->PressUp||Link->InputUp)
  219. && (Between(Link->X+8,this->X,this->X+16)
  220. ||Between(Link->X+1,this->X,this->X+16)
  221. ||Between(Link->X+15,this->X,this->X+16))){
  222. if(!Screen->isSolid(this->X,this->Y-1)
  223. && !Screen->isSolid(this->X+8,this->Y-1)
  224. && !Screen->isSolid(this->X+15,this->Y-1)){
  225. if(Push_Counter<=5){
  226. Link->PressUp = false;
  227. Link->InputUp = false;
  228. Push_Counter++;
  229. }
  230. else{
  231. Game->PlaySound(SFX_PUSH_SOMARIA);
  232. Pushing = DIR_UP;
  233. }
  234. }
  235. else{
  236. Link->PressUp = false;
  237. Link->InputUp = false;
  238. }
  239. }
  240. if(IsSideview()){
  241. if(!OnSidePlatform(this->X,this->Y))
  242. this->Y++;
  243. if(Link->Y+16< this->Y
  244. &&Link->Y>this->Y-18){
  245. if(Link->X+16> this->X
  246. && Link->X< this->X+16){
  247. if(GetEquipmentB()!=I_ROCSFEATHER)
  248. Link->Jump=0;
  249. else{
  250. if(!Link->PressB
  251. && !Link->InputB)
  252. Link->Jump=0;
  253. }
  254. }
  255. }
  256. }
  257. loc = ComboAt(this->X+8,this->Y+8);
  258. if(Is_Switch(loc)){
  259. Screen->ComboD[loc]++;
  260. Game->PlaySound(SFX_SWITCH_PUSH);
  261. Switch_Spot= loc;
  262. if(!Pressed){
  263. for(i= 0;i<=175;i++){
  264. if(Screen->ComboF[i]==CF_SOMARIA)
  265. Screen->ComboD[i]++;
  266. }
  267. Pressed= true;
  268. }
  269. }
  270. else{
  271. if(loc!=Switch_Spot){
  272. if(ComboArray[Switch_Spot]!=-1){
  273. Screen->ComboD[Switch_Spot]=ComboArray[Switch_Spot];
  274. Switch_Spot= 0;
  275. if(Pressed){
  276. for(i= 0;i<=175;i++){
  277. if(Screen->ComboF[i]==CF_SOMARIA)
  278. Screen->ComboD[i]--;
  279. }
  280. Pressed= false;
  281. }
  282. }
  283. }
  284. }
  285. Waitframe();
  286. }
  287. while(Pushing!=-1){
  288. if(Link->PressB)){
  289. if(GetEquipmentB()==I_ITEM_SOMARIA){
  290. for(i=0;i<=3;i++)
  291. spark= FireLWeapon(LW_SCRIPT1,this->X+InFrontX(i,2),this->Y+InFrontY(i,2),
  292. __DirtoRad(i),100,damage,spr,sfx,LWF_PIERCES_ENEMIES);
  293. for(i= 0;i<=175;i++){
  294. if(ComboArray[i]!=-1)
  295. Screen->ComboD[i]=ComboArray[i];
  296. if(Pressed){
  297. if(Screen->ComboF[i]==CF_SOMARIA)
  298. Screen->ComboD[i]--;
  299. }
  300. }
  301. if(Switch_Spot)
  302. Screen->ComboD[Switch_Spot]=ComboArray[Switch_Spot];
  303. this->Data = GH_INVISIBLE_COMBO;
  304. this->Flags[FFCF_ETHEREAL]= true;
  305. Waitframes(30);
  306. Quit();
  307. }
  308. }
  309. if(Sfx_Timer==0)
  310. Game->PlaySound(SFX_PUSH_SOMARIA);
  311. Sfx_Timer = (Sfx_Timer+1)%10;
  312. if(Pushing==DIR_LEFT){
  313. if(!Link->PressRight
  314. && !Link->InputRight
  315. && !Link->InputUp
  316. && !Link->PressDown
  317. && !Link->PressUp
  318. && !Link->InputDown){
  319. this->X = Link->X-16;
  320. if(Screen->isSolid(this->X-1,this->Y)
  321. || Screen->isSolid(this->X-1,this->Y+8)
  322. || Screen->isSolid(this->X-1,this->Y+15)){
  323. Link->InputLeft = false;
  324. Link->PressLeft = false;
  325. }
  326. }
  327. else
  328. Pushing = -1;
  329. }
  330. else if(Pushing==DIR_RIGHT){
  331. if(!Link->PressLeft
  332. && !Link->InputLeft
  333. && !Link->InputUp
  334. && !Link->PressDown
  335. && !Link->PressUp
  336. && !Link->InputDown){
  337. this->X = Link->X+16;
  338. if(Screen->isSolid(this->X+17,this->Y)
  339. || Screen->isSolid(this->X+17,this->Y+8)
  340. || Screen->isSolid(this->X+17,this->Y+15)){
  341. Link->InputRight = false;
  342. Link->PressRight = false;
  343. }
  344. }
  345. else
  346. Pushing = -1;
  347. }
  348. else if(Pushing==DIR_UP){
  349. if(!Link->PressRight
  350. && !Link->InputRight
  351. && !Link->InputLeft
  352. && !Link->PressDown
  353. && !Link->PressLeft
  354. && !Link->InputDown){
  355. this->Y = Link->Y-16;
  356. if(Screen->isSolid(this->X,this->Y-1)
  357. || Screen->isSolid(this->X+8,this->Y-1)
  358. || Screen->isSolid(this->X+15,this->Y-1)){
  359. Link->InputUp = false;
  360. Link->PressUp = false;
  361. }
  362. }
  363. else
  364. Pushing = -1;
  365. }
  366. else if(Pushing==DIR_DOWN){
  367. if(!Link->PressRight
  368. && !Link->InputRight
  369. && !Link->InputUp
  370. && !Link->PressLeft
  371. && !Link->PressUp
  372. && !Link->InputLeft){
  373. this->Y = Link->Y+16;
  374. if(Screen->isSolid(this->X,this->Y+17)
  375. || Screen->isSolid(this->X+8,this->Y+17)
  376. || Screen->isSolid(this->X+15,this->Y+17)){
  377. Link->InputDown = false;
  378. Link->PressDown = false;
  379. }
  380. }
  381. else
  382. Pushing = -1;
  383. }
  384. if(IsSideview()){
  385. if(!OnSidePlatform(this->X,this->Y))
  386. this->Y++;
  387. if(Link->Y+16< this->Y
  388. && Link->Y>this->Y-16){
  389. if(Link->X+16> this->X
  390. && Link->X< this->X+16){
  391. if(GetEquipmentB()!=I_ROCSFEATHER)
  392. Link->Jump=0;
  393. else{
  394. if(!PressAbility()
  395. && !InputAbility())
  396. Link->Jump=0;
  397. }
  398. }
  399. }
  400. }
  401. loc = ComboAt(this->X+8,this->Y+8);
  402. if(Is_Switch(loc)){
  403. Screen->ComboD[loc]++;
  404. Game->PlaySound(SFX_SWITCH_PUSH);
  405. Switch_Spot= loc;
  406. if(!Pressed){
  407. for(i= 0;i<=175;i++){
  408. if(Screen->ComboF[i]==CF_SOMARIA)
  409. Screen->ComboD[i]++;
  410. }
  411. Pressed= true;
  412. }
  413. }
  414. else{
  415. if(loc!=Switch_Spot){
  416. if(ComboArray[Switch_Spot]!=-1){
  417. Screen->ComboD[Switch_Spot]=ComboArray[Switch_Spot];
  418. Switch_Spot= 0;
  419. if(Pressed){
  420. for(i= 0;i<=175;i++){
  421. if(Screen->ComboF[i]==CF_SOMARIA)
  422. Screen->ComboD[i]--;
  423. }
  424. Pressed= false;
  425. }
  426. }
  427. }
  428. }
  429. Waitframe();
  430. }
  431. if(IsSideview()){
  432. if(!OnSidePlatform(this->X,this->Y))
  433. this->Y++;
  434. }
  435. Push_Counter = 0;
  436. Waitframe();
  437. }
  438. }
  439. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement