龙腾世纪起源教你如何在自己的模组产生玩者人物
模组内玩家人物产生教学:
一般刚创立的模组(Module)没有事件脚本(Script)来启动玩家创立人物,要让玩家可以使用DA内建的创立人物介面,可以使用以下的模组事件脚本来达到效果。
请先创立一个脚本,然后在脚本内输入以下的脚本,之后打开模组属性(档案-> 管理模组-> 属性)将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);
}
}
另一个快速的方法跳过人物产生介面
编码:
#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;
}
另一种方法是创建一个生物范本([b]Template),然后呼叫(LoadItemsFromTemplate) 函式将它复制到玩者人物. [/b]
编码: :
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;
}
若要快速升级, 你可以加入以下的脚本到上面的任何范例内:
编码: :
...
#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);
...
}
一个更复杂的脚本可能包括其他设定程式码,例如触发介绍或是电影通知玩家在游戏的剧情.