//:://///////////////////////////////////////////// //:: TRUE Random Task Generator //:: rtg_i0_generic //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* This file is the main processing center for the RTG. Task element storage task generation and rewarding are all handled via calls to functions here. */ //::////////////////////////////////////////////// //:: Created By: Nathan 'yibble' Reynolds //:: Created On: 10/11/2002 //::////////////////////////////////////////////// //void main(){} // Uncomment to permit debug compiles. ////////////////////////////////////////////////// // The structures that holds the information for a task ////////////////////////////////////////////////// struct RTG_TaskData { int nType; // Type of task. int nCR; // Challenge rating of task. int nActive; // Flag the task as Active. int nSpawnerInstance;// Instance of Spawner. int nRewardItemNum; // Number of stacked reward items. int nRewardGold; // NOT USED: Gold reward for completing task. int nRewardXP; // NOT USED: Experience reward for completing task. int nNumItems; // Currently used only in Harvest tasks. string sItemRef; // Blueprint reference of item for task. string sItemName; // Name reference of item for task. string sItemTag; // Blueprint reference of item for task. string sAntagonistRef; // Blueprint reference of antagonsist in task. string sAntagonistName; // Name reference of antagonsist in task. string sProtagonistRef; // Blueprint reference of protagonsist in task. string sProtagonistName;// Name reference of protagonsist in task. string sText; // Text that is spoken by NPCs. string sSpawnerLoc; // Name of Spawners parent area. string sRewardItemRef; // Blueprint of item reward for completing task. string sRewardItemName; // Name of item reward for completing task. }; struct RTG_TaskPhraseData { int nType; // Type of task. string sText; // Text of the task. }; struct RTG_TaskReplyPhraseData { int nType; // Type of task. string sText; // Text of the task. }; struct RTG_TaskCompletePhraseData { int nType; // Type of task. string sText; // Text of the task. }; struct RTG_TaskItemData { int nCR; // Challenge rating of item. string sRef; // Blueprint reference of item for task. string sTag; // Tag of task item. string sName; // Name of item. }; struct RTG_TaskAntagonistData { int nCR; // Challenge rating of item. int nType; // Antagonists have types now! string sRef; // Blueprint reference of item for task. string sName; // Name of antagonist. }; struct RTG_TaskProtagonistData { int nCR; // Challenge rating of item. string sRef; // Blueprint reference of item for task. string sName; // Name of protagonist. }; struct RTG_RewardItemData { int nCR; // Challenge rating of item. int nNum; // Number of stacked reward items. string sRef; // Blueprint reference of item for task. string sName; // Name of reward item. }; //////////////////////////////////////////////////////////////////////////////// // These are the prototypes of all the public functions //////////////////////////////////////////////////////////////////////////////// // Gets the number of start phrases that are in the system. int Private_GetTaskPhraseCount(); // Gets the number of reply phrases that are in the system. int Private_GetTaskReplyPhraseCount(); // Gets the number of completion phrases that are in the system. int Private_GetTaskCompletePhraseCount(); // NOT USED: Gets the number of active tasks that are in the system. int Private_GetTaskCount(); // Gets the number of target items that are in the system. int Private_GetTaskItemCount(); // Gets the number of antagonsists that are in the system. int Private_GetAntagonistCount(); // Gets the number of protagonsists that are in the system. int Private_GetProtagonistCount(); // Gets the number of reward items that are in the system. int Private_GetRewardItemCount(); // Gets the number of related spawners that are in the system. int Private_GetVeryEasyHostileSpawnerCount(); // Gets the number of related spawners that are in the system. int Private_GetVeryEasyFriendlySpawnerCount(); //////////////////////////////////////////////////////////////////////////////// // These are the prototypes of all the private functions //////////////////////////////////////////////////////////////////////////////// // Sets the number of start phrases that are in the system. void Private_SetTaskPhraseCount(int nValue); // Sets the number of reply phrases that are in the system. void Private_SetTaskReplyPhraseCount(int nValue); // Sets the number of completion phrases that are in the system. void Private_SetTaskCompletePhraseCount(int nValue); // NOT USED: Sets the number of active tasks that are in the system. void Private_SetTaskCount(int nValue); // Sets the number of target items that are in the system. void Private_SetItemCount(int nValue); // Sets the number of antagonsists that are in the system. void Private_SetAntagonistCount(int nValue); // Sets the number of protagonsists that are in the system. void Private_SetProtagonistCount(int nValue); // Sets the number of reward items that are in the system. void Private_SetRewardItemCount(int nValue); // Sets the number of related spawners that are in the system. void Private_SetVeryEasyHostileSpawnerCount(int nValue); // Sets the number of related spawners that are in the system. void Private_SetVeryEasyFriendlySpawnerCount(int nValue); // Get a specific element from the system. struct RTG_TaskPhraseData Private_GetTaskPhrase(int nIndex); // Get a specific element from the system. struct RTG_TaskItemData Private_GetTaskItem(int nIndex); // Get a specific element from the system. struct RTG_TaskAntagonistData Private_GetAntagonist(int nIndex); // Get a specific element from the system. struct RTG_TaskProtagonistData Private_GetProtagonist(int nIndex); // Get a specific element from the system. struct RTG_RewardItemData Private_GetRewardItem(int nIndex); // Get a specific element from the system. struct RTG_TaskReplyPhraseData Private_GetTaskReplyPhrase(int nIndex); // Get a specific element from the system. struct RTG_TaskCompletePhraseData Private_GetTaskCompletePhrase(int nIndex); //////////////////////////////////////////////////////////////////////////////// // Constants. //////////////////////////////////////////////////////////////////////////////// #include "rtg_i0_const" //////////////////////////////////////////////////////////////////////////////// // Public Functions. //////////////////////////////////////////////////////////////////////////////// void DebugMessage(string sMessage) { PrintString(sMessage); } void RTG_CreateTaskGenerator() { Private_SetTaskPhraseCount(0); Private_SetTaskReplyPhraseCount(0); Private_SetTaskCompletePhraseCount(0); Private_SetTaskCount(0); Private_SetItemCount(0); Private_SetAntagonistCount(0); Private_SetProtagonistCount(0); Private_SetRewardItemCount(0); // Count Very Easy Hostile Spawners. int nCount = 0; object oSpawner = GetObjectByTag("RTG_VEASY_SPWN_HOS", 0); while(GetIsObjectValid(oSpawner)) { nCount ++; oSpawner = GetObjectByTag("RTG_VEASY_SPWN_HOS", nCount); } Private_SetVeryEasyHostileSpawnerCount(nCount --); // Count Very Easy Friendly Spawners. nCount = 0; oSpawner = GetObjectByTag("RTG_VEASY_SPWN_FRE", 0); while(GetIsObjectValid(oSpawner)) { nCount ++; oSpawner = GetObjectByTag("RTG_VEASY_SPWN_FRE", nCount); } Private_SetVeryEasyFriendlySpawnerCount(nCount --); } string ParseText(string sOriginalPhrase, string sLabel, string sItemName) { int nPosition = FindSubString(sOriginalPhrase, sLabel); if(!nPosition) return sOriginalPhrase; return GetSubString(sOriginalPhrase, 0, nPosition) + sItemName + GetSubString(sOriginalPhrase, nPosition + GetStringLength(sLabel), GetStringLength(sOriginalPhrase)); } void RTG_AddTaskPhraseData (struct RTG_TaskPhraseData newTaskPhraseData) { int nPhrases; nPhrases = Private_GetTaskPhraseCount(); string sPhraseIndex = IntToString(nPhrases); object oModule = GetModule(); SetLocalString(oModule, "RTG_sTaskPhraseText" + sPhraseIndex, newTaskPhraseData.sText); SetLocalInt(oModule, "RTG_sTaskPhraseType" + sPhraseIndex, newTaskPhraseData.nType); Private_SetTaskPhraseCount(nPhrases + 1); } void RTG_AddTaskReplyPhraseData (struct RTG_TaskReplyPhraseData newTaskReplyPhraseData) { int nPhrases; nPhrases = Private_GetTaskReplyPhraseCount(); string sPhraseIndex = IntToString(nPhrases); object oModule = GetModule(); SetLocalString(oModule, "RTG_sTaskReplyPhraseText" + sPhraseIndex, newTaskReplyPhraseData.sText); SetLocalInt(oModule, "RTG_sTaskReplyPhraseType" + sPhraseIndex, newTaskReplyPhraseData.nType); Private_SetTaskReplyPhraseCount(nPhrases + 1); } void RTG_AddTaskCompletePhraseData (struct RTG_TaskCompletePhraseData newTaskCompletePhraseData) { int nPhrases; nPhrases = Private_GetTaskCompletePhraseCount(); string sPhraseIndex = IntToString(nPhrases); object oModule = GetModule(); SetLocalString(oModule, "RTG_sTaskCompletePhraseText" + sPhraseIndex, newTaskCompletePhraseData.sText); SetLocalInt(oModule, "RTG_sTaskCompletePhraseType" + sPhraseIndex, newTaskCompletePhraseData.nType); Private_SetTaskCompletePhraseCount(nPhrases + 1); } void RTG_AddTaskItemData (struct RTG_TaskItemData newTaskItemData) { int nItems; nItems = Private_GetTaskItemCount(); string sItemIndex = IntToString(nItems); object oModule = GetModule(); SetLocalString(oModule, "RTG_sTaskItemRef" + sItemIndex, newTaskItemData.sRef); SetLocalString(oModule, "RTG_sTaskItemTag" + sItemIndex, newTaskItemData.sTag); SetLocalString(oModule, "RTG_sTaskItemName" + sItemIndex, newTaskItemData.sName); SetLocalInt(oModule, "RTG_sTaskItemCR" + sItemIndex, newTaskItemData.nCR); Private_SetItemCount(nItems + 1); } void RTG_AddAntagonistData (struct RTG_TaskAntagonistData newAntagonistData) { int nAntagonists; nAntagonists = Private_GetAntagonistCount(); string sAntagonistIndex = IntToString(nAntagonists); object oModule = GetModule(); SetLocalString(oModule, "RTG_sAntagonistRef" + sAntagonistIndex, newAntagonistData.sRef); SetLocalString(oModule, "RTG_sAntagonistName" + sAntagonistIndex, newAntagonistData.sName); SetLocalInt(oModule, "RTG_sAntagonistCR" + sAntagonistIndex, newAntagonistData.nCR); SetLocalInt(oModule, "RTG_sAntagonistType" + sAntagonistIndex, newAntagonistData.nType); Private_SetAntagonistCount(nAntagonists + 1); } void RTG_AddProtagonistData (struct RTG_TaskProtagonistData newProtagonistData) { int nProtagonists; nProtagonists = Private_GetProtagonistCount(); string sProtagonistIndex = IntToString(nProtagonists); object oModule = GetModule(); SetLocalString(oModule, "RTG_sProtagonistRef" + sProtagonistIndex, newProtagonistData.sRef); SetLocalString(oModule, "RTG_sProtagonistName" + sProtagonistIndex, newProtagonistData.sName); SetLocalInt(oModule, "RTG_sProtagonistCR" + sProtagonistIndex, newProtagonistData.nCR); Private_SetProtagonistCount(nProtagonists + 1); } void RTG_AddRewardItemData (struct RTG_RewardItemData newRewardItemData) { int nRewardItems; nRewardItems = Private_GetRewardItemCount(); string sRewardItemIndex = IntToString(nRewardItems); object oModule = GetModule(); SetLocalString(oModule, "RTG_sRewardItemRef" + sRewardItemIndex, newRewardItemData.sRef); SetLocalString(oModule, "RTG_sRewardItemName" + sRewardItemIndex, newRewardItemData.sName); SetLocalInt(oModule, "RTG_sRewardItemCR" + sRewardItemIndex, newRewardItemData.nCR); SetLocalInt(oModule, "RTG_sRewardItemNum" + sRewardItemIndex, newRewardItemData.nNum); Private_SetRewardItemCount(nRewardItems + 1); } struct RTG_TaskData RTG_GetTask(int nCRMustMatch = 0, int nCRExclude = 0, int nCRMayMatch = 0, int nTaskTypeMustMatch = 0, int nTaskTypeExclude = 0, int nTaskTypeMayMatch = 0) { //int nActiveTasks = Private_GetTaskCount(); int nPhrases = Private_GetTaskPhraseCount(); int nTaskItems = Private_GetTaskItemCount(); int nAntagonists = Private_GetAntagonistCount(); int nProtagonists = Private_GetProtagonistCount(); int nRewardItems = Private_GetRewardItemCount(); DebugMessage("RTG_GetTask() nPhrases = " + IntToString(nPhrases)); DebugMessage("RTG_GetTask() nTaskItems = " + IntToString(nTaskItems)); DebugMessage("RTG_GetTask() nAntagonists = " + IntToString(nAntagonists)); DebugMessage("RTG_GetTask() nProtagonists = " + IntToString(nProtagonists)); DebugMessage("RTG_GetTask() nRewardItems = " + IntToString(nRewardItems)); int nStart, i; struct RTG_TaskData retTaskData; struct RTG_TaskPhraseData curTaskPhraseData; struct RTG_TaskItemData curTaskItemData; struct RTG_TaskAntagonistData curTaskAntagonistData; struct RTG_TaskProtagonistData curTaskProtagonistData; struct RTG_RewardItemData curRewardItemData; //////////////////////////////////////////////////////////////////////////// // Find a task item. //////////////////////////////////////////////////////////////////////////// nStart = Random(nTaskItems); //nStart = 0; for (i=nStart; i