Difference between revisions of "PRCSCR Script Templates"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (Activating a Waypoint on the Worldmap: fixing script)
 
Line 135: Line 135:
 
'''Script:'''
 
'''Script:'''
 
<dascript>
 
<dascript>
const string WML_WOW_Custom = "eshmeswp";
 
 
#include "plt_mnp000pt_main_events"
 
#include "plt_mnp000pt_main_events"
 
#include "wrappers_h"
 
#include "wrappers_h"
 +
 +
const string WML_WOW_Custom = "eshmeswp";
 +
 
void main()
 
void main()
 
{
 
{

Latest revision as of 20:37, 26 April 2020

This page serves as a repository for ready to use M2DA's and Scripts to use in conjunction with PRCSCR M2DA's when adding custom content to the game.

References:

  • See Main Article: PRCSCR
  • See PRCSCR.xls for details about that M2DA, or 2DA for an explanation of 2DA's as a whole
  • To create a Script, right click in the Resourcepalette and select "New/Script" , or see Designer Resources for such Resources as a whole.


Contents:

1. Adding a placeable into an existing Area This Script serves to add a placeable of your choice into an Area of choice. (non removable)
2. Adding a NPC into an existing Area This Script serves to any custom NPC or Creature to a Area of choice. (removable)
3. Activating a Waypoint on the Worldmap This Script serves to activate a custom Waypoint (Map Pin) of choice ,when leaving Lothering or at any other time into the Game.
4. Adding an Item into the Players Inventory This Script serves to instantly add an Item into the Players Inventory.
5. Adding an Item to an existing Vendor or Container This Script serves to add any Item into a existing Vendors Inventory, as long the Vendor exists.
6. Adding a Working Door into an existing Area This Script serves to add a custom Door into a existing Area, that the Player can enter into a custom Area.
7. Adding a Quest to an existing Chanters Board This Script serves to add a new Quest to a existing Chanters Board, at any chosen time into the Game.
8. Playing custom Player Character Allows you to play custom character. Also: start your module with cutscene and allows you to create character 10 lvl and set it's characteristics as you want.


Adding a placeable into an existing Area

M2DA Setup:

  1. AreaListName must not be "any". Chose a specific one.
  2. Copy the GDA into your modules override folder.

Script: (As taken from the Storage Chest mod a kind Bioware employee made :o)

//const string TAL_STORAGE_CHEST_SPAWNED = "TAL_STORAGE_CHEST_SPAWNED";
const string TAL_IP_STORAGE_CHEST = "tal_ip_storage_chest";
const resource TAL_RESOURCE_IP_STORAGE_CHEST = R"tal_ip_storage_chest.utp";
 
void main()
{
    object oMainControlled = GetMainControlled();
    object oChest = UT_GetNearestObjectByTag(oMainControlled, TAL_IP_STORAGE_CHEST);
 
 
    //DisplayFloatyMessage(oMainControlled, "storage script working", FLOATY_MESSAGE, 16777215, 30.0);
 
    if (!IsObjectValid(oChest))
    {
        location lSpawn = Location(GetArea(oMainControlled), Vector(148.77, 117.68, -0.94), 0.0);
        CreateObject(OBJECT_TYPE_PLACEABLE, TAL_RESOURCE_IP_STORAGE_CHEST, lSpawn);          
 
        //DisplayFloatyMessage(oMainControlled, "storage chest created", FLOATY_MESSAGE, 16777215, 30.0);
    }
}
  1. Replace "tal_ip_storage_chest" in the 2nd line with the "Tag" of your own placeable. (only small letters allowed)
  2. Replace "tal_ip_storage_chest.utp" in 3rd line with the Resources Filename of your placable.
  3. Exchange the (4) numbers after it sais "Vector" ,which should be the location of your placable. How to determine?
  4. Create a temporary duplicate of the specific Area, and add the placeable until you see fit. (delete this Area afterwards, do not export)
  5. Note down the numbers in the Object Inspector, and get the first 3 numbers of Position, and the 4rth Number from Rotation. (only 1 number, the first)
  6. Rotation needs to be recalculated before entering it into the script. For positive angles do (180-angle). For negative angles do (-180-(-angle)).

Export the script, the placeable ,and start the game. When you arrive at the specific Area in game, the Placeable will be there.

Note: This method prevents removal of the placable. Check out a Plot driven method.

Adding a NPC into an existing Area

M2DA Setup:

  1. AreaListName must be "any". This Script is Plot driven.
  2. Copy the GDA into your modules override folder.

Script:

// this is the name of a precreated plot file "joblos_quest" prefixed with the special "plt_"
// "plt_" + quest name allows you to reference the flag names as constants.
#include "plt_joblos_quest" 
#include "wrappers_h"
 
void main()
{
    //Check whether we've added Joblo already.
    if (WR_GetPlotFlag(PLT_JOBLOS_QUEST, JOBLO_ADDED_TO_TOWN) == FALSE)
    {
        object oTown = GetObjectByTag("lot100ar_lothering"); //An area's tag is the same as its resource name
        vector vJobloLocation = Vector(126.745f, 120.724f, 0.460568f); // See below for how to get these coordinates
 
        CreateObject(
            OBJECT_TYPE_CREATURE,
            R"joblo.utc",
            Location(oTown, vJobloLocation, 180.0f) //See below for how to get the value for orientation
        ); //this semicolom was missing and caused errors 
 
        WR_SetPlotFlag("joblos_quest", JOBLO_ADDED_TO_TOWN, TRUE);
    }
}
  1. Replace "joblos_quest" (3x) with the name of your Plot.
  2. Replace "JOBLO_ADDED_TO_TOWN" (2x) with a custom Flag you create in your Plot.
  3. Replace "lot100ar_lothering" with the Tag of an Area ,the NPC should spawn in.
  4. Replace "joblo.utc" with the filename of your Creature.
  5. Exchange the (4) numbers ,which should be the location of your placable. How to determine?
  6. Create a temporary duplicate of the specific Area, and add the NPC until you see fit. (delete this Area afterwards, do not export)
  7. Note down the numbers in the Object Inspector, and get the first 3 numbers of Position, and the 4rth Number from Rotation. (only 1 number, the first)
  8. Rotation needs to be recalculated before entering it into the script. For positive angles do (180-angle). For negative angles do (-180-(-angle)).

Export the script, the creature ,and start the game. When you arrive at the specific Area in game, the Creature (Monsters or NPCs alike) will be there.

Activating a Waypoint on the Worldmap

Requirements: Your module must extend Single Player.

M2DA Setup:

  1. AreaListName must be "any". Because Waypoint activation should be universal and it is Plot driven.
  2. Copy the GDA into your modules override folder.

Script:

#include "plt_mnp000pt_main_events"
#include "wrappers_h"
 
const string WML_WOW_Custom = "eshmeswp";
 
void main()
{
    if(WR_GetPlotFlag( PLT_MNP000PT_MAIN_EVENTS, ARCHDEMON_EVENT_ONE) == TRUE )
    {
        WR_SetWorldMapLocationStatus(GetObjectByTag(WML_WOW_Custom), WM_LOCATION_ACTIVE);
    }
}
  1. Replace "eshmeswp" in the 1st line with the "Tag" of your Waypoint (Map Pin) which u created. That Map Pin can be greyed out or inactive or so. Map Pin information can be found at: Map.

Export the script, the Map ,and start the game. The Waypoint will now be activated once you leave Lothering, just like the other main Waypoints. This is to get in line with the Story. However to change the time of it happening..

  1. Choose which Plot should activate the Waypoint. The above example uses the Archdemon quest, when your nightmare triggers for example.
  2. Exchange "mnp000pt_main_events" in the 2nd and 6th line with the name of that other Plot. Leaving the "plt_" there.
  3. Exchange "ARCHDEMON_EVENT_ONE" with a "Flag" of your choice from that Plot.

This "should" work for any plot. Actually, waypoints dont need all this PRCSCR stuff and can be set "Active" in the first place. But the above example is to get in line with the Main Campaign, and potential gamebreaking Plot conflicts if able to leave Lothering too early.

Adding an Item into the Players Inventory

Requirements:

M2DA Setup:

  1. AreaListName is "any".
  2. Copy the GDA into your modules override folder.

Script:

//include utility_h for the UT_AddItemToInventory() function.
#include "utility_h"
//include the custom made plot file
#include "plt_$plot_file_name$"
 
void main()
{
    // If plot flag is TRUE then item already given.
    // Otherwise add item to inventory.
    if ( WR_GetPlotFlag( PLT_$plot_file_name$, $check_flag_name$ ) == FALSE )
    {
        UT_AddItemToInventory(R"$item_file_name$.uti");
        //Set the plot flag to TRUE to indicate that the item was given.
        WR_SetPlotFlag( PLT_$plot_file_name$, $check_flag_name$, TRUE );
    }
}
  1. Replace everything between and including the $ signs with appropriate names (without the file extensions).

Adding an Item to an existing Vendor or Container

Requirements:

M2DA Setup:

Campaign Container ContainerTag AreaListName
Origins Bodahn store_camp_bodahn cam100ar_camp_plains
Origins daytime King's Camp quartermaster pre100sr_quartermaster pre01al_kings_camp
Awakening Yuriah store_vgk100cr_merchant vgk210ar_throne_room
Awakening Party Chest in Vigil's Keep vgk210ip_party_chest vgk210ar_throne_room
Leliana's Song first Lem encounter store_lel00cr_lem lel100ar_market
  1. Create a PRCSCR M2DA override using the desired AreaListName from the above table
  2. Copy this new PRCSCR M2DA into your module's override folder (AddIns\{YourMod}\core\override)

Script:

#include "wrappers_h"
#include "plt_$plot_file_name$"  // include your custom plot
 
void main()
{
  if ( WR_GetPlotFlag( PLT_$plot_file_name$, $check_flag_name$ ) == TRUE ) return;
 
  object oContainer = GetObjectByTag("$ContainerTag$");
 
  if (IsObjectValid(oContainer))
  {
    CreateItemOnObject(R"$resource_name$.uti", oContainer, 1, "", TRUE); // repeat this for each item
 
    WR_SetPlotFlag( PLT_$plot_file_name$, $check_flag_name$, TRUE );
  }
}
  1. Replace "$plot_file_name$" and "$check_flag_name$" with the custom plot and plot flags you create for your module.
  2. Replace "$resource_name$" with the resource name of your custom item.
  3. Replace "$ContainerTag$" with the desired container tag from the table in the M2DA setup section.
  4. The very first time you go to the party camp in Origins (after leaving Lothering) and view the Archdemon cutscene, this script will NOT run when using "cam100ar_camp_plains" as the AreaListName. This is because the cutscene version of the camp is actually a different area. In this case you must exit and return to the "normal" (non-cutscene) party camp for the script to run for the first time.

Adding a Working Door into an existing Area

Requirements:

M2DA Setup:

Script: [Undocumented]

Adding a Quest to an existing Chanters Board

Requirements:

M2DA Setup:

Script: [Undocumented]