Difference between revisions of "Playing custom Player Character"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(Module script)
(Area scipt)
Line 138: Line 138:
  
 
This is script of your starting area
 
This is script of your starting area
 +
<dascript>
 +
//::///////////////////////////////////////////////
 +
//:: Area Core
 +
//:: Copyright (c) 2003 Bioware Corp.
 +
//:://////////////////////////////////////////////
 +
/*
 +
    Handles global area events
 +
*/
 +
//:://////////////////////////////////////////////
 +
//:: Created By: Yaron
 +
//:: Created On: July 17th, 2006
 +
//:://////////////////////////////////////////////
  
 +
#include "log_h"
 +
#include "utility_h"
 +
#include "wrappers_h"
 +
#include "events_h"
 +
#include "2da_constants_h"
 +
 +
#include "lpt_utility_h"
 +
 +
#include "plt_lpt_module_plot"
 +
 +
void main()
 +
{
 +
    event ev = GetCurrentEvent();
 +
    int nEventType = GetEventType(ev);
 +
    string sDebug;
 +
    object oPC = GetHero();
 +
    object oParty = GetParty(oPC);
 +
    int nEventHandled = FALSE;
 +
 +
    switch(nEventType)
 +
    {
 +
        ///////////////////////////////////////////////////////////////////////
 +
        // Sent by: The engine
 +
        // When: it is for playing things like cutscenes and movies when
 +
        // you enter an area, things that do not involve AI or actual game play
 +
        ////////////////////////////////////////////////////////////////////////
 +
        case EVENT_TYPE_AREALOAD_SPECIAL:
 +
        {
 +
 +
            PrintToLog("-----> START AREA - AREALOAD SPECIAL.");
 +
 +
            //moved cutscene and hiring code to postloadexit cause some
 +
            //stuff didnt worked here
 +
 +
            //EDIT: It seems that works with this approach! left other info for
 +
            //      learn and debug purposes.
 +
 +
            //we run cutscene in this event cause in areaload special we could not
 +
            //hire follower with desired behavior (gain xp and skills can be set)..
 +
            //since cutscene and hiring are to be done only once we keep them together.
 +
            //here it works.. why? i dont know..
 +
            if (WR_GetPlotFlag(PLT_LPT_MODULE_PLOT, MODULE_START_CUTSCENE) == FALSE)
 +
            {
 +
                //roquefort is added to start area and has tag "roquefort"
 +
                object oFollower = GetObjectByTag("party_roquefort");
 +
 +
                //this caused follower to not gain xp, it is bug in game script
 +
                //UT_HireFollower(oFollower); //we're not using this
 +
 +
                //instead hiring follower with UT_hirefollower, set plot flag and
 +
                //start script which will hire Roquefort..
 +
                //this is used if you want to set plot flag to "know" that roquefort is hired
 +
                //like in some dialogues etc where you can check for conditions..
 +
                //WR_SetPlotFlag(PLT_LOP_MODULE_PLOT, ROQUEFORT_HIRED, TRUE, TRUE);
 +
 +
                //eventually we can try this to avoid plots at all!
 +
                //but i guess it would not work as it should without setting
 +
                //bResetFollower to true..
 +
                lop_UT_HireFollower(oFollower, FALSE, 0, TRUE, CLASS_WARRIOR);
 +
 +
                // Start cutscene, also set plot flag that cutscene was played.
 +
                PrintToLog("-----> START AREA - Load Cutscene.");
 +
                CS_LoadCutscene(R"lpt_module_intro.cut", PLT_LPT_MODULE_PLOT, MODULE_START_CUTSCENE);
 +
                PlayCutscene();
 +
            }
 +
 +
            break;
 +
        }
 +
        ///////////////////////////////////////////////////////////////////////
 +
        // Sent by: The engine
 +
        // When: for things you want to happen while the load screen is still up,
 +
        // things like moving creatures around
 +
        ////////////////////////////////////////////////////////////////////////
 +
        case EVENT_TYPE_AREALOAD_PRELOADEXIT:
 +
        {
 +
            break;
 +
        }
 +
        ////////////////////////////////////////////////////////////////////////
 +
        // Sent by: The engine
 +
        // When: fires at the same time that the load screen is going away,
 +
        // and can be used for things that you want to make sure the player sees.
 +
        ////////////////////////////////////////////////////////////////////////
 +
        case EVENT_TYPE_AREALOAD_POSTLOADEXIT:
 +
        {
 +
            break;
 +
        }
 +
        ////////////////////////////////////////////////////////////////////////
 +
        // Sent by: The engine
 +
        // When: A creature enters the area
 +
        ////////////////////////////////////////////////////////////////////////
 +
        case EVENT_TYPE_ENTER:
 +
        {
 +
            object oCreature = GetEventCreator(ev);
 +
 +
            break;
 +
        }
 +
        ////////////////////////////////////////////////////////////////////////
 +
        // Sent by: The engine
 +
        // When: A creature exits the area
 +
        ////////////////////////////////////////////////////////////////////////
 +
        case EVENT_TYPE_EXIT:
 +
        {
 +
            object oCreature = GetEventCreator(ev);
 +
 +
            break;
 +
        }
 +
    }
 +
    if (!nEventHandled)
 +
    {
 +
        HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
 +
    }
 +
}
 +
</dascript>
  
  

Revision as of 04:36, 15 July 2014

Author: dr. dummie

This tutorial:

  • Allows you to play custom character.
  • Start your module with cutscene.
  • Allows you to create character 10 lvl and set it's characteristics as you want.


Characters

Plot file

You need to create plot file of your module

There is only one

Module script

This is script of your module

//::///////////////////////////////////////////////
//:: Module Template
//:: Copyright (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Module events
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
 
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
 
#include "sys_chargen_h"
#include "sys_rewards_h"
 
const int FORCE_AUTOLEVEL = 0;  //to turn autolevel off
 
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    string sDebug;
    object oPC = GetHero();
    object oParty = GetParty(oPC);
    int nEventHandled = FALSE;
 
    switch(nEventType)
    {
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: The module starts. This can happen only once for a single
        //       game instance.
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_MODULE_START:
        {
 
            //normally we would go trough chargen
            //PreloadCharGen();
            //StartCharGen(GetHero());
 
            //but since we have fixed hero
            object oHero = GetHero();
 
            // skip character generation and set some defaults
            Chargen_InitializeCharacter(oHero);
            Chargen_SelectGender(oHero, GENDER_FEMALE);
            Chargen_SelectRace(oHero, RACE_HUMAN);
            Chargen_SelectCoreClass(oHero,CLASS_ROGUE);
            Chargen_SelectBackground(oHero, BACKGROUND_NOBLE);
 
            //give hero a name
            SetName(oHero, "Ariana");
 
            //manually give the player some equipment
            //EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_cht_lgt_new.uti"));
 
            //or create your fixed character as template and then transfer everything on player.
            LoadItemsFromTemplate(oHero, "lpt_000c_ariana.utc", TRUE);
 
            //NOTE!
            //to get player appereance as you like, you must create blank char with desired facemorph
            //then after export copy that char to "default_player.utc" in your module override directory
            //so now this will be default char instead JADEN
 
            // lets go level 10 and set autolevel to off
            RewardXP(oHero, RW_GetXPNeededForLevel(10), FALSE, FALSE);
            SetAutoLevelUp(oHero, FORCE_AUTOLEVEL);
 
            PrintToLog("------> MODULE START - Ariana created");
 
            break;
        }
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: The module loads from a save game. This event can fire more than
        //       once for a single module or game instance.
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_MODULE_LOAD:
        {
            break;
        }
    ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: A player enters the module
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_ENTER:
        {
            object oCreature = GetEventCreator(ev);
 
            break;
        }
    ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: the player clicks on a destination in the world map
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_WORLD_MAP_USED:
        {
            int nFrom = GetEventInteger(ev, 0); // travel start location
            int nTo = GetEventInteger(ev, 1); // travel target location
            break;
        }
    }
    if (!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
    }
}

Area scipt

This is script of your starting area

//::///////////////////////////////////////////////
//:: Area Core
//:: Copyright (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Handles global area events
*/
//:://////////////////////////////////////////////
//:: Created By: Yaron
//:: Created On: July 17th, 2006
//:://////////////////////////////////////////////
 
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "2da_constants_h"
 
#include "lpt_utility_h"
 
#include "plt_lpt_module_plot"
 
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    string sDebug;
    object oPC = GetHero();
    object oParty = GetParty(oPC);
    int nEventHandled = FALSE;
 
    switch(nEventType)
    {
        ///////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: it is for playing things like cutscenes and movies when
        // you enter an area, things that do not involve AI or actual game play
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_AREALOAD_SPECIAL:
        {
 
            PrintToLog("-----> START AREA - AREALOAD SPECIAL.");
 
            //moved cutscene and hiring code to postloadexit cause some
            //stuff didnt worked here
 
            //EDIT: It seems that works with this approach! left other info for
            //      learn and debug purposes.
 
            //we run cutscene in this event cause in areaload special we could not
            //hire follower with desired behavior (gain xp and skills can be set)..
            //since cutscene and hiring are to be done only once we keep them together.
            //here it works.. why? i dont know..
            if (WR_GetPlotFlag(PLT_LPT_MODULE_PLOT, MODULE_START_CUTSCENE) == FALSE)
            {
                //roquefort is added to start area and has tag "roquefort"
                object oFollower = GetObjectByTag("party_roquefort");
 
                //this caused follower to not gain xp, it is bug in game script
                //UT_HireFollower(oFollower); //we're not using this
 
                //instead hiring follower with UT_hirefollower, set plot flag and
                //start script which will hire Roquefort..
                //this is used if you want to set plot flag to "know" that roquefort is hired
                //like in some dialogues etc where you can check for conditions..
                //WR_SetPlotFlag(PLT_LOP_MODULE_PLOT, ROQUEFORT_HIRED, TRUE, TRUE);
 
                //eventually we can try this to avoid plots at all!
                //but i guess it would not work as it should without setting
                //bResetFollower to true..
                lop_UT_HireFollower(oFollower, FALSE, 0, TRUE, CLASS_WARRIOR);
 
                // Start cutscene, also set plot flag that cutscene was played.
                PrintToLog("-----> START AREA - Load Cutscene.");
                CS_LoadCutscene(R"lpt_module_intro.cut", PLT_LPT_MODULE_PLOT, MODULE_START_CUTSCENE);
                PlayCutscene();
             }
 
            break;
        }
        ///////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: for things you want to happen while the load screen is still up,
        // things like moving creatures around
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_AREALOAD_PRELOADEXIT:
        {
            break;
        }
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: fires at the same time that the load screen is going away,
        // and can be used for things that you want to make sure the player sees.
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_AREALOAD_POSTLOADEXIT:
        {
            break;
        }
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: A creature enters the area
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_ENTER:
        {
            object oCreature = GetEventCreator(ev);
 
            break;
        }
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: A creature exits the area
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_EXIT:
        {
            object oCreature = GetEventCreator(ev);
 
            break;
        }
    }
    if (!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
    }
}