模组内玩家人物产生教学:
一般刚创立的模组(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);
...
}
一个更复杂的脚本可能包括其他设定程式码,例如触发介绍或是电影通知玩家在游戏的剧情.