Ejemplo n.º 1
0
void ai_boss_misery(Object *o)
{
  /*debug("state: %d", o->state);
  debug("timer: %d", o->timer);
  debug("timer2: %d", o->timer2);*/

  switch (o->state)
  {
    // fight begin and default/base state
    case STATE_FIGHTING:
    {
      o->flags |= FLAG_SHOOTABLE;
      o->savedhp = o->hp;

      o->timer    = 0;
      o->frame    = 0;
      o->xinertia = 0;
      o->state++;
    }
    case STATE_FIGHTING + 1:
    {
      FACEPLAYER;

      o->yinertia += (o->y < o->ymark) ? 0x20 : -0x20;
      LIMITY(0x200);

      if (++o->timer > 200 || (o->savedhp - o->hp) >= 80)
      {
        o->state = STATE_FLASH_FOR_SPELL;
        o->timer = 0;
      }
    }
    break;
  }

  run_spells(o);
  run_teleport(o);

  run_intro(o);
  run_defeated(o);

  LIMITX(0x200);
  LIMITY(0x400);
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: z88dk/z88dk
int
main(void)
{
   unsigned char idle = 0;

   // the crt has disabled interrupts before main is called
   
   // z88dk tracks the border colour so that beeper audio does not change the border colour while playing.
   // (this project contains a 3rd party ntropic player that does not obey z88dk convention so we set the border to same colour)
   zx_border(INK_BLACK);

   // set up the block memory allocator with one queue
   // max size requested by sp1 will be 24 bytes or block size of 25 (+1 for overhead)
   balloc_reset(0);                                              // make queue 0 empty
   balloc_addmem(0, sizeof(block_of_ram)/25, 24, block_of_ram);  // add free memory from bss section
   balloc_addmem(0, 8, 24, (void *)0xd101);                      // another eight from an unused area

   // interrupt mode 2
   setup_int();

   // sp1.lib
   sp1_Initialize(SP1_IFLAG_MAKE_ROTTBL | SP1_IFLAG_OVERWRITE_TILES | SP1_IFLAG_OVERWRITE_DFILE, INK_BLACK | PAPER_BLACK, ' ');
   // sp1_Validate(&cr);  // not necessary since sp1_Initialize will not mark screen for update
   
   ps0.bounds = &cr;
   ps0.flags = SP1_PSSFLAG_INVALIDATE;
   ps0.visit = 0;

   intrinsic_ei();

   // setup our font
   pt = font;
   for (i = 0; i < 96; ++i, pt += 8)
      sp1_TileEntry(32 + i, pt);

   // setup the bg tiles
   pt = tiles;
   for (i = 0; i < TILES_LEN; ++i, pt += 8)
      sp1_TileEntry(TILES_BASE + i, pt);

   init_sprites();

   draw_menu();

   srand(tick);  // 256 different games are possible

   while(1)
   {
      key = in_inkey();
      if (key)
      {
         if (key == '4')
         {
            playfx(FX_SELECT);

            in_wait_nokey();
            run_redefine_keys();
            idle = 0;
            draw_menu();
         }
         if (key == '1' || key == '2' || key == '3')
         {
            playfx(FX_SELECT);

            joy_k.left  = in_key_scancode(keys[0]);
            joy_k.right = in_key_scancode(keys[1]);
            // we don't use up/down in this game
            joy_k.down  = in_key_scancode(keys[0]);
            joy_k.up    = in_key_scancode(keys[1]);
            joy_k.fire  = in_key_scancode(keys[2]);

            if (key == '1')
               joyfunc = (JOYFUNC)in_stick_keyboard;
            if (key == '2')
               joyfunc = (JOYFUNC)in_stick_kempston;
            if (key == '3')
               joyfunc = (JOYFUNC)in_stick_sinclair1;

            // run game
            run_intro();

            run_play();
            idle = 0;
            draw_menu();
         }
      }

      if (idle++ == 255)
      {
         // go back to the welcome screen after a while
         // if the player doesn't do anything
         idle = 0;
         draw_menu();
      }

      wait();
      sp1_UpdateNow();
   }
}
Ejemplo n.º 3
0
void ai_ballos_priest(Object *o)
{
	//AIDEBUG;
	//debug("timer3: %d", o->timer3);
	
	/*if (o->state < 1000)
	{
		FindObjectByID2(500)->Delete();
		StartScript(900);
		return;
	}*/
	
	run_intro(o);
	run_defeated(o);
	
	run_flight(o);
	run_lightning(o);
	
	switch(o->state)
	{
		// show "ninja" stance for "timer" ticks,
		// then prepare to fly horizontally
		case BP_FIGHTING_STANCE:
		{
			o->frame = 1;
			o->animtimer = 0;
			o->state++;
			
			o->damage = DMG_NORMAL;
			o->savedhp = o->hp;
		}
		case BP_FIGHTING_STANCE+1:
		{
			ANIMATE(10, 1, 2);
			FACEPLAYER;
			
			if (--o->timer < 0 || (o->savedhp - o->hp) > 50)
			{
				if (++o->timer3 > 4)
				{
					o->state = BP_LIGHTNING_STRIKE;
					o->timer3 = 0;
				}
				else
				{
					o->state = BP_PREPARE_FLY_LR;
					o->timer2 = 0;
				}
			}
		}
		break;
		
		// prepare for flight attack
		case BP_PREPARE_FLY_LR:
		case BP_PREPARE_FLY_UD:
		{
			o->timer2++;
			o->state++;
			
			o->timer = 0;
			o->frame = 3;	// fists in
			o->damage = DMG_NORMAL;
			
			// Fly/UD faces player only once, at start
			FACEPLAYER;
		}
		case BP_PREPARE_FLY_LR+1:
		{
			FACEPLAYER;
		}
		case BP_PREPARE_FLY_UD+1:
		{
			// braking, if we came here out of another fly state
			o->xinertia *= 8; o->xinertia /= 9;
			o->yinertia *= 8; o->yinertia /= 9;
			
			if (++o->timer > 20)
			{
				sound(SND_FUNNY_EXPLODE);
				
				if (o->state == BP_PREPARE_FLY_LR+1)
				{
					o->state = BP_FLY_LR;		// flying left/right
				}
				else if (player->y < (o->y + (12 << CSF)))
				{
					o->state = BP_FLY_UP;		// flying up
				}
				else
				{
					o->state = BP_FLY_DOWN;		// flying down
				}
			}
		}
		break;
	}
	
	// his bounding box is in a slightly different place on L/R frames
	if (o->dirparam != o->dir)
	{
		sprites[o->sprite].bbox = sprites[o->sprite].frame[0].dir[o->dir].pf_bbox;
		o->dirparam = o->dir;
	}
}