Guest User

Untitled

a guest
Dec 8th, 2019
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #TouhouDanmakufu[Player]
  2. #ScriptVersion[3]
  3. #ID["PERSON_B"]
  4. #Title["Person B"]
  5. #Text["Person B"]
  6. #Image["./protag_select.png"]
  7. #ReplayName["PersonA"]
  8.  
  9. let CSD = GetCurrentScriptDirectory;
  10. let playerID = GetPlayerObjectID;
  11. let playerObj = ObjPrim_Create(OBJ_SPRITE_2D);
  12. let hitboxObj = ObjPrim_Create(OBJ_SPRITE_2D);
  13. let count = -1;
  14. let isFocus = false;
  15. let playerdeadSFX = CSD ~ "DEAD.wav";
  16. let spellSFX = CSD ~ "LASER2.wav";
  17. //shot sheet
  18. let shotPerson = CSD ~ "playershot.txt";
  19.  
  20. //texture sheet
  21. let playerSprite = CSD ~ "player.png";
  22.  
  23. //spell card effect texture
  24. let spellTex = CSD ~ "spelleffect.png";
  25.  
  26. ObjPlayer_AddIntersectionCircleA1(playerID, 0, 0, 1, 20);
  27.  
  28.  
  29. @Initialize {
  30.  
  31. LoadSound(playerdeadSFX);
  32. LoadSound(spellSFX);
  33. LoadPlayerShotData(shotPerson);
  34.  
  35. SetPlayerSpeed (5,2.5);
  36.  
  37. //set hitbox
  38. ObjPlayer_AddIntersectionCircleA1(playerID,0,0,2,16);
  39.  
  40. //set how far your player can move in the feild
  41. SetPlayerClip(0+6,0+24,384-6,448-16);
  42.  
  43. //set how long your player is gone when dead
  44. SetPlayerDownStateFrame(60);
  45.  
  46. //set how long you have to deathbomb
  47. SetPlayerRebirthFrame(35);
  48.  
  49. //set auto collection line
  50. SetPlayerAutoItemCollectLine(120);
  51.  
  52.  
  53. renderPlayer;
  54. renderHitBox;
  55.  
  56.  
  57.  
  58. }
  59.  
  60. task TExplosion{
  61. let path = GetCurrentScriptDirectory() ~ "player.png";
  62. let obj = ObjPrim_Create(OBJ_SPRITE_2D);
  63. ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
  64. Obj_SetRenderPriority(obj, 0.60);
  65. ObjPrim_SetTexture(obj, path);
  66. ObjSprite2D_SetSourceRect(obj, 192, 0, 255, 63);
  67. ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
  68.  
  69. let alpha = 255;
  70. let scale = 0;
  71. loop(30)
  72. {
  73. scale += 0.2;
  74. alpha -= 8;
  75. ObjRender_SetColor(obj, alpha, alpha, alpha);
  76. ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
  77. ObjRender_SetScaleXYZ(obj, scale, scale, 1);
  78. yield;
  79. }
  80. Obj_Delete(obj);
  81. }
  82.  
  83. @Event {
  84. alternative(GetEventType)
  85.  
  86. //spell card
  87. case(EV_REQUEST_SPELL) {
  88. if (GetPlayerSpell > 0) {
  89. SetScriptResult(true);
  90. SetPlayerSpell(GetPlayerSpell - 1);
  91. spellCard;
  92. }
  93. else {
  94. SetScriptResult(false);
  95. }
  96.  
  97.  
  98. }
  99.  
  100. //player is dead
  101. case(EV_PLAYER_SHOOTDOWN){
  102. PlaySE(playerdeadSFX);
  103. TExplosion;
  104. wait(10);
  105. ObjRender_SetAlpha(playerObj,0);
  106.  
  107. SetForbidPlayerShot(true);
  108. SetForbidPlayerSpell(true);
  109.  
  110. }
  111.  
  112. //player is reviving
  113. case(EV_PLAYER_REBIRTH) {
  114. SetForbidPlayerShot(false);
  115. SetForbidPlayerSpell(false);
  116. ObjRender_SetAlpha(playerObj,255);
  117. SetPlayerInvincibilityFrame(120);
  118. SetPlayerSpell(3);
  119. }
  120.  
  121. }
  122.  
  123. @MainLoop{
  124.  
  125.  
  126. if(IsPermitPlayerShot) {
  127. if(GetVirtualKeyState(VK_SHOT) == KEY_PUSH || GetVirtualKeyState(VK_SHOT) == KEY_HOLD) {
  128. count++;
  129. if(count>=5) {
  130. count = 0;
  131. }
  132. }
  133. if(GetVirtualKeyState(VK_SHOT) == KEY_PULL) {
  134. count = -1;
  135. }
  136.  
  137.  
  138. //focus shot
  139.  
  140. if(isFocus){
  141. if(count>3) {
  142. //location x, location y, speed, dorection, damage, penetration, ID
  143. CreatePlayerShotA1(GetPlayerX-3,GetPlayerY-20,20,270,5,1,1);
  144. CreatePlayerShotA1(GetPlayerX+3,GetPlayerY-20,20,270,5,1,1);
  145. }
  146. }
  147.  
  148. //regular shot
  149.  
  150. else {
  151. if(count>3) {
  152. CreatePlayerShotA1(GetPlayerX-8,GetPlayerY-20,20,260,4,1,1);
  153. CreatePlayerShotA1(GetPlayerX,GetPlayerY-20,20,270,4,1,1);
  154. CreatePlayerShotA1(GetPlayerX+8,GetPlayerY-20,20,280,4,1,1);
  155. }
  156.  
  157.  
  158.  
  159.  
  160. yield;
  161. }
  162. }
  163. }
  164.  
  165.  
  166. task renderPlayer {
  167. ObjPrim_SetTexture(playerObj,playerSprite);
  168. Obj_SetRenderPriorityI(playerObj,31);
  169. ObjRender_SetBlendType(playerObj,BLEND_ALPHA);
  170. ObjRender_SetAngleXYZ(playerObj,0,0,0);
  171. ObjRender_SetScaleXYZ(playerObj,1,1,0);
  172. ObjRender_SetAlpha(playerObj,255);
  173. ObjSprite2D_SetSourceRect(playerObj,0,0,50,70);
  174. ObjSprite2D_SetDestCenter(playerObj);
  175. ObjRender_SetPosition(playerObj,GetPlayerX,GetPlayerY,0);
  176.  
  177. while(!Obj_IsDeleted(playerObj)){
  178. ObjRender_SetPosition(playerObj,GetPlayerX,GetPlayerY,0);
  179.  
  180. if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || GetVirtualKeyState(VK_LEFT) == KEY_HOLD) {
  181. ObjRender_SetAngleY(playerObj,0);
  182. ObjSprite2D_SetSourceRect(playerObj,90,0,50,70);
  183. }
  184. else if (GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD) {
  185. ObjRender_SetAngleY(playerObj,180);
  186. ObjSprite2D_SetSourceRect(playerObj,90,0,50,70);
  187. }
  188. else {
  189. ObjSprite2D_SetSourceRect(playerObj,0,0,50,70);
  190. }
  191.  
  192. yield;
  193.  
  194. }
  195.  
  196. }
  197.  
  198.  
  199. task renderHitBox{
  200. let alpha = 0;
  201. let spin = 0;
  202.  
  203. ObjPrim_SetTexture(hitboxObj,playerSprite);
  204. ObjRender_SetBlendType(hitboxObj,BLEND_ALPHA);
  205. Obj_SetRenderPriorityI(hitboxObj,50);
  206. ObjRender_SetAlpha(hitboxObj,0);
  207. ObjRender_SetScaleXYZ(hitboxObj,1,1,0);
  208. ObjSprite2D_SetSourceRect(hitboxObj,0,90,50,137);
  209. ObjSprite2D_SetDestCenter(hitboxObj);
  210.  
  211. while (!Obj_IsDeleted(hitboxObj)) {
  212. ObjRender_SetPosition(hitboxObj,GetPlayerX,GetPlayerY,0);
  213. ObjRender_SetAngleZ(hitboxObj,spin);
  214. ObjRender_SetAlpha(hitboxObj,alpha);
  215.  
  216. if(GetVirtualKeyState(VK_SLOWMOVE) == KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE) == KEY_HOLD){
  217. alpha = 255;
  218. }
  219. else {
  220. alpha = 0;
  221. }
  222.  
  223. spin+=2;
  224.  
  225. yield;
  226.  
  227.  
  228. }
  229. }
  230. function wait(w){
  231. loop(w) {
  232. yield;
  233. }
  234. }
  235.  
  236. task spellCard {
  237. PlaySE(spellSFX);
  238.  
  239.  
  240. //prepare
  241.  
  242. SetForbidPlayerShot(true);
  243. SetForbidPlayerSpell(true);
  244. SetPlayerInvincibilityFrame(180);
  245. SetPlayerSpeed(2,2);
  246.  
  247. // a spellcard object
  248. let spellObject = ObjSpell_Create();
  249. ObjSpell_Regist(spellObject);
  250. ObjSpell_SetEraseShot(spellObject,true);
  251.  
  252.  
  253. // bomb
  254. loop(16) {
  255. createRingEffect;
  256. TShake;
  257. ObjSpell_SetIntersectionCircle(spellObject,GetPlayerX,GetPlayerY,512);
  258.  
  259. ObjSpell_SetDamage(spellObject,10);
  260. wait(10);
  261.  
  262. }
  263.  
  264. Obj_Delete(GetSpellManageObject);
  265. //cleanup
  266. SetForbidPlayerShot(false);
  267. SetForbidPlayerSpell(false);
  268. SetPlayerSpeed(5,2.5);
  269.  
  270. task TShake
  271. { let objManage = GetSpellManageObject();
  272. while(!Obj_IsDeleted(objManage))
  273. {
  274. Set2DCameraFocusX(GetStgFrameWidth / 2 + rand(-8, 8));
  275. Set2DCameraFocusY(GetStgFrameHeight / 2 + rand(-8, 8));
  276. yield;
  277. }
  278.  
  279. Reset2DCamera();
  280. }
  281.  
  282. task createRingEffect {
  283. let scale = 0;
  284. let alpha = 200;
  285.  
  286. let obj = ObjPrim_Create(OBJ_SPRITE_2D);
  287. ObjPrim_SetTexture(obj,spellTex);
  288. ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
  289. ObjRender_SetAlpha(obj,alpha);
  290. Obj_SetRenderPriorityI(obj,41);
  291. ObjRender_SetAngleXYZ(obj,scale,scale,0);
  292. ObjSprite2D_SetSourceRect(obj,0,0,200,200);
  293. ObjSprite2D_SetDestCenter(obj);
  294. ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);
  295.  
  296. ObjRender_SetColor(obj,truncate(rand(128,255)),truncate(rand(128,255)),truncate(rand(128,255)));
  297.  
  298. while(alpha > 0) {
  299. ObjRender_SetAlpha(obj,alpha);
  300. ObjRender_SetAngleXYZ(obj,scale,scale,0);
  301.  
  302. scale+=0.4;
  303. alpha-=2;
  304.  
  305. yield;
  306.  
  307. }
  308.  
  309. Obj_Delete(obj);
  310. }
  311. }
RAW Paste Data