Subversion Repositories Games.Rick Dangerous

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * src/e_sbonus.c
  3.  *
  4.  * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
  5.  *
  6.  * The use and distribution terms for this software are contained in the file
  7.  * named README, which can be found in the root of this distribution. By
  8.  * using this software in any fashion, you are agreeing to be bound by the
  9.  * terms of this license.
  10.  *
  11.  * You must not remove this notice, or any other, from this software.
  12.  */
  13.  
  14. #include "system.h"
  15. #include "game.h"
  16. #include "ents.h"
  17. #include "e_sbonus.h"
  18.  
  19. #include "util.h"
  20. #include "maps.h"
  21. #include "e_rick.h"
  22.  
  23.  
  24. /*
  25.  * public vars
  26.  */
  27. U8 e_sbonus_counting = FALSE;
  28. U8 e_sbonus_counter = 0;
  29. U16 e_sbonus_bonus = 0;
  30.  
  31.  
  32. /*
  33.  * Entity action / start counting
  34.  *
  35.  * ASM 2182
  36.  */
  37. void e_sbonus_start (U8 e)
  38. {
  39.    if (E_RICK_STTST (E_RICK_STZOMBIE))
  40.       return;
  41.  
  42.    ent_ents[e].sprite = 0; /* invisible */
  43.  
  44.    if (u_trigbox (e, (S16) (ENT_RICK.x + 0x0C), (S16) (ENT_RICK.y + 0x0A)))
  45.    {
  46.       /* rick is within trigger box */
  47.       ent_ents[e].n = 0;
  48.       e_sbonus_counting = TRUE;   /* 6DD5 */
  49.       e_sbonus_counter = 0x1e;   /* 6DDB */
  50.       e_sbonus_bonus = 2000;      /* 291A-291D */
  51.       syssnd_play (WAV_SBONUS1, 1);
  52.    }
  53. }
  54.  
  55.  
  56. /*
  57.  * Entity action / stop counting
  58.  *
  59.  * ASM 2143
  60.  */
  61. void e_sbonus_stop (U8 e)
  62. {
  63.    if (E_RICK_STTST (E_RICK_STZOMBIE))
  64.       return;
  65.  
  66.    ent_ents[e].sprite = 0; /* invisible */
  67.  
  68.    if (!e_sbonus_counting)
  69.       return;
  70.  
  71.    if (u_trigbox (e, (S16) (ENT_RICK.x + 0x0C), (S16) (ENT_RICK.y + 0x0A)))
  72.    {
  73.       /* rick is within trigger box */
  74.       e_sbonus_counting = FALSE; /* stop counting */
  75.       ent_ents[e].n = 0; /* deactivate entity */
  76.       game_score += e_sbonus_bonus; /* add bonus to score */
  77.       syssnd_play(WAV_SBONUS2, 1);
  78.  
  79.       /* make sure the entity won't be activated again */
  80.       map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
  81.    }
  82.    else
  83.    {
  84.       /* keep counting */
  85.       if (--e_sbonus_counter == 0)
  86.       {
  87.          e_sbonus_counter = 0x1e;
  88.          if (e_sbonus_bonus) e_sbonus_bonus--;
  89.       }
  90.    }
  91. }
  92.