I did not duplicate it, I just made a plot called background_check with four flags. HERO_IS_ELVEN, HERO_IS_DWARVEN, HERO_IS_MAGE, HERO_IS_FEMALE for conversations and things among those lines.
The scripts are as follows, the forum has some wierd stuff going on.
mymod_sys_chargen:
#include "bdm_sys_chargen_h"
#include "log_h"
const int CHARGEN_QUICKSTART_QUICK = 0;
const int CHARGEN_QUICKSTART_NORMAL = 1;
const int CHARGEN_QUICKSTART_ADVANCED = 2;
void _RunChargen(int nRace, int nclass, object oChar, int nBackground)
{
Chargen_InitializeCharacter(oChar);
Chargen_SelectGender(oChar,GENDER_MALE);
Chargen_SelectRace(oChar,nRace);
Chargen_SelectCoreclass(oChar,nclass);
Chargen_SelectBackground(oChar, nBackground,FALSE);
int nEquipIdx = Chargen_GetEquipIndex(nRace, nclass, nBackground);
Chargen_InitInventory(oChar,0,nEquipIdx);
Chargen_SpendAttributePoints(oChar,PROPERTY_ATTRIBUTE_STRENGTH, 3,FALSE);
Chargen_SpendAttributePoints(oChar,PROPERTY_ATTRIBUTE_DEXTERITY, 2,FALSE);
}
void main(){
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
object oChar = GetEventObject(ev,0);
int nMode;
int nInt0 = GetEventInteger(ev,0);
int nInt1 = GetEventInteger(ev,1);
// -------------------------------------------------------------------------
// Debug Data.
// -------------------------------------------------------------------------
Log_Trace(LOG_CHANNEL_EVENTS_CHARGEN,"bdm_sys_chargen","Chargen Event:" + Log_GetEventNameById (nEventType)
+ " " + ToString(nInt0) + "," + ToString(nInt1), oChar);
int nEventHandled = FALSE;
switch (nEventType)
{
// ----------------------------------------------------------------------
// This fires when the player selects the icon corresponding to any of
// the available backgrounds
//
// nInt0 - Constant BACKGROUND_* integer
// ----------------------------------------------------------------------
case EVENT_TYPE_CHARGEN_SELECT_BACKGROUND: {
int nBackground = nInt0;
// -----------------------------------------------------------------
// Set the background on the player and reinitialize plot flags
// for the background
// -----------------------------------------------------------------
Chargen_InitializeCharacter(oChar,TRUE);
Chargen_SelectGender(oChar,GetCreatureGender(oChar));
Chargen_SelectRace(oChar,GetCreatureRacialType(oChar));
Chargen_SelectCoreclass(oChar,GetCreatureCoreclass(oChar));
bdm_Chargen_SelectBackground(oChar, nBackground, FALSE);
bdm_Chargen_SetupPlotFlags(oChar);
// -----------------------------------------------------------------
// Generate the index into the equipment template 2da and
// then load the starting equipment based on the data returned.
// -----------------------------------------------------------------
int nclass = GetCreatureCoreclass(oChar);
int nRace = GetCreatureRacialType(oChar);
int nEquipIdx = Chargen_GetEquipIndex(nRace, nclass, nBackground);
Chargen_InitInventory(oChar,0,nEquipIdx);
nEventHandled = TRUE;
break;
}
case EVENT_TYPE_CHARGEN_END: {
nMode = nInt0;
int nQuickStart = nInt1;
// 0 - quickstart
// 1 - normal \\\\
// 2 - advanced / treat as the same
Log_Trace(LOG_CHANNEL_CHARACTER,"bdm_sys_chargen","MODE: " + IntToString(nMode)
+ ", Quick Start: " + IntToString(nQuickStart));
if (nMode == CHARGEN_MODE_CREATE && nQuickStart == CHARGEN_QUICKSTART_QUICK){
Log_Trace(LOG_CHANNEL_CHARACTER,"bdm_sys_chargen","Setting default values for player character");
int nRandclass = abs((GetLowResTimer()%3)+1);
if(nRandclass == class_ROGUE || nRandclass == class_WARRIOR)
{
_RunChargen(RACE_HUMAN, nRandclass, oChar, BACKGROUND_GRAYWARDEN);
WR_SetPlotFlag(background_check, HERO_IS_MAGE, FALSE);
}
else // mage
{
_RunChargen(RACE_HUMAN, nRandclass, oChar, BACKGROUND_GRAYWARDEN );
WR_SetPlotFlag(background_check, HERO_IS_MAGE, TRUE);;
}
Chargen_SetNumTactics(oChar);
SetCanLevelUp(oChar,Chargen_HasPointsToSpend(oChar));
SendEventModuleChargenDone("", "");
nEventHandled = TRUE;
}
break;
}
} //end switch
if (!nEventHandled){
HandleEvent(ev, R"sys_chargen.ncs");
}
}
bdm_sys_chargen_h
#include "sys_chargen_h"
#include "wrappers_h"
#include "plt_background_check"
void bdm_Chargen_SelectBackground(object oChar, int nBackground, int bUnApply, int nRace, int nGender = FALSE)
{
Log_Chargen("bdm_Chargen_SelectBackground","-- " + (bUnApply?"Un":"") +"Selecting BG: " + ToString(nBackground),oChar);
// -------------------------------------------------------------------------
// 1. Set the background variable
// - Create creature property (or check what we used so far
// - We don't set backgrounds on non player generated chars.
// -------------------------------------------------------------------------
if (bUnApply)
{
SetCreatureProperty(oChar, PROPERTY_SIMPLE_BACKGROUND, 0.0, PROPERTY_VALUE_BASE);
}
else
{
SetCreatureProperty(oChar, PROPERTY_SIMPLE_BACKGROUND, IntToFloat(nBackground), PROPERTY_VALUE_BASE);
}
// -------------------------------------------------------------------------
// 2. Give one skill
// - retrieve the skill that is granted by the background from backgrounds.xls
// - give it to the player.
// -------------------------------------------------------------------------
int nAbility = ChargenGetBackgroundSkill(GetCreatureRacialType(oChar), nBackground);
if (nAbility)
{
_AddAbility (oChar, nAbility, bUnApply);
}
}
void bdm_Chargen_SetupPlotFlags(object oChar)
{
int nRace = GetCreatureRacialType(oChar);
int nBackground = GetPlayerBackground(oChar);
int nGender = GetCreatureGender(oChar);
Log_Trace(LOG_CHANNEL_CHARACTER,"bdm_sys_chargen_h","Setting plot flags, race: "
+ IntToString(nRace) + ", background: " + IntToString(nBackground));
// First, init all flags (debug setup)
WR_SetPlotFlag(plt_background_check, HERO_IS_ELVEN,FALSE);
WR_SetPlotFlag(plt_background_check, HERO_IS_DWARVEN,FALSE);
WR_SetPlotFlag(plt_background_check, HERO_IS_FEMALE,FALSE);
switch (nBackground)
{
case 1:
{
switch(nRace)
{
case RACE_DWARF: WR_SetPlotFlag(plt_background_check,HERO_IS_DWARVEN ,TRUE); break;
case RACE_ELF: WR_SetPlotFlag(plt_background_check, HERO_IS_ELVEN,TRUE); break;
}
break;
switch(nGender)
{
case GENDER_FEMALE: WR_SetPlotFlag(plt_background_check, HERO_IS_FEMALE,TRUE); break;
}
break;
}
}
}
Modifié par Gisle Aune, 06 septembre 2010 - 06:33 .