Difference between revisions of "Character generation"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (cleaned up and expanded examples for ease of use)
Line 1: Line 1:
 
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).
 
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).
 
  
 
<dascript>
 
<dascript>
Line 8: Line 7:
 
void main()
 
void main()
 
{
 
{
 +
    // keep track of whether the event has been handled
 +
    int nEventHandled = FALSE;
 +
 
     event ev = GetCurrentEvent();
 
     event ev = GetCurrentEvent();
     int nEventType = GetEventType(ev); //extract event type from current event
+
     switch(GetEventType(ev))
    int nEventHandled = FALSE; //keep track of whether the event has been handled
+
    switch(nEventType)
+
 
     {
 
     {
 
         case EVENT_TYPE_MODULE_START:
 
         case EVENT_TYPE_MODULE_START:
 
         {
 
         {
             PreloadCharGen(); //preloads resources needed for character generation
+
             // preloads resources needed for character generation
             StartCharGen(GetHero(),0); //initiates character generation
+
            PreloadCharGen();
 +
 
 +
            // initiates character generation
 +
             StartCharGen(GetHero(),0);  
 +
 
 
             break;
 
             break;
 
         }
 
         }
 
     }
 
     }
     if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
+
 
 +
     // if this event wasn't handled by this script fall through to the core script
 +
    if(!nEventHandled)
 
     {
 
     {
 
         HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
 
         HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
Line 27: Line 33:
 
</dascript>
 
</dascript>
  
Another quick and dirty method that skips the character generation interface:
+
A basic script that skips the character generation interface:
  
 
<dascript>
 
<dascript>
    #include "sys_chargen_h"
+
#include "sys_chargen_h"
    #include "utility_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:
 
         case EVENT_TYPE_MODULE_START:
 
         {
 
         {
 +
            object oHero = GetHero();
  
 
             // skip character generation
 
             // skip character generation
            object oHero = GetHero();
 
 
             Chargen_InitializeCharacter(oHero);
 
             Chargen_InitializeCharacter(oHero);
 
             Chargen_SelectGender(oHero,GENDER_MALE);
 
             Chargen_SelectGender(oHero,GENDER_MALE);
Line 47: Line 59:
  
 
             // give the player some equipment
 
             // give the player some equipment
             object oItem = UT_AddItemToInventory(R"gen_im_arm_cht_lgt_rlr.uti");
+
             EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_cht_lgt_rlr.uti"));
             EquipItem(oHero,oItem);
+
             EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_bot_lgt_rlr.uti"));
            oItem = UT_AddItemToInventory(R"gen_im_arm_bot_lgt_rlr.uti");
+
             EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_glv_lgt_rlr.uti"));
             EquipItem(oHero,oItem);
+
             EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_shd_sml_wdn.uti"));
            oItem = UT_AddItemToInventory(R"gen_im_arm_glv_lgt_rlr.uti");
+
             EquipItem(oHero, UT_AddItemToInventory(R"gen_im_wep_mel_lsw_lsw.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;
 
             break;
 
         }
 
         }
 +
    }
 +
 +
    // if this event wasn't handled by this script fall through to the core script
 +
    if(!nEventHandled)
 +
    {
 +
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
 +
    }
 +
}
 
</dascript>
 
</dascript>
  
Another alternative is to create a template creature and then call LoadItemsFromTemplate to copy it to the player.
+
Another alternative is to create a template creature with the appropriate starting equipment and then call [[LoadItemsFromTemplate]] to copy it to the player:
  
 
<dascript>
 
<dascript>
 
         case EVENT_TYPE_MODULE_START:
 
         case EVENT_TYPE_MODULE_START:
 
         {
 
         {
            // skip character generation
 
 
             object oHero = GetHero();
 
             object oHero = GetHero();
 +
 +
            // skip character generation
 
             Chargen_InitializeCharacter(oHero);
 
             Chargen_InitializeCharacter(oHero);
 
             Chargen_SelectRace(oHero,RACE_HUMAN);
 
             Chargen_SelectRace(oHero,RACE_HUMAN);
Line 74: Line 90:
 
             Chargen_SelectBackground(oHero,BACKGROUND_NOBLE);
 
             Chargen_SelectBackground(oHero,BACKGROUND_NOBLE);
  
 +
            // give the player some equipment
 
             LoadItemsFromTemplate(oHero, "gcd_hero.utc", TRUE);
 
             LoadItemsFromTemplate(oHero, "gcd_hero.utc", TRUE);
  
Line 80: Line 97:
 
</dascript>
 
</dascript>
  
For a quick-and-dirty level up, you could add the following to one of the examples above:
+
If you want to increase the starting level a basic script can be created by merging one of the above with the following template:
  
 
<dascript>
 
<dascript>
...
+
// [additional includes goes here]
 
+
 
#include "sys_rewards_h"
 
#include "sys_rewards_h"
 +
 
const int FORCE_AUTOLEVEL = 2;
 
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:
 
         case EVENT_TYPE_MODULE_START:
 
         {
 
         {
 
             object oHero = GetHero();
 
             object oHero = GetHero();
...
+
 
             // Make character level 10
+
             // [chargen code goes here]
             int nTargetLevel = 10;
+
 
             RewardXP(oHero, RW_GetXPNeededForLevel(nTargetLevel), FALSE, FALSE);
+
             // auto-level the player to level 10
 +
             RewardXP(oHero, RW_GetXPNeededForLevel(10), FALSE, FALSE);
 
             SetAutoLevelUp(oHero, FORCE_AUTOLEVEL);
 
             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);
 +
    }
 +
}
 
</dascript>
 
</dascript>
  
A more sophisticated script could include other setup 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.
  
 
[[Category:Character generation]]
 
[[Category:Character generation]]

Revision as of 10:14, 29 November 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 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);
    }
}

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;
         }

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.