Guest User

playerscript

a guest
Jan 15th, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.54 KB | None | 0 0
  1. #TouhouDanmakufu[Player]
  2. #Menu[Rainbow Dash]
  3. #Text[Dashtest]
  4. #ReplayName[RD]
  5. #ScriptVersion[2]
  6.  
  7. script_player_main
  8. {
  9. #include_function ".\drawchar.dnh";
  10.  
  11. let CSD = GetCurrentScriptDirectory;
  12. let imgpplayer = CSD ~"rdb.png";
  13. let plshot = CSD ~"rdshot.png";
  14. let eff = CSD ~ "rdashani.png";
  15.  
  16. let scount = -1;
  17. let shotcount = -1;
  18.  
  19.  
  20. let f = 0;
  21.  
  22. task Option(position,id)
  23. {
  24. yield;
  25. let count = 0;
  26. let dir1 = 270;
  27. let dir2 = 270;
  28. let destinationx = GetPlayerX+position[0];
  29. let destinationy = GetPlayerY+position[1];
  30. let optioneffect = Obj_Create(OBJ_EFFECT);
  31. Obj_SetPosition(optioneffect,GetPlayerX,GetPlayerY);
  32. ObjEffect_SetTexture(optioneffect,eff);
  33. ObjEffect_SetRenderState(optioneffect,ADD);
  34. ObjEffect_SetPrimitiveType(optioneffect,PRIMITIVE_TRIANGLEFAN);
  35. ObjEffect_SetLayer(optioneffect,3);
  36. ObjEffect_CreateVertex(optioneffect,4);
  37. ObjEffect_SetVertexUV(optioneffect,0,828,1);
  38. ObjEffect_SetVertexUV(optioneffect,1,843,1);
  39. ObjEffect_SetVertexUV(optioneffect,2,843,16);
  40. ObjEffect_SetVertexUV(optioneffect,3,828,16);
  41. let option = Obj_Create(OBJ_EFFECT);
  42. Obj_SetPosition(option,GetPlayerX,GetPlayerY);
  43. ObjEffect_SetTexture(option,eff);
  44. ObjEffect_SetRenderState(option,ALPHA);
  45. ObjEffect_SetPrimitiveType(option,PRIMITIVE_TRIANGLEFAN);
  46. ObjEffect_SetLayer(option,3);
  47. ObjEffect_CreateVertex(option,4);
  48. ObjEffect_SetVertexUV(option,0,828,1);
  49. ObjEffect_SetVertexUV(option,1,843,1);
  50. ObjEffect_SetVertexUV(option,2,843,16);
  51. ObjEffect_SetVertexUV(option,3,828,16);
  52. let distancetopoint = ((destinationx-Obj_GetX(option))^2+(destinationy-Obj_GetY(option))^2)^0.5;
  53. let directiontopoint = atan2(destinationy-Obj_GetY(option),destinationx-Obj_GetX(option));
  54. if (id == 0){
  55. dir1 = 267;
  56. dir2 = 270;
  57. }
  58. else{
  59. dir1 = 270;
  60. dir2 = 273;
  61. }
  62. while(!Obj_BeDeleted(option)){
  63. distancetopoint = ((destinationx-Obj_GetX(option))^2+(destinationy-Obj_GetY(option))^2)^0.5;
  64. directiontopoint = atan2(destinationy-Obj_GetY(option),destinationx-Obj_GetX(option));
  65. if (distancetopoint >= 1){
  66. Obj_SetPosition(option,Obj_GetX(optioneffect)+cos(directiontopoint)*distancetopoint*0.4,Obj_GetY(optioneffect)+ sin(directiontopoint)*distancetopoint*0.4);
  67. Obj_SetPosition(optioneffect,Obj_GetX(optioneffect)+cos(directiontopoint)*distancetopoint*0.4,Obj_GetY(optioneffect)+ sin(directiontopoint)*distancetopoint*0.4);
  68. }
  69. else{
  70. Obj_SetPosition(option,destinationx,destinationy);
  71. Obj_SetPosition(optioneffect,destinationx,destinationy);
  72. }
  73. if (GetKeyState(VK_SLOWMOVE) == KEY_PUSH || GetKeyState(VK_SLOWMOVE) == KEY_HOLD){
  74. destinationx = GetPlayerX+position[2];
  75. destinationy = GetPlayerY+position[3];
  76. if (shotcount == 6){
  77. rarshot(Obj_GetX(option),Obj_GetY(option),-0.8,270,2,1.25);
  78. }
  79. }
  80. else{
  81. destinationx = GetPlayerX+position[0];
  82. destinationy = GetPlayerY+position[1];
  83. if (shotcount == 6){
  84. rarshot(Obj_GetX(option),Obj_GetY(option),-0.8,270,2,1.25);
  85. }
  86. }
  87. ObjEffect_SetVertexXY(option,0,(10.6*cos((count*5)+225)),(10.6*sin((count*5)+225)));
  88. ObjEffect_SetVertexXY(option,1,(10.6*cos((count*5)+315)),(10.6*sin((count*5)+315)));
  89. ObjEffect_SetVertexXY(option,2,(10.6*cos((count*5)+45)),(10.6*sin((count*5)+45)));
  90. ObjEffect_SetVertexXY(option,3,(10.6*cos((count*5)+135)),(10.6*sin((count*5)+135)));
  91. ObjEffect_SetVertexXY(optioneffect,0,(16*cos((count*-5)+225)),(16*sin((count*-5)+225)));
  92. ObjEffect_SetVertexXY(optioneffect,1,(16*cos((count*-5)+315)),(16*sin((count*-5)+315)));
  93. ObjEffect_SetVertexXY(optioneffect,2,(16*cos((count*-5)+45)),(16*sin((count*-5)+45)));
  94. ObjEffect_SetVertexXY(optioneffect,3,(16*cos((count*-5)+135)),(16*sin((count*-5)+135)));
  95. ObjEffect_SetVertexColor(optioneffect,0,128,255,255,255);
  96. ObjEffect_SetVertexColor(optioneffect,1,128,255,255,255);
  97. ObjEffect_SetVertexColor(optioneffect,2,128,255,255,255);
  98. ObjEffect_SetVertexColor(optioneffect,3,128,255,255,255);
  99. count ++;
  100. yield;
  101. }
  102. }
  103.  
  104. @Initialize
  105. {
  106. SetCommonData("CHAR","RDR");
  107. Hitbox;
  108. Hitbox2;
  109. Option([-30,10,-20,10],0);
  110. Option([30,10,20,10],1);
  111. Option([-15,32,-10,25],1);
  112. Option([15,32,10,25],0);
  113. SetSpeed(5.5,2.5);
  114. SetPlayerLifeImage(imgpplayer,0,0,31,47);
  115.  
  116. LoadGraphic(imgpplayer);
  117.  
  118. LoadPlayerShotData(CSD ~ "regshot.dnh");
  119.  
  120. }
  121.  
  122. @DrawLoop
  123. {
  124. drawchar;
  125. DrawHitbox;
  126. DrawHitbox2;
  127. }
  128.  
  129. @Missed
  130. {
  131.  
  132. yield;
  133.  
  134. }
  135.  
  136. @SpellCard
  137. {
  138. UseSpellCard("bombSC",NULL);
  139. PlaySE(CSD ~ "spark.wav");
  140. PlaySE(CSD ~ "shot4.wav");
  141. }
  142.  
  143. @Finalize
  144. {
  145.  
  146. }
  147.  
  148. @MainLoop
  149. {
  150.  
  151. if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && scount == -1)
  152. {
  153. scount = 0;
  154. }
  155.  
  156. //when focused
  157. if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
  158. {
  159. if(scount == 2)
  160. {
  161. rdregshot(GetPlayerX-10,GetPlayerY+13,30,270,1,1.5);
  162. rdregshot(GetPlayerX+10,GetPlayerY+13,30,270,1,1.5);
  163. //rdregshot(GetPlayerX-18,GetPlayerY+15,28,270,1,1.5);
  164. //rdregshot(GetPlayerX+18,GetPlayerY+15,28,270,1,1.5);
  165. //rdregshot(GetPlayerX,GetPlayerY+15,28,276,1,1.5);
  166. //rdregshot(GetPlayerX,GetPlayerY+15,28,264,1,1.5);
  167. PlaySE(CSD ~ "se_plshot.wav");
  168. scount = -1;
  169. }
  170. }
  171.  
  172. //when not focused
  173. else
  174. {
  175. if(scount == 2)
  176. {
  177. rdregshot(GetPlayerX-10,GetPlayerY+15,28,270,1,1.5);
  178. rdregshot(GetPlayerX+10,GetPlayerY+15,28,270,1,1.5);
  179. //rdregshot(GetPlayerX-18,GetPlayerY+15,28,270,1,1.5);
  180. //rdregshot(GetPlayerX+18,GetPlayerY+15,28,270,1,1.5);
  181. //rdregshot(GetPlayerX,GetPlayerY+15,28,276,1,1.5);
  182. //rdregshot(GetPlayerX,GetPlayerY+15,28,264,1,1.5);
  183. PlaySE(CSD ~ "se_plshot.wav");
  184. scount = -1;
  185. }
  186. }
  187.  
  188. if(scount >= 0)
  189. {
  190. scount++;
  191. }
  192.  
  193. SetIntersectionCircle(GetPlayerX,GetPlayerY,0);
  194.  
  195. if (GetKeyState(VK_SHOT) == KEY_PUSH || GetKeyState(VK_SHOT) == KEY_HOLD && shotcount == -1){
  196. shotcount = 0;
  197. }
  198. if (shotcount >= 0){
  199. shotcount ++;
  200. }
  201. if (shotcount >= 7){
  202. shotcount = -1;
  203. }
  204.  
  205. yield;
  206.  
  207. }
  208.  
  209. task rdregshot(x,y,speed,dir,graphic,dmg)
  210. {
  211. let obj = Obj_Create(OBJ_SHOT);
  212.  
  213. Obj_SetPosition(obj,x,y);
  214. Obj_SetSpeed(obj,speed);
  215. Obj_SetAngle(obj,dir);
  216. Obj_SetAlpha(obj,200);
  217. ObjShot_SetGraphic(obj,graphic);
  218. ObjShot_SetDamage(obj,dmg);
  219. ObjShot_SetPenetration(obj,1);
  220. Obj_SetAutoDelete(obj,true);
  221.  
  222. task ShotFade(x,y,dir)
  223. {
  224. let fcount = 0;
  225. let obj_shotfade = Obj_Create(OBJ_EFFECT);
  226. Obj_SetPosition(obj_shotfade,x,y);
  227. Obj_SetSpeed(obj_shotfade,5);
  228. Obj_SetAngle(obj_shotfade,dir);
  229. ObjEffect_SetRenderState(obj_shotfade,ALPHA);
  230. Obj_SetAlpha(obj_shotfade,10);
  231. ObjEffect_SetTexture(obj_shotfade,plshot);
  232. ObjEffect_SetPrimitiveType(obj_shotfade,PRIMITIVE_TRIANGLEFAN);
  233. ObjEffect_CreateVertex(obj_shotfade,4);
  234. ObjEffect_SetVertexUV(obj_shotfade,0,0,113);
  235. ObjEffect_SetVertexUV(obj_shotfade,1,18,113);
  236. ObjEffect_SetVertexUV(obj_shotfade,2,18,171);
  237. ObjEffect_SetVertexUV(obj_shotfade,3,0,171);
  238. ObjEffect_SetVertexXY(obj_shotfade,0,-8,-16);
  239. ObjEffect_SetVertexXY(obj_shotfade,1,8,-16);
  240. ObjEffect_SetVertexXY(obj_shotfade,2,8,16);
  241. ObjEffect_SetVertexXY(obj_shotfade,3,-8,16);
  242. while(!Obj_BeDeleted(obj_shotfade))
  243. {
  244.  
  245. if (fcount >= 0 && fcount < 5)
  246. {
  247. ObjEffect_SetVertexUV(obj_shotfade,0,0,113);
  248. ObjEffect_SetVertexUV(obj_shotfade,1,18,113);
  249. ObjEffect_SetVertexUV(obj_shotfade,2,18,171);
  250. ObjEffect_SetVertexUV(obj_shotfade,3,0,171);
  251. }
  252.  
  253. if (fcount >= 5 && fcount < 10)
  254. {
  255. ObjEffect_SetVertexUV(obj_shotfade,0,0,50);
  256. ObjEffect_SetVertexUV(obj_shotfade,1,18,50);
  257. ObjEffect_SetVertexUV(obj_shotfade,2,18,108);
  258. ObjEffect_SetVertexUV(obj_shotfade,3,0,108);
  259. }
  260.  
  261. if (fcount >= 10 && fcount < 15)
  262. {
  263. ObjEffect_SetVertexUV(obj_shotfade,0,0,0);
  264. ObjEffect_SetVertexUV(obj_shotfade,1,18,0);
  265. ObjEffect_SetVertexUV(obj_shotfade,2,18,51);
  266. ObjEffect_SetVertexUV(obj_shotfade,3,0,51);
  267. }
  268.  
  269. if (fcount >= 15)
  270. {
  271. Obj_Delete(obj_shotfade);
  272. return;
  273. }
  274.  
  275. fcount ++;
  276. yield;
  277. }
  278. }
  279. while(!Obj_BeDeleted(obj))
  280. {
  281. x = Obj_GetX(obj);
  282. y = Obj_GetY(obj);
  283. dir = Obj_GetAngle(obj);
  284. yield;
  285. }
  286. ShotFade(x,y,dir);
  287.  
  288. }
  289.  
  290. task rarshot(x,y,speed,dir,graphic,dmg)
  291. {
  292. let obj = Obj_Create(OBJ_SHOT);
  293. let timer = 0;
  294. let boost = 5;
  295.  
  296. Obj_SetPosition(obj,x,y);
  297. Obj_SetSpeed(obj,speed);
  298. Obj_SetAngle(obj,dir);
  299. Obj_SetAlpha(obj,200);
  300. ObjShot_SetGraphic(obj,graphic);
  301. ObjShot_SetDamage(obj,dmg);
  302. ObjShot_SetPenetration(obj,1);
  303. Obj_SetAutoDelete(obj,true);
  304.  
  305. task ShotFade(x,y,dir)
  306. {
  307. let fcount = 0;
  308. let obj_shotfade = Obj_Create(OBJ_EFFECT);
  309. Obj_SetAutoDelete(obj_shotfade,true);
  310. Obj_SetPosition(obj_shotfade,x,y);
  311. Obj_SetSpeed(obj_shotfade,5);
  312. Obj_SetAngle(obj_shotfade,dir);
  313. ObjEffect_SetRenderState(obj_shotfade,ALPHA);
  314. Obj_SetAlpha(obj_shotfade,10);
  315. ObjEffect_SetTexture(obj_shotfade,plshot);
  316. ObjEffect_SetPrimitiveType(obj_shotfade,PRIMITIVE_TRIANGLEFAN);
  317. ObjEffect_CreateVertex(obj_shotfade,4);
  318. ObjEffect_SetVertexUV(obj_shotfade,0,0,113);
  319. ObjEffect_SetVertexUV(obj_shotfade,1,18,113);
  320. ObjEffect_SetVertexUV(obj_shotfade,2,18,171);
  321. ObjEffect_SetVertexUV(obj_shotfade,3,0,171);
  322. ObjEffect_SetVertexXY(obj_shotfade,0,-8,-16);
  323. ObjEffect_SetVertexXY(obj_shotfade,1,8,-16);
  324. ObjEffect_SetVertexXY(obj_shotfade,2,8,16);
  325. ObjEffect_SetVertexXY(obj_shotfade,3,-8,16);
  326. while(!Obj_BeDeleted(obj_shotfade))
  327. {
  328.  
  329. if (fcount >= 0 && fcount < 5)
  330. {
  331. ObjEffect_SetVertexUV(obj_shotfade,0,0,113);
  332. ObjEffect_SetVertexUV(obj_shotfade,1,18,113);
  333. ObjEffect_SetVertexUV(obj_shotfade,2,18,171);
  334. ObjEffect_SetVertexUV(obj_shotfade,3,0,171);
  335. }
  336.  
  337. if (fcount >= 5 && fcount < 10)
  338. {
  339. ObjEffect_SetVertexUV(obj_shotfade,0,0,50);
  340. ObjEffect_SetVertexUV(obj_shotfade,1,18,50);
  341. ObjEffect_SetVertexUV(obj_shotfade,2,18,108);
  342. ObjEffect_SetVertexUV(obj_shotfade,3,0,108);
  343. }
  344.  
  345. if (fcount >= 10 && fcount < 15)
  346. {
  347. ObjEffect_SetVertexUV(obj_shotfade,0,0,0);
  348. ObjEffect_SetVertexUV(obj_shotfade,1,18,0);
  349. ObjEffect_SetVertexUV(obj_shotfade,2,18,51);
  350. ObjEffect_SetVertexUV(obj_shotfade,3,0,51);
  351. }
  352.  
  353. if (fcount >= 15)
  354. {
  355. Obj_Delete(obj_shotfade);
  356. return;
  357. }
  358.  
  359. fcount ++;
  360. yield;
  361. }
  362. }
  363.  
  364. task Trail(x,y,dir)
  365. {
  366. let fcount = 0;
  367. let obj_trail = Obj_Create(OBJ_EFFECT);
  368. Obj_SetAutoDelete (obj_trail,true);
  369. Obj_SetPosition(obj_trail,x,y);
  370. Obj_SetSpeed(obj_trail,0);
  371. Obj_SetAngle(obj_trail,dir);
  372. ObjEffect_SetRenderState(obj_trail,ADD);
  373. Obj_SetAlpha(obj_trail,10);
  374. ObjEffect_SetTexture(obj_trail,plshot);
  375. ObjEffect_SetPrimitiveType(obj_trail,PRIMITIVE_TRIANGLEFAN);
  376. ObjEffect_CreateVertex(obj_trail,4);
  377.  
  378. ObjEffect_SetVertexUV(obj_trail,0,1,177);
  379. ObjEffect_SetVertexUV(obj_trail,1,15,177);
  380. ObjEffect_SetVertexUV(obj_trail,2,15,203);
  381. ObjEffect_SetVertexUV(obj_trail,3,1,203);
  382.  
  383. ObjEffect_SetVertexXY(obj_trail,0,-8,-16);
  384. ObjEffect_SetVertexXY(obj_trail,1,8,-16);
  385. ObjEffect_SetVertexXY(obj_trail,2,8,16);
  386. ObjEffect_SetVertexXY(obj_trail,3,-8,16);
  387. loop(5)
  388. {
  389.  
  390. if (fcount >= 0 && fcount < 3)
  391. {
  392. ObjEffect_SetVertexUV(obj_trail,0,1,177);
  393. ObjEffect_SetVertexUV(obj_trail,1,15,177);
  394. ObjEffect_SetVertexUV(obj_trail,2,15,203);
  395. ObjEffect_SetVertexUV(obj_trail,3,1,203);
  396. fcount ++;
  397. }
  398.  
  399. if (fcount >= 3 && fcount < 6)
  400. {
  401. ObjEffect_SetVertexUV(obj_trail,0,1,150);
  402. ObjEffect_SetVertexUV(obj_trail,1,15,150);
  403. ObjEffect_SetVertexUV(obj_trail,2,15,176);
  404. ObjEffect_SetVertexUV(obj_trail,3,1,176);
  405. fcount ++;
  406. }
  407.  
  408. if (fcount >= 6 && fcount < 9)
  409. {
  410. ObjEffect_SetVertexUV(obj_trail,0,1,123);
  411. ObjEffect_SetVertexUV(obj_trail,1,15,123);
  412. ObjEffect_SetVertexUV(obj_trail,2,15,149);
  413. ObjEffect_SetVertexUV(obj_trail,3,1,149);
  414. fcount ++;
  415. }
  416.  
  417. if (fcount >= 9)
  418. {
  419. Obj_Delete(obj_trail);
  420. return;
  421. }
  422. yield;
  423. }
  424. }
  425.  
  426. while(!Obj_BeDeleted(obj))
  427. {
  428. x = Obj_GetX(obj);
  429. y = Obj_GetY(obj);
  430. dir = Obj_GetAngle(obj);
  431. loop
  432. {
  433. Obj_SetSpeed(obj,speed);
  434. speed+=0.5;
  435. Trail(Obj_GetX(obj),Obj_GetY(obj),dir);
  436. yield;
  437. }
  438. yield;
  439. }
  440. ShotFade(x,y,dir);
  441.  
  442. }
  443.  
  444. function wait(w){loop(w){yield;}}
  445. }
  446.  
  447. //spellcard
  448.  
  449. script_spell bombSC
  450. {
  451.  
  452. let CSD = GetCurrentScriptDirectory;
  453. let back = CSD ~ "icefield.png";
  454. let cut = CSD ~ "cut.png";
  455.  
  456. @Initialize
  457. {
  458. SetPlayerInvincibility(360);
  459. LoadGraphic(back);
  460. LoadGraphic(cut);
  461.  
  462.  
  463. SpellTask;
  464. }
  465.  
  466. @MainLoop
  467. {
  468. CollectItems;
  469. yield;
  470. }
  471.  
  472. @Finalize
  473. {
  474.  
  475. }
  476.  
  477. task SpellTask
  478. {
  479. ice;
  480. wait(180);
  481. End;
  482. }
  483.  
  484. task ice
  485. {
  486. let objj = Obj_Create(OBJ_EFFECT);
  487. let obj = Obj_Create(OBJ_SPELL);
  488. let scroll = 10;
  489. let scroll2 = 13;
  490. let xc = 2;
  491. let counter = 0;
  492. let alph = 5;
  493. ObjEffect_SetTexture(objj,back);
  494. ObjEffect_SetRenderState(objj, ALPHA);
  495. Obj_SetAlpha(objj, 210);
  496. ObjEffect_SetLayer(objj, 1);
  497. ObjEffect_CreateVertex(objj, 4);
  498. ObjEffect_SetPrimitiveType(objj, PRIMITIVE_TRIANGLEFAN);
  499. ObjEffect_SetVertexUV(objj, 0, 0, 0);
  500. ObjEffect_SetVertexUV(objj, 1, 255, 0);
  501. ObjEffect_SetVertexUV(objj, 2, 255, 255);
  502. ObjEffect_SetVertexUV(objj, 3, 0, 255);
  503. while(! Obj_BeDeleted(objj))
  504. {
  505. ObjEffect_SetVertexUV(objj, 0, 0 - scroll2, 0 - scroll);
  506. ObjEffect_SetVertexUV(objj, 1, 255 - scroll2, 0 - scroll);
  507. ObjEffect_SetVertexUV(objj, 2, 255 - scroll2, 255 - scroll);
  508. ObjEffect_SetVertexUV(objj, 3, 0 - scroll2, 255 - scroll);
  509. ObjEffect_SetVertexXY(objj, 0, 0, 0);
  510. ObjEffect_SetVertexXY(objj, 1, 448, 0);
  511. ObjEffect_SetVertexXY(objj, 2, 448, 480);
  512. ObjEffect_SetVertexXY(objj, 3, 0, 480);
  513. scroll-=xc;
  514. scroll2-=xc;
  515. xc = 2;
  516. while(scroll>=255)
  517. {
  518. scroll-=255;
  519. }
  520. while(scroll2>=255)
  521. {
  522. scroll2-=255;
  523. }
  524. if(counter<50)
  525. {
  526. alph+=10;
  527. }
  528. if(counter>180)
  529. {
  530. alph-=40;
  531. }
  532. ObjEffect_SetVertexColor(objj, 0, alph, 255, 255, 255);
  533. ObjEffect_SetVertexColor(objj, 1, alph, 255, 255, 255);
  534. ObjEffect_SetVertexColor(objj, 2, alph, 255, 255, 255);
  535. ObjEffect_SetVertexColor(objj, 3, alph, 255, 255, 255);
  536. if(counter==180)
  537. {
  538. ObjSpell_SetIntersecrionCircle(obj,GetCenterY,GetCenterX,400,8,true);
  539. yield;
  540. Obj_Delete(objj);
  541. Obj_Delete(obj);
  542. }
  543. yield;
  544. counter++;
  545. }
  546. }
  547.  
  548. function wait(w){loop(w){yield;}}
  549. }
Advertisement
Add Comment
Please, Sign In to add comment