Exemplo n.º 1
0
TbBool get_next_manufacture(struct Dungeon *dungeon)
{
    int chosen_class,chosen_kind,chosen_amount;
    set_manufacture_level(dungeon);
    chosen_class = TCls_Empty;
    chosen_kind = 0;
    chosen_amount = get_doable_manufacture_with_minimal_amount_available(dungeon, &chosen_class, &chosen_kind);
    if (chosen_amount >= MANUFACTURED_ITEMS_LIMIT)
    {
        if (chosen_amount == LONG_MAX) {
            WARNDBG(7,"Player %d has %s but no doable manufacture",(int)dungeon->owner,room_code_name(RoK_WORKSHOP));
        } else {
            WARNDBG(6,"Player %d reached manufacture limit for all items",(int)dungeon->owner);
        }
        return false;
    }
    if (chosen_class != TCls_Empty)
    {
        SYNCDBG(8,"Player %d manufacturing class %d kind %d",(int)dungeon->owner,(int)chosen_class,(int)chosen_kind);
        dungeon->manufacture_class = chosen_class;
        dungeon->manufacture_kind = chosen_kind;
        return true;
    }
    WARNDBG(6,"Player %d has nothing to manufacture",(int)dungeon->owner);
    return false;
}
Exemplo n.º 2
0
struct Dungeon *get_players_num_dungeon_f(long plyr_idx,const char *func_name)
{
    struct PlayerInfo *player;
    PlayerNumber plyr_num;
    player = get_player(plyr_idx);
    plyr_num = player->id_number;
    if (player_invalid(player) || (plyr_num < 0) || (plyr_num >= DUNGEONS_COUNT))
    {
        ERRORMSG("%s: Tried to get players %d non-existing dungeon %d!",func_name,(int)plyr_idx,(int)plyr_num);
        return INVALID_DUNGEON;
    }
    if (plyr_num != player->id_number)
    {
        WARNDBG(7,"%s: Player number(%d) differ from index(%d)!",func_name,(int)plyr_num,(int)plyr_idx);
    }
    return &(game.dungeon[(int)plyr_num]);
}
Exemplo n.º 3
0
short manufacturing(struct Thing *creatng)
{
    struct Room *room;
    //return _DK_manufacturing(creatng);
    TRACE_THING(creatng);
    room = get_room_thing_is_on(creatng);
    if (creature_work_in_room_no_longer_possible(room, RoK_WORKSHOP, creatng))
    {
        remove_creature_from_work_room(creatng);
        set_start_state(creatng);
        return CrStRet_ResetFail;
    }
    if (room->used_capacity > room->total_capacity)
    {
        if (is_my_player_number(creatng->owner))
            output_message(SMsg_WorkshopTooSmall, 500, true);
        remove_creature_from_work_room(creatng);
        set_start_state(creatng);
        return CrStRet_ResetOk;
    }
    struct Dungeon *dungeon;
    dungeon = get_dungeon(creatng->owner);
    if (dungeon->manufacture_class)
    {
        struct CreatureControl *cctrl;
        struct CreatureStats *crstat;
        cctrl = creature_control_get_from_thing(creatng);
        crstat = creature_stats_get_from_thing(creatng);
        long work_value;
        work_value = compute_creature_work_value(crstat->manufacture_value*256, room->efficiency, cctrl->explevel);
        work_value = process_work_speed_on_work_value(creatng, work_value);
        SYNCDBG(9,"The %s index %d produced %d manufacture points",thing_model_name(creatng),(int)creatng->index,(int)work_value);
        dungeon->manufacture_progress += work_value;
        dungeon->field_1181 += work_value;
    } else
    {
        WARNDBG(9,"The %s index %d owner %d is manufacturing nothing",thing_model_name(creatng),(int)creatng->index,(int)creatng->owner);
        // This may be cause by a creature taking up place in workshop where crate should be created; the creature should take a break
        if (room->used_capacity >= room->total_capacity) {
            external_set_thing_state(creatng, CrSt_CreatureGoingHomeToSleep);
            return CrStRet_Modified;
        }
    }
    process_creature_in_workshop(creatng, room);
    return CrStRet_Modified;
}
Exemplo n.º 4
0
/**
 * Plays an in-game message.
 *
 * @param msg_idx Message index
 * @param delay Delay between the message can be repeated.
 * @param queue True will allow the message to queue,
 *     false will play it immediately or never.
 * @return Gives true if the message was prepared to play or queued.
 *     If the message couldn't be played nor queued, returns false.
 */
TbBool output_message(long msg_idx, long delay, TbBool queue)
{
    struct SMessage *smsg;
    long i;
    SYNCDBG(5,"Message %ld, delay %ld, queue %s",msg_idx, delay, queue?"on":"off");
    smsg = &messages[msg_idx];
    if (!message_can_be_played(msg_idx))
    {
        SYNCDBG(8,"Delay to turn %ld didn't passed, skipping",(long)smsg->end_time);
        return false;
    }
    if (!speech_sample_playing())
    {
      i = get_phrase_sample(get_phrase_for_message(msg_idx));
      if (i == 0)
      {
          SYNCDBG(8,"No phrase %d sample, skipping",(int)msg_idx);
          return false;
      }
      if (play_speech_sample(i))
      {
          message_playing = msg_idx;
          smsg->end_time = (long)game.play_gameturn + delay;
          SYNCDBG(8,"Playing prepared");
          return true;
      }
    }
    if ( (msg_idx == message_playing) || (message_already_in_queue(msg_idx)) )
    {
        SYNCDBG(8,"Message %ld is already in queue",msg_idx);
        return false;
    }
    if (queue)
    {
      if (add_message_to_queue(msg_idx, delay))
      {
          SYNCDBG(8,"Playing queued");
          return true;
      }
    }
    WARNDBG(8,"Playing message %ld failed",msg_idx);
    return false;
}