void CPlatform::process() { // check if someone is still standing on the platform if(mp_CarriedPlayer) { if(!hitdetect(*mp_CarriedPlayer) || mp_CarriedPlayer->blockedu) { mp_CarriedPlayer->supportedbyobject = false; mp_CarriedPlayer->m_jumpdownfromobject = false; mp_CarriedPlayer = NULL; } } processActionRoutine(); }
void CCouncilMember::getTouchedBy(CObject &theObject) { if(hitdetect(theObject)) { // When Keen touches the Council Member exit the level and add one to the council list if(theObject.m_type == OBJ_PLAYER) { CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject); CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList; EventContainer.add( new EventExitLevel(mp_Map->getLevel(), true) ); Player.m_Inventory.Item.m_special.ep4.elders++; } } }
void OmegaBoss::Run(void) { Object *&o = game.stageboss.object; if (omg.defeated) return; switch(o->state) { case 0: break; // waiting for trigger by script case OMG_WAIT: // waits for a moment then go to omg.nextstate { o->state++; omg.timer = 0; } case OMG_WAIT+1: { if (++omg.timer >= OMEGA_WAIT_TIME) { omg.timer = 0; o->state = omg.nextstate; } } break; case OMG_APPEAR: { omg.timer = 0; o->frame = 0; o->state = OMG_MOVE; omg.movedir = -OMEGA_SPEED; o->flags |= FLAG_SOLID_MUSHY; } case OMG_MOVE: // rising up/going back into ground { o->frame = 0; o->y += omg.movedir; game.quaketime = 2; omg.timer++; if ((omg.timer & 3) == 0) sound(SND_QUAKE); if (omg.timer >= omg.movetime) { if (omg.movedir < 0) { // was rising out of ground omg.nextstate = OMG_JAWS_OPEN; o->state = OMG_WAIT; } else { // was going back into ground omg.timer = 0; o->state = OMG_UNDERGROUND; o->flags &= ~(FLAG_SOLID_MUSHY | FLAG_SOLID_BRICK); } } } break; case OMG_JAWS_OPEN: // jaws opening { o->state++; omg.animtimer = 0; sound(SND_JAWS); o->sprite = SPR_OMG_OPENED; // select "open" bounding box } case OMG_JAWS_OPEN+1: { omg.animtimer++; if (omg.animtimer > 2) { omg.animtimer = 0; o->frame++; if (o->frame==3) { o->state = OMG_FIRE; omg.firecounter = 0; o->flags |= FLAG_SHOOTABLE; } } } break; case OMG_FIRE: // throwing out red stuff { omg.firecounter++; if (omg.firecounter > omg.startfiring && omg.firecounter < omg.stopfiring) { if ((omg.firecounter % omg.firefreq)==0) { Object *shot; sound(SND_EM_FIRE); shot = SpawnObjectAtActionPoint(o, OBJ_OMEGA_SHOT); shot->xinertia = random(-omg.shotxspd, omg.shotxspd); shot->yinertia = -0x333; if (omg.form==2 || random(0, 9) < 8) { shot->sprite = SPR_OMG_BULLET_NORMAL; shot->flags = FLAG_SHOOTABLE; } else { shot->sprite = SPR_OMG_BULLET_HARD; shot->flags = (FLAG_SHOOTABLE | FLAG_INVULNERABLE); } shot->timer = (random(0, 7) >= 4) ? random(300, 400):0; shot->damage = 4; } } else if (omg.firecounter >= omg.endfirestate || sound_is_playing(SND_MISSILE_HIT)) { // snap jaws shut omg.animtimer = 0; o->state = OMG_JAWS_CLOSE; sound(SND_JAWS); } } break; case OMG_JAWS_CLOSE: // jaws closing { omg.animtimer++; if (omg.animtimer > 2) { omg.animtimer = 0; o->frame--; if (o->frame == 0) { sound_stop(SND_JAWS); sound(SND_BLOCK_DESTROY); o->sprite = SPR_OMG_CLOSED; // select "closed" bounding box o->flags &= ~FLAG_SHOOTABLE; o->damage = 0; if (omg.form == 1) { // form 1: return to sand o->state = OMG_WAIT; omg.nextstate = OMG_MOVE; omg.movedir = OMEGA_SPEED; omg.movetime = OMEGA_SINK_DEPTH; } else { // form 2: jump sound(SND_FUNNY_EXPLODE); if (o->x < player->x) o->xinertia = 0xC0; else o->xinertia = -0xC0; o->state = OMG_JUMP; o->yinertia = -0x5FF; omg.orgy = o->y; } } } // hurt player if he was standing in the middle when the jaws shut if (player->riding == o) { hurtplayer(OMEGA_DAMAGE); } } break; case OMG_UNDERGROUND: // underground waiting to reappear { if (++omg.timer >= 120) { omg.timer = 0; o->state = OMG_APPEAR; o->x = omg.orgx + (random(-64, 64) << CSF); o->y = omg.orgy; omg.movetime = OMEGA_RISE_HEIGHT; // switch to jumping out of ground when we get low on life if (omg.form==1 && o->hp <= HP_TRIGGER_POINT) { o->flags |= FLAG_SOLID_MUSHY; omg.form = 2; omg.firefreq = 5; omg.shotxspd = 0x155; omg.startfiring = 0; omg.stopfiring = 30; omg.endfirestate = 50; omg.movetime = OMEGA_RISE_HEIGHT+3; } } } break; case OMG_JUMP: // init for jump { omg.orgy = o->y; o->state++; omg.timer = 0; } case OMG_JUMP+1: // jumping { o->yinertia += 0x24; if (o->yinertia > 0x5ff) o->yinertia = 0x5ff; if (o->yinertia > 0) { // coming down pieces[LEFTLEG]->sprite = pieces[RIGHTLEG]->sprite = SPR_OMG_LEG_ONGROUND; // retract legs a little when we hit the ground if (pieces[LEFTLEG]->blockd || pieces[RIGHTLEG]->blockd) { o->xinertia = 0; omg.leg_descend -= o->yinertia; if (++omg.timer >= 3) { o->yinertia = 0; o->state = OMG_JAWS_OPEN; } } // --- squash player if we land on him ------------- // if top of player is higher than bottom of our bounding box // but bottom of player's bounding box is not... if (player->blockd) { int omg_bottom = o->y + (sprites[o->sprite].solidbox.y2 << CSF); if (player->y <= omg_bottom) { if (player->y + (sprites[player->sprite].solidbox.y2 << CSF) >= omg_bottom) { if (hitdetect(o, player)) // easy way to verify the X's are lined up { // SQUISH! hurtplayer(OMEGA_DAMAGE); } } } } } else { // jumping up; extend legs omg.leg_descend = (omg.orgy - o->y) + LEGD_MIN; if (omg.leg_descend > LEGD_MAX) omg.leg_descend = LEGD_MAX; pieces[LEFTLEG]->sprite = pieces[RIGHTLEG]->sprite = SPR_OMG_LEG_INAIR; } } break; /// victory case OMG_EXPLODING: { omg.timer = 0; o->state++; } case OMG_EXPLODING+1: { int x, y; o->xinertia = o->yinertia = 0; x = o->CenterX() + (random(-48, 48)<<CSF); y = o->CenterY() + (random(-48, 24)<<CSF); SmokePuff(x, y); effect(x, y, EFFECT_BOOMFLASH); game.quaketime = 2; if ((omg.timer % 12)==0) sound(SND_ENEMY_HURT_BIG); if (++omg.timer > 100) { omg.timer = 0; starflash.Start(o->CenterX(), o->CenterY()); o->state = OMG_EXPLODED; } else if (omg.timer==24) { StartScript(210); } } break; case OMG_EXPLODED: { game.quaketime = 40; if (++omg.timer > 50) { o->Delete(); for(int i=0;i<NUM_PIECES;i++) pieces[i]->Delete(); omg.defeated = true; return; } } break; } // implement shaking when shot // we do it manually instead of used the usual shared code // because we want all the pieces to shake at once if (o->hp != omg.lasthp && !omg.shaketimer) { omg.shaketimer = 3; // why did I write this? anyway, I'm sure it's important if (o->x > player->x) o->display_xoff = -1; else o->display_xoff = 1; omg.lasthp = o->hp; } if (omg.shaketimer) { int xoff = -o->display_xoff; if (!--omg.shaketimer) xoff = 0; o->display_xoff = xoff; pieces[LEFTLEG]->display_xoff = xoff; pieces[RIGHTLEG]->display_xoff = xoff; pieces[LEFTSTRUT]->display_xoff = xoff; pieces[RIGHTSTRUT]->display_xoff = xoff; } if (o->state) { o->blockl |= pieces[LEFTLEG]->blockl; o->blockr |= pieces[RIGHTLEG]->blockr; pieces[LEFTLEG]->x = o->x - (4 << CSF); pieces[LEFTLEG]->y = o->y + omg.leg_descend; pieces[RIGHTLEG]->x = o->x + (38 << CSF); pieces[RIGHTLEG]->y = o->y + omg.leg_descend; pieces[LEFTSTRUT]->x = o->x + (9 << CSF); pieces[LEFTSTRUT]->y = o->y + (27 << CSF); pieces[RIGHTSTRUT]->x = o->x + (43 << CSF); pieces[RIGHTSTRUT]->y = o->y + (27 << CSF); } }
void CSpriteItem::getTouchedBy(CObject &theObject) { if(hitdetect(theObject)) { exists = false; if(theObject.m_type != OBJ_PLAYER) return; CPlayerLevel *pPlayer = (CPlayerLevel*)(&theObject); stItemGalaxy &Item = pPlayer->m_Inventory.Item; /// Calculate the right animation. // Point items Uint32 newanimsprite = got_sprite_item_pics[0]; if( m_basesprite >= 103 && m_basesprite <= 116 ) { newanimsprite = got_sprite_item_pics[4+(m_basesprite-103)/2]; switch(m_basesprite) { case 103: Item.m_points += 100; break; case 105: Item.m_points += 200; break; case 107: Item.m_points += 500; break; case 109: Item.m_points += 1000; break; case 111: Item.m_points += 2000; break; case 113: Item.m_points += 5000; break; default: break; } g_pSound->playSound( SOUND_GET_BONUS ); } // raygun if( m_basesprite >= 127 && m_basesprite <= 128 ) { Item.m_bullets += 5; newanimsprite = got_sprite_item_pics[11]; g_pSound->playSound( SOUND_GET_AMMO ); } m_ObjectPtrs.push_back(new CItemEffect(mp_Map, getXPosition(), getYPosition(), newanimsprite)); // Now add the stuff to the inventory if( m_basesprite >= 118 && m_basesprite <= 124 ) { switch(m_basesprite) { case 118: case 119: Item.m_gem.red++; break; case 120: case 121: Item.m_gem.yellow++; break; case 122: case 123: Item.m_gem.blue++; break; case 124: case 125: Item.m_gem.green++; break; default: break; } g_pSound->playSound( SOUND_GET_GEM ); } if ( m_basesprite == 115 ) { Item.m_lifes++; g_pSound->playSound( SOUND_EXTRA_LIFE ); } } }
void ai_falling_spike_large(Object *o) { switch(o->state) { case 0: { o->xmark = o->x; if (pdistlx(12 << CSF)) o->state = 1; } break; case 1: // shaking { if (++o->animtimer >= 12) o->animtimer = 0; o->x = o->xmark; if (o->animtimer >= 6) // scuttle:: big spikes shake in the other direction o->x -= (1 << CSF); if (++o->timer > 30) { o->state = 2; // fall o->frame = 1; // slightly brighter frame at top } } break; case 2: // falling { o->yinertia += 0x20; LIMITY(0xC00); if (o->Bottom() < player->Bottom()) { // could fall on player o->flags &= ~FLAG_SOLID_BRICK; o->damage = 127; // ouch! } else { // player could only touch side from this position o->flags |= FLAG_SOLID_BRICK; o->damage = 0; } // damage NPC's as well (it kills that one Dragon Zombie) Object *enemy; FOREACH_OBJECT(enemy) { if ((enemy->flags & FLAG_SHOOTABLE) && \ o->Bottom() >= enemy->CenterY() && hitdetect(o, enemy)) { if (!(enemy->flags & FLAG_INVULNERABLE)) enemy->DealDamage(127); } } if (++o->timer > 8 && o->blockd) { o->flags |= FLAG_SOLID_BRICK; o->damage = 0; o->yinertia = 0; o->state = 3; // fall complete o->timer = 0; sound(SND_BLOCK_DESTROY); SmokeClouds(o, 4, 2, 2); effect(o->CenterX(), o->y + (sprites[o->sprite].block_d[0].y << CSF), EFFECT_STARSOLID); } } break; case 3: // hit ground { if (++o->timer > 4) { // make it destroyable o->flags |= FLAG_SHOOTABLE; o->flags &= ~FLAG_INVULNERABLE; o->state = 4; } } break; } }