Difference between revisions of "Character generation"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(Skipping Character Generation)
m (linki)
Line 32: Line 32:
 
}
 
}
 
</dascript>
 
</dascript>
 +
 
==Skipping Character Generation==
 
==Skipping Character Generation==
 
A basic script that skips the character generation interface:
 
A basic script that skips the character generation interface:
Line 139: Line 140:
  
 
A more sophisticated script could include other set-up code, for example triggering an introductory cinematic to inform the player of the game's plot.
 
A more sophisticated script could include other set-up code, for example triggering an introductory cinematic to inform the player of the game's plot.
 +
 +
== Modifying the morph-generating step of character generation ==
 +
 +
See [[Chargenmorphcfg.xml]] for information about how to modify this step of character generation.
  
 
[[Category:Character generation]]
 
[[Category:Character generation]]

Revision as of 20:04, 18 February 2010

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 below script as the module event script. This is done by first creating the below script, and saving it, then opening your module properties (file > manage modules > properties), and changing the "script" field to be whatever you named your script (hit the ellipsis and browse for it).

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

Skipping Character Generation

A basic script that skips the character generation interface:

#include "sys_chargen_h"
#include "utility_h" 
 
void main()
{
    // keep track of whether the event has been handled
    int nEventHandled = FALSE; 
 
    event ev = GetCurrentEvent();
    switch(GetEventType(ev))
    {
        case EVENT_TYPE_MODULE_START:
        {
            object oHero = GetHero();
 
            // skip character generation
            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
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_cht_lgt_rlr.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_bot_lgt_rlr.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_glv_lgt_rlr.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_shd_sml_wdn.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_wep_mel_lsw_lsw.uti"));
 
            break;
        }
    }
 
    // if this event wasn't handled by this script fall through to the core script
    if(!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
    }
}

Another alternative is to create a template creature with the appropriate starting equipment and then call LoadItemsFromTemplate to copy it to the player:

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

It should be noted that, by skipping the internal character generation process that way, the character will have the correct stats but will be featureless and bald. To change that Bioware is working on an additional function to change the head morph via script.

Initial levelup or other modifications

If you want to increase the starting level a basic script can be created by merging one of the above with the following template:

// [additional includes goes here]
#include "sys_rewards_h"
 
const int FORCE_AUTOLEVEL = 2;
 
void main()
{
    // keep track of whether the event has been handled
    int nEventHandled = FALSE; 
 
    event ev = GetCurrentEvent();
    switch(GetEventType(ev))
    {
         case EVENT_TYPE_MODULE_START:
         {
            object oHero = GetHero();
 
            // [chargen code goes here]
 
            // auto-level the player to level 10
            RewardXP(oHero, RW_GetXPNeededForLevel(10), FALSE, FALSE);
            SetAutoLevelUp(oHero, FORCE_AUTOLEVEL);
 
            break;
         }
    }
 
    // if this event wasn't handled by this script fall through to the core script
    if(!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
    }
}

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

Modifying the morph-generating step of character generation

See Chargenmorphcfg.xml for information about how to modify this step of character generation.