コード例 #1
0
struct Thing *create_and_control_creature_as_controller(struct PlayerInfo *player, long breed, struct Coord3d *pos)
{
    struct CreatureStats *crstat;
    struct CreatureControl *cctrl;
    struct Dungeon *dungeon;
    struct Thing *thing;
    struct Camera *cam;
    struct InitLight ilght;
    SYNCDBG(6,"Request for model %ld at (%d,%d,%d)",breed,(int)pos->x.val,(int)pos->y.val,(int)pos->z.val);
    //return _DK_create_and_control_creature_as_controller(player, a2, pos);
    thing = create_creature(pos, breed, player->id_number);
    if (thing_is_invalid(thing))
      return INVALID_THING;
    dungeon = get_dungeon(thing->owner);
    dungeon->num_active_creatrs--;
    dungeon->owned_creatures_of_model[thing->model]--;
    if (is_my_player(player))
    {
        toggle_status_menu(0);
        turn_off_roaming_menus();
    }
    cam = player->acamera;
    player->controlled_thing_idx = thing->index;
    player->field_31 = thing->creation_turn;
    player->field_4B5 = cam->field_6;
    thing->alloc_flags |= TAlF_IsControlled;
    thing->field_4F |= 0x01;
    cctrl = creature_control_get_from_thing(thing);
    cctrl->flgfield_2 |= 0x02;
    cctrl->max_speed = calculate_correct_creature_maxspeed(thing);
    set_player_mode(player, PVT_CreatureContrl);
    set_start_state(thing);
    // Preparing light object
    LbMemorySet(&ilght, 0, sizeof(struct InitLight));
    ilght.mappos.x.val = thing->mappos.x.val;
    ilght.mappos.y.val = thing->mappos.y.val;
    ilght.mappos.z.val = thing->mappos.z.val;
    ilght.field_2 = 36;
    ilght.field_3 = 1;
    ilght.is_dynamic = 1;
    ilght.field_0 = 2560;
    thing->light_id = light_create_light(&ilght);
    if (thing->light_id != 0)
    {
        light_set_light_never_cache(thing->light_id);
    } else
    {
        ERRORLOG("Cannot allocate light to new hero");
    }
    if (is_my_player_number(thing->owner))
    {
        if (thing->class_id == TCls_Creature)
        {
            crstat = creature_stats_get_from_thing(thing);
            setup_eye_lens(crstat->eye_effect);
        }
    }
    return thing;
}
コード例 #2
0
ファイル: player_data.c プロジェクト: ommmmmmm/keeperfx
void set_player_mode(struct PlayerInfo *player, long nview)
{
  long i;
  if (player->view_type == nview)
    return;
  player->view_type = nview;
  player->allocflags &= ~PlaF_Unknown8;
  if (is_my_player(player))
  {
    game.numfield_D &= ~numfield_D_08;
    game.numfield_D |= numfield_D_01;
    if (is_my_player(player))
      stop_all_things_playing_samples();
  }
  switch (player->view_type)
  {
  case PVT_DungeonTop:
      i = PVM_IsometricView;
      if (player->view_mode_restore == PVM_FrontView)
      {
        set_engine_view(player, PVM_IsometricView);
        i = PVM_FrontView;
      }
      set_engine_view(player, i);
      if (is_my_player(player))
          toggle_status_menu((game.status_flags & Status_ShowStatusMenu));
      if ((game.status_flags & Status_ShowGui) != 0)
        setup_engine_window(status_panel_width, 0, MyScreenWidth, MyScreenHeight);
      else
        setup_engine_window(0, 0, MyScreenWidth, MyScreenHeight);
      break;
  case PVT_CreatureContrl:
  case PVT_CreaturePasngr:
      set_engine_view(player, PVM_CreatureView);
      if (is_my_player(player))
        game.numfield_D &= ~numfield_D_01;
      setup_engine_window(0, 0, MyScreenWidth, MyScreenHeight);
      break;
  case PVT_MapScreen:
      player->continue_work_state = player->work_state;
      set_engine_view(player, PVM_ParchmentView);
      break;
  case PVT_MapFadeIn:
      set_player_instance(player, PI_MapFadeTo, 0);
      break;
  case PVT_MapFadeOut:
      set_player_instance(player, PI_MapFadeFrom, 0);
      break;
  }
}