Character generation
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() { 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:
A more sophisticated script could include other setup code, for example triggering an introductory cinematic to inform the player of the game's plot.