Difference between revisions of "Character generation"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (remove some unused comments)
Line 61: Line 61:
 
         case EVENT_TYPE_MODULE_START:
 
         case EVENT_TYPE_MODULE_START:
 
         {
 
         {
            //PreloadCharGen(); //preloads resources needed for character generation
 
            //StartCharGen(GetHero(),0); //initiates character generation
 
 
             // skip character generation
 
             // skip character generation
 
             object oHero = GetHero();
 
             object oHero = GetHero();

Revision as of 22:43, 19 August 2009

A module with no event script will start the player without going through character generation, which will leave the player with an almost unusable character to play with. To send the player through a basic character generation UI use the following script as the module event script:

#include "events_h"
#include "global_objects_h"
 
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev); //extract event type from current event
    int nEventHandled = FALSE; //keep track of whether the event has been handled
    switch(nEventType)
    {
         case EVENT_TYPE_MODULE_START:
         {
            PreloadCharGen(); //preloads resources needed for character generation
            StartCharGen(GetHero(),0); //initiates character generation
            break;
         }
    }
    if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
    }
}

Another quick and dirty method that skips the character generation interface:

        case EVENT_TYPE_MODULE_START:
        {
 
            // skip character generation
            object oHero = GetHero();
            Chargen_InitializeCharacter(oHero);
            Chargen_SelectGender(oHero,GENDER_MALE);
            Chargen_SelectRace(oHero,RACE_HUMAN);
            Chargen_SelectCoreClass(oHero,CLASS_WARRIOR);
            Chargen_SelectBackground(oHero,BACKGROUND_NOBLE);
 
            // give the player some equipment
            object oItem = UT_AddItemToInventory(R"gen_im_arm_cht_lgt_rlr.uti");
            EquipItem(oHero,oItem);
            oItem = UT_AddItemToInventory(R"gen_im_arm_bot_lgt_rlr.uti");
            EquipItem(oHero,oItem);
            oItem = UT_AddItemToInventory(R"gen_im_arm_glv_lgt_rlr.uti");
            EquipItem(oHero,oItem);
            oItem = UT_AddItemToInventory(R"gen_im_arm_shd_sml_wdn.uti");
            EquipItem(oHero,oItem);
            oItem = UT_AddItemToInventory(R"gen_im_wep_mel_lsw_lsw.uti");
            EquipItem(oHero,oItem);
 
            break;
        }

Another alternative is to create a template creature and then call LoadItemsFromTemplate to copy it to the player.

         case EVENT_TYPE_MODULE_START:
         {
            // skip character generation
            object oHero = GetHero();
            Chargen_InitializeCharacter(oHero);
            Chargen_SelectRace(oHero,RACE_HUMAN);
            Chargen_SelectCoreClass(oHero,CLASS_WARRIOR);
            Chargen_SelectBackground(oHero,BACKGROUND_NOBLE);
 
            LoadItemsFromTemplate(oHero, "gcd_hero.utc", TRUE);
 
            break;
         }

A more sophisticated script could include other setup code, for example triggering an introductory cinematic to inform the player of the game's plot.