예제 #1
0
/* Kill Player! */
void
Player::kill(bool completely)
{
  if(dying || deactivated)
    return;

  if(!completely && safe_timer.started() || invincible_timer.started())
    return;                          
  
  sound_manager->play("sounds/hurt.wav");

  physic.set_velocity_x(0);

  if(!completely && is_big()) {
    if(player_status->bonus == FIRE_BONUS
        || player_status->bonus == ICE_BONUS) {
      safe_timer.start(TUX_SAFE_TIME);
      set_bonus(GROWUP_BONUS, true);
    } else {
      //growing_timer.start(GROWING_TIME);
      safe_timer.start(TUX_SAFE_TIME /* + GROWING_TIME */);
      adjust_height(30.8);
      duck = false;
      set_bonus(NO_BONUS, true);
    }
  } else {
    for (int i = 0; (i < 5) && (i < player_status->coins); i++)
    {
      // the numbers: starting x, starting y, velocity y
      Sector::current()->add_object(new FallingCoin(get_pos() + 
            Vector(systemRandom.rand(5), systemRandom.rand(-32,18)), 
            systemRandom.rand(-100,100)));
    }
    physic.enable_gravity(true);
    physic.set_acceleration(0, 0);
    physic.set_velocity(0, -700);
    player_status->coins -= 25;
    set_bonus(NO_BONUS, true);
    dying = true;
    dying_timer.start(3.0);
    set_group(COLGROUP_DISABLED);

    DisplayEffect* effect = new DisplayEffect();
    effect->fade_out(3.0);
    Sector::current()->add_object(effect);
    sound_manager->stop_music(3.0);
  }
}
예제 #2
0
파일: diamond.c 프로젝트: hambone20/mudlib
create(int clone){
    set_tradeskill("weaponsmithing");
    set_short("diamond");
    set_long("This is diamond, very difficult but very strong.\n");
    set_alloy("diamond");
    set_bonus(20);
    set_difficulty(20);
    set_subset("alloy");
    set_color("%^BOLD%^%^CYAN%^");
    set_id( ({ "diamond" }) );
예제 #3
0
void
Player::do_backflip() {
  if (!duck) return;
  if (!on_ground()) return;

  // TODO: we don't have an animation for firetux backflipping, so let's revert to bigtux
  set_bonus(GROWUP_BONUS, true);

  backflip_direction = (dir == LEFT)?(+1):(-1);
  backflipping = true;
  do_jump(-580);
  sound_manager->play("sounds/flip.wav");
  backflip_timer.start(0.15);
}
예제 #4
0
bool
Player::add_bonus(BonusType type, bool animate)
{
  // always ignore NO_BONUS
  if (type == NO_BONUS) {
    return true;
  }

  // ignore GROWUP_BONUS if we're already big
  if (type == GROWUP_BONUS) {
    if (player_status->bonus == GROWUP_BONUS)
      return true;
    if (player_status->bonus == FIRE_BONUS)
      return true;
    if (player_status->bonus == ICE_BONUS)
      return true;
  }

  return set_bonus(type, animate);
}
예제 #5
0
void
CheatMenu::menu_action(MenuItem& item)
{
  if (Sector::current())
  {
    std::vector<Player*> players = Sector::get().get_players();
    auto player = players.empty() ? nullptr : players[0];

    switch(item.id)
    {
      case MNID_GROW:
        if (player)
        {
          player->set_bonus(GROWUP_BONUS);
        }
        break;

      case MNID_FIRE:
        if (player)
        {
          player->set_bonus(FIRE_BONUS);
        }
        break;

      case MNID_ICE:
        if (player)
        {
          player->set_bonus(ICE_BONUS);
        }
        break;

      case MNID_AIR:
        if (player)
        {
          player->set_bonus(AIR_BONUS);
        }
        break;

      case MNID_EARTH:
        if (player)
        {
          player->set_bonus(EARTH_BONUS);
        }
        break;

      case MNID_STAR:
        if (player)
        {
          player->make_invincible();
        }
        break;

      case MNID_SHRINK:
        if (player)
        {
          player->kill(false);
        }
        break;

      case MNID_KILL:
        if (player)
        {
          player->kill(true);
        }
        break;

      case MNID_FINISH:
        if (GameSession::current())
        {
          GameSession::current()->finish(true);
        }
        break;

      case MNID_GHOST:
        if (GameSession::current() && player)
        {
          if(player->get_ghost_mode())
          {
            scripting::mortal();
          }
          else
          {
            scripting::ghost();
          }
        }
        break;

      default:
        break;
    }
  }

  MenuManager::instance().clear_menu_stack();
}
예제 #6
0
void
Player::update(float elapsed_time)
{
  if( no_water ){
    swimming = false;
  }
  no_water = true;

  if(dying && dying_timer.check()) {
    set_bonus(NO_BONUS, true);
    dead = true;
    return;
  }

  if(!dying && !deactivated)
    handle_input();

  /*
  // handle_input() calls apply_friction() when Tux is not walking, so we'll have to do this ourselves
  if (deactivated)
  apply_friction();
  */

  // extend/shrink tux collision rectangle so that we fall through/walk over 1
  // tile holes
  if(fabsf(physic.get_velocity_x()) > MAX_WALK_XM) {
    set_width(RUNNING_TUX_WIDTH);
  } else {
    set_width(TUX_WIDTH);
  }

  // on downward slopes, adjust vertical velocity so tux walks smoothly down
  if (on_ground() && !dying) {
    if(floor_normal.y != 0) {
      if ((floor_normal.x * physic.get_velocity_x()) >= 0) {
        physic.set_velocity_y(250);
      }
    }
  }

  // handle backflipping
  if (backflipping && !dying) {
    //prevent player from changing direction when backflipping
    dir = (backflip_direction == 1) ? LEFT : RIGHT;
    if (backflip_timer.started()) physic.set_velocity_x(100 * backflip_direction);
    //rotate sprite during flip
    sprite->set_angle(sprite->get_angle() + (dir==LEFT?1:-1) * elapsed_time * (360.0f / 0.5f));
  }

  // set fall mode...
  if(on_ground()) {
    fall_mode = ON_GROUND;
    last_ground_y = get_pos().y;
  } else {
    if(get_pos().y > last_ground_y)
      fall_mode = FALLING;
    else if(fall_mode == ON_GROUND)
      fall_mode = JUMPING;
  }

  // check if we landed
  if(on_ground()) {
    jumping = false;
    if (backflipping && (backflip_timer.get_timegone() > 0.15f)) {
      backflipping = false;
      backflip_direction = 0;
      sprite->set_angle(0.0f);

      // if controls are currently deactivated, we take care of standing up ourselves
      if (deactivated)
        do_standup();
    }
  }

  // calculate movement for this frame
  movement = physic.get_movement(elapsed_time);

  if(grabbed_object != NULL && !dying) {
    position_grabbed_object();
  }

  if(grabbed_object != NULL && dying){
    grabbed_object->ungrab(*this, dir);
    grabbed_object = NULL;
  }

  if(!ice_this_frame && on_ground())
    on_ice = false;

  on_ground_flag = false;
  ice_this_frame = false;

  // when invincible, spawn particles
  if (invincible_timer.started())
  {
    if (graphicsRandom.rand(0, 2) == 0) {
      float px = graphicsRandom.randf(bbox.p1.x+0, bbox.p2.x-0);
      float py = graphicsRandom.randf(bbox.p1.y+0, bbox.p2.y-0);
      Vector ppos = Vector(px, py);
      Vector pspeed = Vector(0, 0);
      Vector paccel = Vector(0, 0);
      Sector::current()->add_object(std::make_shared<SpriteParticle>(
                                      "images/objects/particles/sparkle.sprite",
                                      // draw bright sparkle when there is lots of time left,
                                      // dark sparkle when invincibility is about to end
                                      (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING) ?
                                      // make every other a longer sparkle to make trail a bit fuzzy
                                      (size_t(game_time*20)%2) ? "small" : "medium"
                                      :
                                      "dark", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
    }
  }

  if (growing) {
    if (sprite->animation_done()) growing = false;
  }

  // when climbing animate only while moving
  if(climbing){
    if((physic.get_velocity_x()==0)&&(physic.get_velocity_y()==0))
      sprite->stop_animation();
    else
      sprite->set_animation_loops(-1);
  }

}
예제 #7
0
/* Kill Player! */
void
Player::kill(bool completely)
{
  if(dying || deactivated || is_winning() )
    return;

  if(!completely && (safe_timer.started() || invincible_timer.started()))
    return;

  growing = false;

  if (climbing) stop_climbing(*climbing);

  physic.set_velocity_x(0);

  sprite->set_angle(0.0f);

  if(!completely && is_big()) {
    SoundManager::current()->play("sounds/hurt.wav");

    if(player_status->bonus == FIRE_BONUS
       || player_status->bonus == ICE_BONUS) {
      safe_timer.start(TUX_SAFE_TIME);
      set_bonus(GROWUP_BONUS, true);
    } else if(player_status->bonus == GROWUP_BONUS) {
      safe_timer.start(TUX_SAFE_TIME /* + GROWING_TIME */);
      adjust_height(SMALL_TUX_HEIGHT);
      duck = false;
      backflipping = false;
      sprite->set_angle(0.0f);
      set_bonus(NO_BONUS, true);
    } else if(player_status->bonus == NO_BONUS) {
      safe_timer.start(TUX_SAFE_TIME);
      adjust_height(SMALL_TUX_HEIGHT);
      duck = false;
    }
  } else {
    SoundManager::current()->play("sounds/kill.wav");

    // do not die when in edit mode
    if (edit_mode) {
      set_ghost_mode(true);
      return;
    }

    if (player_status->coins >= 25 && !GameSession::current()->get_reset_point_sectorname().empty())
    {
      for (int i = 0; i < 5; i++)
      {
        // the numbers: starting x, starting y, velocity y
        Sector::current()->add_object(std::make_shared<FallingCoin>(get_pos() +
                                                      Vector(graphicsRandom.rand(5), graphicsRandom.rand(-32,18)),
                                                      graphicsRandom.rand(-100,100)));
      }
      player_status->coins -= std::max(player_status->coins/10, 25);
    }
    else
    {
      GameSession::current()->set_reset_point("", Vector());
    }
    physic.enable_gravity(true);
    physic.set_gravity_modifier(1.0f); // Undo jump_early_apex
    safe_timer.stop();
    invincible_timer.stop();
    physic.set_acceleration(0, 0);
    physic.set_velocity(0, -700);
    set_bonus(NO_BONUS, true);
    dying = true;
    dying_timer.start(3.0);
    set_group(COLGROUP_DISABLED);

    // TODO: need nice way to handle players dying in co-op mode
    Sector::current()->effect->fade_out(3.0);
    SoundManager::current()->stop_music(3.0);
  }
}
예제 #8
0
void create() {
	set_bonus(5);
        set_weapon_type("sword/two-handed");
set("value",   5000);
	set("id", ({ "flaming sword", "sword" }) );
예제 #9
0
void create() {
	set_bonus(4);
        set_weapon_type("mace");
	set("id", ({ "crystal mace", "mace" }) );
예제 #10
0
void create() {
	set_bonus(2, 2, 2);
        set_weapon_type("sword/long");
set("value",   1300);
	set("id", ({ "giant slayer", "sword" }) );
예제 #11
0
void create() {
    set_bonus(3);
    set_weapon_type("sword/two-handed");
    set("id", ({ "an Abyssal two-handed sword" }) );
예제 #12
0
void create() {
	set_bonus(2);
        set_weapon_type("dagger");
	set("id", ({ "dagger" }) );
예제 #13
0
void create() {

    set_weapon_type("hammer");
	set_bonus(3);
set("value",   1500);
	set("id", ({ "warhammer", "hammer" }) );