?login_element?

Subversion Repositories NedoOS

Rev

Rev 962 | Blame | Compare with Previous | Last modification | View Log | Download

  1. #ifndef LEVEL4_C
  2. #define LEVEL4_C
  3. #include "gameloop.c"
  4. #include "level_fragments.h"
  5. #include "engine.c"
  6. #include "resources.h"
  7. #include "dialogs.c"
  8. #include "gameloop.c"
  9. #include "sprite_pool.c"
  10. u8 l4s = 0;
  11.  
  12. //static void init_level(u8 image);
  13. //static void start_level(u8 image, u8 *name);
  14. static void init_level(u8 pal, char *fn);
  15. static void start_level(u8 pal, char *fn, u8 *name);
  16.  
  17. void process_level4();
  18.  
  19. const u8 level4[] = {
  20.     MakeCaravan(60, EYE, 1, 20, BONUS_CARD),
  21.     Nop(10),
  22.     MakeLeftFlyers(100, BAT, 5, 0),
  23.     AimedCircle(FIREBALL, 10, 2),
  24.     MakeRightFlyers(150, BAT, 5, 0),
  25.     AimedCircle(FIREBALL, 10, 2),
  26.     MakeLeftFlyers(180, BAT, 5, 0),
  27.     AimedCircle(FIREBALL, 10, 2),
  28.     MakeRightFlyers(50, BAT, 5, 0),
  29.     AimedCircle(FIREBALL, 10, 2),
  30.     Nop(20),
  31.     MakeShootingStar(160, 80, ICEBALL, 10, 30),
  32.     Nop(10),
  33.     MakeCorridor(GHOST, 41, 10, BONUS_CARD),
  34.     Nop(10),
  35.     AimedSideEnemies(KNIFE_LEFT, 10, 10),
  36.     Nop(5),
  37.     Triangle(EYE, 30, HEALTH_CARD),
  38.     Nop(4),
  39.     MakeEnemyWave(BAT, 10, 20),
  40.     MakeBoomFairy(50, 50, HEALTH_CARD),
  41.     Nop(10),
  42.     PushNpc(30, -20, 1, 1, EYE, 33, 15, 0),
  43.     PushNpc(280, -20, -1, 1, EYE, 33, 15, 0),
  44.     PushNpc(62, -20, 1, 1, EYE, 33, 15, 0),
  45.     PushNpc(218, -20, -1, 1, EYE, 33, 15, 0),
  46.     PushNpc(160, -20, -1, 1, EYE, 33, 15, 0),
  47.     AimedShoot(33, 10),
  48.     SetNpcSpeed(33, 0, 5),
  49.     Nop(20),
  50.     MakeEnemiesPair(BAT, 3, 30),
  51.     MakeCaravan(20, EYE, 30, 40, HEALTH_CARD),
  52.     Nop(10),
  53.     MakeShootingStar(70, 60, FIREBALL, 20, 20),
  54.     MakeShootingStar(250, 80, ICEBALL, 20, 20),
  55.     AimedCircle(FIREBALL, 10, 10),
  56.     MidBoss2(EYE, 100),
  57.     Nop(10),
  58.     DroppedEnemy(30, FIREBALL, 10),
  59.     DroppedEnemy(230, FIREBALL, 10),
  60.     DroppedEnemy(130, FIREBALL, 10),
  61.     Nop(10),
  62.     DroppedEnemy(50, FIREBALL, 10),
  63.     DroppedEnemy(80, FIREBALL, 10),
  64.     DroppedEnemy(180, FIREBALL, 10),
  65.     Nop(10),
  66.     DroppedEnemy(3, FIREBALL, 10),
  67.     DroppedEnemy(74, FIREBALL, 10),
  68.     DroppedEnemy(32, FIREBALL, 10),
  69.     Nop(10),
  70.     DroppedEnemy(210, FIREBALL, 10),
  71.     DroppedEnemy(11, FIREBALL, 10),
  72.     DroppedEnemy(63, FIREBALL, 10),
  73.     Nop(10),
  74.     TriangleHalf(1, EYE, 30, BONUS_CARD),
  75.     Nop(10),
  76.     MakeEnemyWave(GHOST, 30, 30),
  77.     Nop(16),
  78.     PushNpc(160, -20, 0, 1, FLANDRE, BOSS_TYPE, 2000, 0),
  79.     Nop(15),
  80.     End
  81. };
  82.  
  83. const u8 level4_2[] = {
  84.     MakeCaravan(32, BOOK, 1, 10, BONUS_CARD),
  85.     Nop(10),
  86.     MakeBoomFairy(100, 30, HEALTH_CARD),
  87.     Nop(10),
  88.     Triangle(BAT, 30, 0),
  89.     MakeLeftFlyers(120, BOOK, 20, BONUS_CARD),
  90.     JustStar(160, 120, 5),
  91.     MakeRightFlyers(40, BOOK, 20, BONUS_CARD),
  92.     Nop(10),
  93.     MakeShootingStar(70, 70, FIREBALL, 44, 20),
  94.     MakeShootingStar(180, 90, ICEBALL, 33, 20),
  95.     JustStar(160,120, 5),
  96.     Nop(20),
  97.     DroppedEnemy(30, BOOK, 10),
  98.     DroppedEnemy(230, BOOK, 10),
  99.     DroppedEnemy(130, BOOK, 10),
  100.     AimedCircle(FIREBALL, 5, 1),
  101.     Nop(10),
  102.     DroppedEnemy(50, BOOK, 10),
  103.     DroppedEnemy(80, BOOK, 10),
  104.     DroppedEnemy(180, BOOK, 10),
  105.     DroppedEnemy(3, BOOK, 10),
  106.     AimedCircle(FIREBALL, 5, 1),
  107.     Nop(10),
  108.     DroppedEnemy(74, BOOK, 10),
  109.     DroppedEnemy(32, BOOK, 10),
  110.     AimedCircle(FIREBALL, 5, 1),
  111.     DroppedEnemy(210, BOOK, 10),
  112.     DroppedEnemy(11, BOOK, 10),
  113.     Nop(5),
  114.     AimedCircle(FIREBALL, 5, 1),
  115.     Nop(10),
  116.     DroppedEnemy(63, BOOK, 10),
  117.     Nop(10),
  118.     AimedSideEnemies(KNIFE_LEFT, 1, 10),
  119.     Nop(10),
  120.     MakeEnemyWave(BOOK, 20, 10),
  121.     Nop(10),
  122.     MakeEnemiesPair(EYE, 99, 30),
  123.     Nop(5),
  124.     TriangleHalf(1, EYE, 30, BONUS_CARD),
  125.     Nop(10),
  126.     DroppedEnemy(30, FIREBALL, 10),
  127.     DroppedEnemy(230, BOOK, 10),
  128.     DroppedEnemy(130, FIREBALL, 10),
  129.     Nop(10),
  130.     DroppedEnemy(50, BOOK, 10),
  131.     DroppedEnemy(80, FIREBALL, 10),
  132.     DroppedEnemy(180, BOOK, 10),
  133.     Nop(10),
  134.     JustStar(160,120, 5),
  135.     Nop(10),
  136.     DroppedEnemy(3, FIREBALL, 10),
  137.     DroppedEnemy(74, FIREBALL, 10),
  138.     DroppedEnemy(32, BOOK, 10),
  139.     Nop(10),
  140.     DroppedEnemy(210, BOOK, 10),
  141.     DroppedEnemy(11, FIREBALL, 10),
  142.     DroppedEnemy(63, BOOK, 10),
  143.     Nop(10),
  144.     Triangle(EYE, 30, BONUS_CARD),
  145.     Nop(10),
  146.     MakeBoomFairy(100, 30, HEALTH_CARD),
  147.     Nop(10),
  148.     MakeShootingStar(60, 70, BOOK, 33, 33),
  149.     MakeShootingStar(180, 90, BOOK, 33, 33),
  150.     MakeShootingStar(160, 120, BOOK, 33, 33),
  151.     Nop(10),
  152.     PushNpc(160, -20, 0, 1, PATCHULY, BOSS_TYPE, 2000, 0),
  153.     Nop(20),
  154.     End
  155. };
  156.  
  157. void init_level4()
  158. {
  159.     level_loop = 0;
  160.     l4s = 0;
  161.     flush_sprites();
  162.     //start_level(IMG256_BG7, "Looking for Patchuly Knowlege");
  163. start_level(PAL256_BG7, "bg7-16.bmp", "Looking for Patchuly Knowlege");
  164.     music_play(MUS_ZONK);
  165.     bullet_sprite = DEFAULT_BULLET;
  166.     state = STATE_PLAY;
  167.     init_vm(level4);
  168.     process_level = process_level4;
  169.     scroll_speed = 1;
  170. }
  171.  
  172. void dialog_l4p2()
  173. {
  174.     init_dialog();
  175.     swap_screen();
  176.     put_dialog_string(FLAN_FACE, "So...\nYou've played with me!\nWhat do you want?", 0);
  177.     put_dialog_string(REIMU_FACE, "I'm flying to kick\nyour bookworm's ass!", 1);
  178.     put_dialog_string(FLAN_FACE, "Sister Flan is sitting\nin the library!", 0);
  179. //swap_screen();
  180.     wait_for_space();
  181.     //init_level(IMG256_BG7);
  182. init_level(0/*PAL256_BG7*/, "bg7-16.bmp");
  183. unpack_pal256(PAL256_BG7, 0);
  184.     state = STATE_PLAY;
  185.     process_level = process_level4;
  186.     bullet_sprite = DEFAULT_BULLET;
  187.     init_vm(level4_2);
  188. }
  189.  
  190. const u8 patch_vm[] = {
  191.     Nop(20),
  192.     AimedShoot(BOSS_TYPE, 10),
  193.     Nop(20),
  194.     PushNpc(32, -20, 0, 1, MAID, 254, 50, HEALTH_CARD),
  195.     PushNpc(280, -20, 0, 1, FLANDRE, 254, 50, HEALTH_CARD),
  196.     Nop(10),
  197.     SetNpcSpeed(254, 0, 0),
  198.     AimedShoot(254, 10),
  199.     SetNpcSpeed(254, 0, -3),
  200.     Nop(10),
  201.     AimedCircle(FIREBALL, 1, 3),
  202.     Nop(10),
  203.     AimedCircle(FIREBALL, 1, 3),
  204.     Nop(10),
  205.     AimedCircle(FIREBALL, 1, 3),
  206.     End
  207. };
  208.  
  209. u8 leftBonus = 0;
  210.  
  211. void last_dialog()
  212. {
  213.     init_dialog();
  214.     swap_screen();
  215.     put_dialog_string(PACHU_FACE, "Please stop!\nWhat a noise in my\nlibrary?", 0);
  216.     put_dialog_string(REIMU_FACE, "I NEED TO TALK WITH YOU!\nAnd \"thank you\" Marisa for\n\"help\"", 1);
  217.     put_dialog_string(MARISA_FACE, "I've sent you\nhealthing and my power!", 0);
  218. //swap_screen();
  219.     wait_for_space(); init_dialog();
  220.     swap_screen();
  221.     put_dialog_string(REIMU_FACE, "Like a drunken sniper...", 1);
  222.     put_dialog_string(FLAN_FACE, "So...\nWhat do you want from\nmy sister?!", 0);
  223.     put_dialog_string(REIMU_FACE, "My donations box is lost!\nHave you taken it for\nyour books?", 1);
  224. //swap_screen();
  225.     wait_for_space(); init_dialog();
  226.     swap_screen();
  227.     put_dialog_string(PACHU_FACE, "What?\n", 0);
  228.     put_dialog_string(REIMU_FACE, "Also, Komano is lost...", 1);
  229.     put_dialog_string(PACHU_FACE, "Oh, she came to me and\nasked for books about\nbox repairing...", 0);
  230. //swap_screen();
  231.     wait_for_space(); init_dialog();
  232.     swap_screen();
  233.     put_dialog_string(PACHU_FACE, "She went to the repair\nmaster. But you made\nall this noise!", 0);
  234.     put_dialog_string(REIMU_FACE, "Okeey, as an apology, I'm\nwaiting for everyone to\nget drunk tonight.", 1);
  235.     put_dialog_string(CIRNO_FACE, "I'll be there!", 0);
  236. //swap_screen();
  237.     wait_for_space(); init_dialog();
  238.     swap_screen();
  239.     put_dialog_string(REIMU_FACE, "But how do you appear\nhere?!", 1);
  240.     put_dialog_string(CIRNO_FACE, "Cause I'm the strongest!And Sakuya just opened\nthe door..", 0);
  241.     put_dialog_string(REIMU_FACE, "Fi-i-inee!\nLet's drink tonight!\nAnd even Cirno-tan.", 1);
  242. //swap_screen();
  243.     wait_for_space();
  244.     state = STATE_WIN;
  245. }
  246.  
  247. void process_patchu()
  248. {
  249.     Npc *boss;
  250.    
  251.     boss = find_npc_by_type(BOSS_TYPE);
  252.     if (!boss) {
  253.         last_dialog();
  254.         return ;
  255.     }
  256.  
  257.     if (!executing) {
  258.         init_vm(patch_vm);
  259.     }
  260.  
  261.     vm_step();
  262.  
  263.     if (boss->sprite.x > 280 || boss->sprite.x < 30)
  264.         boss->sprite.dx = -boss->sprite.dx;
  265.  
  266.     if (scroll_pos < 2 || scroll_pos > 300/*260*/) {
  267.         scroll_speed = -scroll_speed;
  268.     }
  269.  
  270.     if (hor_scroll_pos < 2 || hor_scroll_pos > 195) {
  271.         hor_scroll_speed = -hor_scroll_speed;
  272.     }
  273.    
  274.     switch (level_loop % 60) {
  275.         boss_shoot1(0, boss->sprite.x, boss->sprite.y)
  276.         just_star(30, boss->sprite.x + 16, boss->sprite.y + 16)
  277.         just_star(35, boss->sprite.x + 16, boss->sprite.y + 16)
  278.         just_star(40, boss->sprite.x + 16, boss->sprite.y + 16)
  279.         just_star(45, boss->sprite.x + 16, boss->sprite.y + 16)
  280.         case 59:
  281.             if (leftBonus) {
  282.                 push_bonus(HEALTH_CARD, 10, 80, 2, -5);
  283.                 push_bonus(BONUS_CARD, 100, 80, 0, -5);
  284.                 push_bonus(HEALTH_CARD, 30, 80, 2, -5);
  285.             } else {
  286.                 push_bonus(HEALTH_CARD, 160, 80, 0, -5);
  287.                 push_bonus(BONUS_CARD, 260, 80, -2, -5);
  288.                 push_bonus(BONUS_CARD, 280, 80, -2, -5);    
  289.             }
  290.             leftBonus = !leftBonus;
  291.             break;
  292.        
  293.     }
  294.  
  295. }
  296.  
  297. void dialog_l4p3()
  298. {
  299.     init_dialog();
  300.     swap_screen();
  301.     put_dialog_string(PACHU_FACE, "What a noise?!", 0);
  302.     put_dialog_string(REIMU_FACE, "Oh...\nI've found you!", 1);
  303.     put_dialog_string(PACHU_FACE, "Please, stop this noise!", 0);
  304. //swap_screen();
  305.     wait_for_space();
  306.     init_dialog();
  307.     swap_screen();
  308.     put_dialog_string(REIMU_FACE, "I need to talk with you.", 1);
  309. //swap_screen();
  310.     wait_for_space();
  311.     //init_level(IMG256_BG8);
  312. music_stop();
  313. init_level(PAL256_BG8, "bg8-16.bmp");
  314.     pal_bright(BRIGHT_MIN);
  315.     swap_screen();
  316.     //unpack_pal256(PAL256_BG8, 0);
  317.     //unpack_pal16(PAL16_SPRITES, 15, 0);
  318.     pal_bright(BRIGHT_MID);
  319.     swap_screen();
  320.     process_level = process_patchu;
  321.     music_play(MUS_TH0PN);
  322.     state = STATE_PLAY;
  323.     scroll_pos = 192;
  324.     hor_scroll_pos = 150;
  325.     scroll_speed = -3;
  326.     hor_scroll_speed = 3;
  327.     push_npc(160, 32, 2, 0, PATCHULY, BOSS_TYPE, 1024, 0);
  328.     bullet_sprite = BULLET2;
  329.     level_loop = 0;
  330.     init_vm(patch_vm);
  331. }
  332.  
  333. void process_flandre()
  334. {
  335.     Npc *boss;
  336.     Npc *bossClone;
  337.  
  338.     boss = find_npc_by_type(BOSS_TYPE);
  339.     bossClone = find_npc_by_type(254);
  340.  
  341.     if (boss) {
  342.          if (boss->sprite.x <= 20 || boss->sprite.x >= 280)
  343.         {
  344.             boss->sprite.dx = -boss->sprite.dx;
  345.             boss->sprite.x += boss->sprite.dx;
  346.         }
  347.         if (boss->sprite.y <= 20 || boss->sprite.y >= 120)
  348.         {
  349.             boss->sprite.dy = -boss->sprite.dy;
  350.             boss->sprite.y += boss->sprite.dy;
  351.         }
  352.  
  353.         if (bossClone) {
  354.             if (bossClone->sprite.x <= 20 || bossClone->sprite.x >= 280)
  355.             {
  356.                 bossClone->sprite.dx = -bossClone->sprite.dx;
  357.                 bossClone->sprite.x += bossClone->sprite.dx;
  358.             }
  359.             if (bossClone->sprite.y <= 20 || bossClone->sprite.y >= 120)
  360.             {
  361.                 bossClone->sprite.dy = -bossClone->sprite.dy;
  362.                 bossClone->sprite.y += bossClone->sprite.dy;
  363.             }
  364.         }
  365.  
  366.         if (level_loop % 10 < 4) {
  367.             push_star(boss->sprite.x + 16, boss->sprite.y + 16);
  368.             if (bossClone) push_star(bossClone->sprite.x + 16, bossClone->sprite.y + 16);
  369.         }
  370.  
  371.         switch (level_loop % 150)
  372.         {
  373.         case 0:
  374.             push_npc(boss->sprite.x, boss->sprite.y, -boss->sprite.dx, -boss->sprite.dy, FLANDRE, 254, 30, HEALTH_CARD);
  375.             break;
  376.         case 50:
  377.             npc_by_type_set_speed(254, 0, 330);
  378.             break;
  379.         case 100:
  380.             push_bonus(HEALTH_CARD, 160, 120, -2, -3);
  381.             push_bonus(HEALTH_CARD, 160, 120, 0, -5);
  382.             push_bonus(HEALTH_CARD, 160, 120, 2, 3);
  383.             push_bonus(BONUS_CARD, 160, 100, -2, -3);
  384.             push_bonus(BONUS_CARD, 160, 100, 0, -5);
  385.             push_bonus(BONUS_CARD, 160, 100, 2, 3);
  386.             break;
  387.         }
  388.     } else {
  389.         dialog_l4p2();
  390.     }
  391. }
  392.  
  393. void dialog_l4p1()
  394. {
  395.     init_dialog();
  396.     swap_screen();
  397.     put_dialog_string(FLAN_FACE, "Hello, Reddy-sister!\nAre you gonna play with me?", 0);
  398.     put_dialog_string(REIMU_FACE, "Flan, I have no time\nfor this!", 1);
  399.     put_dialog_string(FLAN_FACE, "Oh sister...\nYou'll play with me!", 0);
  400. //swap_screen();
  401.     bullet_sprite = FLAN_BULLET;
  402.     process_level = process_flandre;
  403.     wait_for_space();
  404.     //init_level(IMG256_BG7);
  405. init_level(0/*PAL256_BG7*/, "bg7-16.bmp");
  406. unpack_pal256(PAL256_BG7, 0);
  407.     push_npc(32, 32, 2, 3, FLANDRE, BOSS_TYPE, 500, HEALTH_CARD);
  408.     state = STATE_PLAY;
  409. }
  410.  
  411. void process_level4()
  412. {
  413.     if (executing) {
  414.         vm_step();
  415.     } else {
  416.         switch (l4s) {
  417.             case 0:
  418.                 l4s++;
  419.                 dialog_l4p1();
  420.                 break;
  421.             case 1:
  422.                 dialog_l4p3();
  423.                 break;
  424.         }
  425.     }
  426. }
  427.  
  428. #endif
  429.