Difference between revisions of "Character generation"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(add those includes. This is still just a code fragment, mind you, it needs to be inserted into an event handler)
Line 76: Line 76:
  
 
             break;
 
             break;
 +
        }
 +
</dascript>
 +
 +
For a quick-and-dirty level up, you could add the following to one of the examples above:
 +
 +
<dascript>
 +
...
 +
 +
#include "sys_rewards_h"
 +
const int FORCE_AUTOLEVEL = 2;
 +
 +
...
 +
 +
        case EVENT_TYPE_MODULE_START:
 +
        {
 +
            object oHero = GetHero();
 +
...
 +
            // Make character level 10
 +
            int nTargetLevel = 10;
 +
            RewardXP(oHero, RW_GetXPNeededForLevel(nTargetLevel), FALSE, FALSE);
 +
            SetAutoLevelUp(oHero, FORCE_AUTOLEVEL);
 +
...
 
         }
 
         }
 
</dascript>
 
</dascript>

Revision as of 09:34, 25 October 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:

    #include "sys_chargen_h"
    #include "utility_h" 
 
...
 
        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;
         }

For a quick-and-dirty level up, you could add the following to one of the examples above:

...
 
#include "sys_rewards_h"
const int FORCE_AUTOLEVEL = 2;
 
...
 
         case EVENT_TYPE_MODULE_START:
         {
            object oHero = GetHero();
...
            // Make character level 10
            int nTargetLevel = 10;
            RewardXP(oHero, RW_GetXPNeededForLevel(nTargetLevel), FALSE, FALSE);
            SetAutoLevelUp(oHero, FORCE_AUTOLEVEL);
...
         }

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