Skip to content

NPC ~ NPC Battle Integration Design Document

Emily Bae edited this page May 16, 2022 · 8 revisions

Overview

This document will cover how NPCs can be integrated with battle modules. While the Battles team is responsible for the design of the battle, the NPC-Battle Integration team will make certain design choices for what types of NPCs can engage in battle and in what setting. The following document basically covers:

  • npc_battle module
  • Class type
    • Player Class Integration
    • Skill Trees Integration
  • Open World Integration

Note: please take a look at the NPC Battle Changes Design Document for details on changes made to NPC-Battle Integration modules.

Relevant Modules

  • Battle
    • battle_structs.h
    • battle_common.h
    • battle_ai.h
  • NPC
    • npc.h
    • npc_battle.h
    • npc_move.h

Relevant Data Structures

npc.h
typedef struct npc {
    UT_hash_handle hh, hh_room;
    char *npc_id;
    char *short_desc;
    char *long_desc;
    convo_t *dialogue;
    item_hash_t *inventory;
    class_t *class;
    npc_mov_t *movement;
    bool will_fight;
    npc_battle_t *npc_battle;
} npc_t;
npc_battle.h
typedef enum hostility {
    FRIENDLY = 0,
    CONDITIONAL_FRIENDLY = 1,
    HOSTILE = 2
} hostility_t;

typedef struct npc_battle {
    int health;
    stat_t *stats;
    move_t *moves;
    difficulty_t ai;
    hostility_t hostility_level;
    int surrender_level;
} npc_battle_t;
battle_common.h
typedef struct combatant
{
    char *name;
    bool is_friendly;
    class_t *class_type;
    stat_t *stats;
    move_t *moves;
    battle_item_t *items;
    difficulty_t ai;
    struct combatant *next;
    struct combatant *prev;
} combatant_t;

typedef struct battle
{
    combatant_t *player;
    combatant_t *enemy;
    environment_t environment;
    turn_t turn;
} battle_t;
battle_structs.h
typedef struct battle_item {
    int id;
    bool is_weapon;
    int effectiveness_decrement;
    int quantity;
    int durability;
    char* name;
    char* description;
    bool battle;
    int attack;
    int defense;
    int hp;
    struct battle_item *next;
    struct battle_item *prev;
} battle_item_t;

typedef struct move {
    battle_item_t *item;
    int id;
    // NOTE: functions to create move_new do not take into account a name
    char* name;
    char* info;
    bool attack;
    int damage;
    int defense;
    struct move *next;
    struct move *prev;
} move_t;

typedef struct stat {
    int speed;
    int defense;
    int strength;
    int dexterity;
    int hp;
    int max_hp;
    int xp;
    int level;
} stat_t;

NPC_Battle

Comparing the structs in the NPC and battle modules respectively, we’re interested in including class_type and battle_item_t *items into the npc_battle_t in order to increase compatibility with combatant_t in the battle_structs module. In terms of compatibility issues between NPC and battle structs, we find none, but we see the potential for improvement in the stat_changes_t struct to implement the temporary stat change feature. For example, stat_changes_t could be incorporated into stat_t such that the temp_stat struct contains temporary stats implemented only during battle. However, this implementation is highly dependent on the battles team’s design choices. Please see Battle's design document for stat changes for more information.

Some changes can be made to the npc_t and npc_battle_t struct:

  1. Incorporating class_t and item_hash_t *inventory into the npc_battle_t struct
  2. What NPC classes can engage in battle?
  3. Have a separate battle_items_t *items struct in npc_battle_t?
  4. Instead of bool will_fight, incorporate hostility_t struct into npc_t?

Class type

Considerations to make:

  1. Class development with skill_tree for each class type in mind
  2. Different classes of NPCs have different skills / stats / battle items (categories that need details planned out for future sprint)
  3. Different types of battles fought for combatant_t structs with different class_t

Open World Integration

Considerations to make:

  1. Where hostile, conditional friendly, and friendly NPCs will be located
  2. How a battle_ai with an NPC will start
  3. What level of provocation will get a conditional friendly NPC to fight?
  4. Will surrender_level be higher for a hostile NPC as opposed to a conditional_friendly NPC?
  5. How will hostile NPCs approach players?
Clone this wiki locally