Netruk44/uesp-wiki-content huggingface dataset:
Tes2Mod:DFRemake/Resource - RMGet3dObjectCopy

DWORD RMGetObjectCopy ( DWORD ObjectValue )

Inputs
ObjectValue: The object value (from the Arch3d directory) that you wish to create a copy of

Outputs
Returns the object ID of the newly created object.

Description
Use this function to create a new copy of the given object (object value from the Arch3d directory).

Notes
This function should never fail but will return 0 if it does. It can only fail if the NULL object does not exist (meaning an invalid object cache state).

Example
   Local NewID as DWORD
  
   NewID = RMGetObjectCopy(456)
   Position Object NewID, 10, 30, 20
Tes2Mod:DFRemake/Resource - RMInitObjects

integer RMInitObjects ( )

Inputs
None

Outputs
Returns 1 on success and 0 on failure. On failure the program should be aborted.

Description
Call this program once at startup to initialize the object resource manager.

Example
   Local Result as integer
 
   Result = RMInitObjects()
   if (not Result) then End
Tes2Mod:DFRemake/Resource - RMDestroyObjects

RMDestroyObjects ( )

Inputs
None

Outputs
None

Description
Call this program once at the end of the program to destroy the object resource manager. Do not use this function during the program execution to clear the cache (use RMClearObjectCache instead).

Example
   RMDestroyObjects()
Tes2Mod:DFRemake/Resource - RMClearObjectCache

RMClearObjectCache ( )

Inputs
None

Outputs
None

Description
Use this function to delete all objects currently in the object cache. Special objects (like the NULL object) will not be deleted.

Example
   RMClearObjectCache()
Tes2Mod:DFRemake/Resource - RMObjects

RMObjects() is a global list, user defined type rmobjects_t, that holds all cached 3d objects.


Fields
The following table lists the RMObjects() fields.
Tes2Mod:DFRemake/Resource - Dungeon

The resource manager will hold the needed information for one dungeon at a time.

Design Notes
Although in DF, a Dungeon is composed of multiple blocks, here a Dungeon is a collection of objects (and other records). Blocks are only needed during dungeon creation and it will be easier to store the objects individually.
Dungeon objects will be hidden/disabled when the player is not in the dungeon.

Objects
Objects within the dungeon include any static 3d object such as walls, rooms, furniture, etc....  Dungeon objects will be stored in one list, RMDungeonObjects() with the following fields.

DWORD ObjectID: The DarkBasic object ID.
DWORD RefObjectID: The referenced object ID (dungeon objects will be instanced). The referenced ID is stored so that it can be 
properly dereferenced once the dungeon is destroyed (for reference counting).
DWORD Flags: Various object parameters.


Flats
Flats will be stored in a separate list, RMDungeonFlats(), so they can be quickly accessed. They will use the same fields as objects.

Actions
Actions include things like switches, levers, and platforms that can move. Doors do not use action records.

DWORD ActionID: The unique value for this action.
DWORD SourceObjectID: The object that triggers this action.
DWORD TargetObjectID: This value is 0 if the action has no target object.
BYTE ActionType: Type of action to perform (translation, rotation, etc...)
DWORD Flags: Various flags depending on the action type.
float Duration: How long to perform the action (seconds).
float Delta: How much action to perform over the duration (depends on the action type).


Lights
The list of lights in the dungeon, RMDungeonLights(), with the following fields.

DWORD LightID: The DarkBasic light identifier value.
DWORD Flags: Holds various light parameters.


Exits
A list of dungeon exits, RMDungeonExits(). Although there is usually only one exit in a dungeon, we'll use a list for flexability.

ObjectID? 
Destination information (exterior location, X/Y/Z?)


Functions
RMInitDungeon : Initializes the dungeon resource manager at startup.
RMDestroyDungeon : Destroys the dungeon resource manager at program end.
RMResetDungeon : Clears the current dungeon information.
RMLoadDungeonBlock : Loads a dungeon block file and adds it to the current dungeon.
RMFindDungeonObjectID : Searches dungeon objects for the given object.
RMMakeDungeonBlockFilename : Create a dungeon block filename for loading from Blocks.bsa.
RMCreateDungeon : Creates the current dungeon (as set in DFELibrary).
RMEnableDungeon : Enables and displays the current dungeon.
RMDisableDungeon : Disables and hides the current dungeon.
Tes2Mod:DFRemake/DarkBasic Bugs

This page contains a list of possible bugs we've encountered in DarkBasic Pro. Where available, the DB version should be included as well as in which version the bug was fixed in.

IDE Crash (v5.4): Rarely crashes when trying to copy text in the IDE (only happened a few times).
DLL Parameter Mismatch (v5.4): There is some sort of parameter mismatch when calling a DLL function that takes a DWORD and returns a string. If we have the string table definition SomeFunc[%SD%SomeFunc%SomeFunc with the export definition DWORD SomeFunc(DWORD Value) then the input Value is always 0. If, however, we change the export definition to "DWORD SomeFunc(DWORD Value1, DWORD Value2) and call it in DB with Name$ = SomeFunc(123, 456) then Value1 is still 0 and Value2 is set to 123. This doesn't seem to happen with functions that return other types.
Constant Strings (v5.7): There is something wrong with constant string values, for example:
    #CONSTANT DF_GAME_PATH = "e:\dagger\"
    Result = DFESetGamePath(DF_GAME_PATH)
results in the compile-time error "Must close speech marks" (speech marks?). DFESetGamePath here is an external DLL function call.
IDE Function Completion (v5.7): A minor bug with the function help displayed in the status bar while you type in the IDE. For example, if you type "TESTLOG" the function popup will show the LOG function.
Tes2Mod:DFRemake/DarkBasic Tips

This page contains general tips to help one get the most out of DarkBasic. This includes a number of things in DB that are counter-intuitive or different from other common programming languages.

General
Using very large object IDs (10-100 million) results in a very slow execution time as well as greatly increased memory usage.


Functions
All input parameters are passed by value (no such thing as pass-by-reference).
Cannot return user defined types.
Do accept arrays as input parameters. The syntax Function TestFunc(dim array(100) as dword) does compile but you get an error if you try to access the array in the function.
Cannot return arrays.


Variable Types
UDTs cannot be returned by functions
UDTs cannot be passed into DLLs (not directly or very easily at any rate)
UDTs cannot contain arrays
Beware of mixing DWORDs with the ABS() command. For example, Value3 = ABS(Value1 - Value2) may not return what you think it should if all the values are DWORDs. 


Arrays/Lists
The time taken to add elements to lists seems to be non-linear and increases dramatically as the list grows. For example, adding 100 elements takes 0.25 ms, 1000 takes 15 ms, 10000 takes 1500 ms. Deleting elements roughly follows the same trend.
Tes2Mod:DFRemake/DarkBasic Wishlist

This page lists all the features and improvements we'd like to see added to DarkBasic.

Consistant Command Naming: For example SET LIGHT RANGE and COLOR LIGHT (why isn't it SET LIGHT COLOR?). Makes it harder to guess commands (fortunately the coloring of commands in the IDE helps).
Type Conversions: Make it easier to define implicit type conversions. For example, if I divide 2 integers and assign the value to a float, it should not truncate the factions. Currently in order to do this I have to define one or more temporary float values.
Built-In String Formatting: There needs to be some way of created nicely formatted strings from numbers, like what you can do with the C printf() function. Something like StrFormat$(Value, Width, Decimals, Flags) would do.
Compile Progress: The current compile progress bar is difficult to gauge the overall progess of the compile (assumably it goes from 0-100 for each file?). A slightly improved progress dialog including current file and overall progress would be appreciated.
Tes2Mod:TEXT.RSC format

The structure of the TEXT.RSC file is trivial.  The TEXT.RSC file is nothing more than a Text Record Database; there are no other data elements.  In brief, it consists solely of a TextRecordDatabaseHeader element, a TextRecordHeaderList element, and the remainder of the file consists of TextRecord elements.  

The file contains no other data, and the TextRecordDatabase structure begins at the file's start (Byte 0).  All records conform to the Text Record Format specification.  

Example Records

Example from TextRecord #5404:    
Here we see a TextRecord composed of a single TextSubrecord, which contains several centered lines.  


Example from TextRecord #200:    
In this example, we see several TextSubrecords in this single TextRecord, none of which have any formatting information.  When required, the game will select one at random from the list.  So, to generate a random joke (%jok), the engine loads TextRecord 200 from TEXT.RSC, then selects a TextSubrecord at random from the list, and then displays it.  As seen above, there are %ra (character's race) macros which will need to be resolved when the TextSubrecord is displayed.
Tes2Mod:DFRemake/Resource - RMGetFreeMeshID

DWORD RMGetFreeMeshID ( )

Inputs
None

Outputs
Returns the next available mesh ID. The ID is guaranteed to be valid and not currently in use.

Description
Use this function to obtain a free mesh ID used for mesh creation. 

Notes
The only way this function can fail to return a valid mesh ID is if all IDs are currently in use. Since mesh IDs range from 1000 to 1 million, this is unlikely to occur. Mesh IDs returned by this function start at 1000 leaving the lower IDs available for special purposes.

Example
   Local NewID as DWORD
 
   NewID = RMGetFreeMeshID()
   Load Mesh "somefile.x", NewID
Tes2Mod:DFRemake/Resource - RMDumpObjects

RMDumpObjects ( )

Inputs
None

Outputs
None

Description
Outputs basic information on all objects in the cache to the log file.

Example
   RMDumpObjects()
Tes2Mod:DFRemake/Resource - Storing Data

There are a few ways to store and access resources within DarkBasic.


User Defined Types
It is important to note the limitations of user defined types (UDT) within DarkBasic.
Like other types, UDTs are passed by value into functions
UDTs cannot be returned by functions
UDTs cannot be passed into DLLs (not directly or very easily at any rate)
UDTs cannot contain arrays


Lists
Lists, or dynamic arrays, are the obvious choice for storing resouce types. Given the limitations of how things can be passed to/from functions, they will need to be accessed globally (all arrays are global by default).


Performance
Although a while loop is ideal for iterating through lists, it is much slower (up to 6000 times slower) than for loops due to built-in sync/update code. For this reason one should always use for loops to iterate lists.
Simple iteration/comparison takes roughly 1 ms per 10000 elements (roughly linear).
Adding items at the bottom of the list appears to be non-linear as the number of elements in the list increases. For instance adding 100 elements takes 0.25 ms, 1000 takes 15 ms, 10000 takes 1500 ms.
There appears to be no speed difference between adding items from the top or at the bottom.
Time taken to add elements is based on their size ,especially for UDTs. For example, adding 10000 BYTEs takes 1300 ms, 10000 DWORDs takes 1500 ms, 10000 UDTs (1 field, 4 bytes total) takes 2100 ms, and 10000 UDTs (3 fields, 9 bytes total) takes 7000 ms.
When iterating in a for loop, storing the ARRAY COUNT() in a local variable is slightly faster. For example, iterating 10000 DWORDS takes 0.86 ms with a local and 1.1 ms with the function (~25% slower).
It is important to note that the ARRAY COUNT() command actually returns the last index in the list, as opposed to the number of elements. Since lists are 0-based this is a 1-record difference. Thus, in a for loop we must iterate from 0 to ARRAY COUNT() rather than 1 to ARRAY COUNT() or 0 to ARRAY COUNT()-1.
Deleting elements takes about the same time as adding elements. For example, deleting 10000 DWORDS takes 1150 ms.
Tes2Mod:DFRemake/Resource - RMDeferenceObject

RMDereferenceObject ( DWORD ObjectID )

Inputs
ObjectID: The ID of the object in the cache to dereference.

Outputs
None

Description
Decreases the reference count of the given object in the cache. 

Example
   Result = RMDereferenceObject(1009)
Tes2Mod:DFRemake/Resource - RMInitDungeon

integer RMInitDungeon ( )

Inputs
None

Outputs
Returns 1 on success, 0 on error.

Description
Initializes the dungeon resource manager. Call once at program startup. If the function returns failure the program should be aborted.

Example
   Local Result as integer
   Result = RMInitDungeon()
   if (not Result) then End
Tes2Mod:DFRemake/Resource - RMDestroyDungeon

RMDestroyDungeon ( )

Inputs
None

Outputs
None

Description
Destroys the dungeon resource manager. Should be called once at program end. Do not use this function to clear dungeon data during the game. Use RMResetDungeon instead.

Example
   RMDestroyDungeon()
Tes2Mod:DFRemake/Resource - RMResetDungeon

RMResetDungeon ( )

Inputs
None

Outputs
None

Description
Clears the current dungeon information. Is used before loading a new dungeon.

Example
   RMResetDungeon()
Tes2Mod:DFRemake/Resource - RMLoadDungeonBlock

integer RMLoadDungeonBlock ( Filename as String )

Inputs
Filename: The dungeon block RDB file to load from Blocks.bsa.

Outputs
Returns 1 on success and 0 on any error.

Description
Loads the given dungeon block and adds it to the current dungeon. 

Example
   Local Result as integer
   Result = RMLoadDungeonBlock("B0000002.rdb")
   if (not Result) then ExitFunction
Tes2Mod:DFRemake/Resource - RMFindDungeonObjectID

integer RMFindDungeonObjectID ( DWORD ObjectID )

Inputs
ObjectID: The ID of the dungeon object to find.

Outputs
Returns 1 on success and sets the current element of RMDungeonObjects() to the given object. Returns 0 on any error.

Description
Attempts to find the given object in the list of current dungeon objects.

Example
   Local Result as integer
 
   Result = RMFindDungeonObjectID(1090)
 
   if (Result)
      print "Dungeon object #1090 has original reference object #", RMDungeonObjects().RefObjectID
   endif
Tes2Mod:DFRemake/Resource - RMMakeDungeonBlockFilename

string RMMakeDungeonBlockFilename ( DWORD BlockIndex, BYTE BlockChar )

Inputs
BlockIndex: The dungeon block index (0-999).
BlockChar: The dungeon block character (N/W/L/S/B/M).

Outputs
Returns the created block filename. Returns an empty string on any error.

Description
Creates a dungeon block filename (RDB) found in the Blocks.bsa file.

Example
   Filename$ = RMMakeDungeonBlockFilename(19, 'N')
Tes2Mod:DFRemake/Resource - RMCreateDungeon

integer RMCreateDungeon (  )

Inputs
Non3

Outputs
Returns 1 on success and 0 on any error.

Description
Creates the current dungeon as set/loaded in DFELibrary. The previous dungeon information is destroyed.

Example
   Result = RMCreateDungeon()
Tes3Mod:AddTopic

AddTopic
 

Adds the given dialogue topic to the players list of known topics.  Known topics will appear when the player talks to NPCs that have that topic.  When creating a new plugin with new dialogue topics, you will frequently want to add a few topics that the player already knows.  To do this, create a temporary object near the related NPC and attach a script like the following:
Tes3Mod:AIActivate

AIActivate
 

Although this function is in the TES Construction Set help file it is never actually used in any of the official master files. It causes the referenced NPC/creature to attempt to activate the given object (such as an item, door, activator, etc...).

There is a known bug when using the optional Reset parameter with AiActivate (verified with Tribunal). It is therefore recommended to not include the reset parameter. Also, this function is mostly broken in the original Morrowind game, but has been significantly improved in Tribunal. The following actions have been tested and verified to work:

Potion - NPC drinks it (works in original Morrowind as well)
Item on Ground - NPC picks it up
Door - Opens it
Load Door - Teleports through it but only if the destination of the door is in the same cell or a currently loaded cell. Otherwise the game crashes.
Activator - NPC activates it (such as a lever/button, etc...).
Tes3Mod:Xbox

Xbox
 

Returns 1 if the game is being played on the Xbox, or 0 otherwise.
Tes3Mod:WakeUpPC

WakeUpPC
 

Wakes up the PC if they are sleeping. Use it to wake up the PC to notify them of some timed event.
Tes3Mod:UsedOnMe

UsedOnMe
 

Returns 1 if the given ObjectID is used on the calling object, or 0 otherwise. It appears that this function is currently broken. UsedOnMe is probably commented out because there's no way for an object to be used on another in the Morrowind engine.  I suspect that it was early alpha stuff.
Tes3Mod:TurnMoon

TurnMoonRed 
TurnMoonWhite
 

Turns the moon(s) the given color for special Werewolf effects (unconfirmed).
Tes3Mod:UndoWerewolf

UndoWerewolf
 

Will undo the werewolf change brought on by the BecomeWerewolf function. However, the NPC/creature will essentially be naked after the switch. They have to be told to re-equip (weapons are usually re-equipped if it occurs in combat).

Using Becomewerewolf and Undowerewolf can break your game. Some quests and variables depend solely on the use of these, so if you use one to toy around.... you may be asking for it.

See Also: BecomeWerewolf, PCWerewolf, IsWerewolf
Tes3Mod:BecomeWerewolf

BecomeWerewolf
 

Turns the player, NPC, or creature immediately into a werewolf. Only works properly for NPCs, however, it can be used on creatures for some weird effects. Affected NPCs take on the werewolf mesh, removing all clothing and weapons, and retaining all AI settings. This means an NPC turned into a werewolf may not be able to talk, but he/she will have the same Idle, Fight, and Hello, settings, etc... (though they'll just track the PC on Hello triggers, no dialogue). Likewise, already attacking NPCs will simply keep attacking, albeit in a new form - scripts seem to continue to run fine, as the object ID seems to remain the same. I'm unsure if stats on
NPCs affected by this function call are changed or not - Speed is definitely not changed, so presumably it's only attack damage and/or hit chance that changes.

This command can be used on creatures, with varying effects - the creature NIF/appearance will NOT be swapped out, nor will their 'Name' tag say 'werewolf', as it does on NPCs - and it only seems to work for certain creatures, changing their attack sound and attack stats, if I'm not mistaken. Creatures with Weapon & Shield bone entries will unequip whatever they're holding and go hand-to-hand - and as I said the attack sound changes to a werewolf growl, but otherwise Idle and other sounds seem to remain the same. It's amusing when used on Rieklings - they become little snarling, boxing, midgets.

Also, The Werewolf transformation is handled almost exactly like the Vampire one, with the PCWerewolf global being used. Using Becomewerewolf and Undowerewolf can break your game. Some quests and variables depend solely on the use of these, so if you use one to toy around.... you may be asking for it.

See Also: IsWerewolf, PCWerewolf, SetWerewolfAcrobatics, UndoWerewolf
Tes3Mod:IsWerewolf

IsWerewolf
 

Returns 1 if the player (or other NPC?) is currently in Werewolf form, or 0 otherwise.

See Also: BecomeWerewolf, UndoWerewolf
Tes3Mod:PCWerewolf

PCWerewolf
 

A global variable that gives the state of the player's werewolf status.
Tes3Mod:Unlock

Unlock
 

Unlocks the calling object.

See Also: Lock
Tes3Mod:Lock

Lock
 

Locks the calling object to the given lock value.

See Also: Unlock
Tes3Mod:SetWerewolfAcrobatics

SetWerewolfAcrobatics
 

Sets the acrobatics skill value/bonus when the player is in Werewolf form (unconfirmed).
Tes3Mod:While

while 
endwhile
 
		while ( LeftValue CompareOp RightValue )
			 
		endwhile

       Where:   LeftValue  = Local/global variable or function call
		CompareOp  = ==,  , >=, !=
		RightValue = Local/global variable or numeric literal value
		Statements = Zero or more statements to execute

	Type:	System

     Returns:	none

     Example:	while ( GetStrength  

The while is the only loop statement available in the scripting language.  The while loop is executed within one frame until the condition is satisfied. This can cause an unwanted pause in the game if there are many loops required.
Tes3Mod:TestCellsModels

TestCells 
TestInteriorCells 
TestModels (T3D) 
TestThreadCells
 

Presumably this console command tests various objects/locations in the game in some manner.

See Also: StopCellTest
Tes3Mod:StopCellTest

StopCellTest (SCT)
 

Presumably this console command stops a cell test previously started by the TestCells console command.

See Also: TestCells
Tes3Mod:AddToLev

AddToLevCreature 
AddToLevItem
 

Allows the user to modify the levelled item/creature lists while the game is running.  The functions will add the object/level pair to the levelled list (assuming that it doesn't already exist in the list).

See Also: RemoveFromLevCreature, RemoveFromLevItem
Tes3Mod:RemoveFromLev

RemoveFromLevCreature 
RemoveFromLevItem
 

Allows the user to modify the leveled item/creature lists while the game is running.  The functions will remove the given object/level pair to the leveled list (assuming that it exists in the list).

See Also: AddToLevCreature, AddToLevItem
Tes3Mod:AIFollow

AIFollow 
AIFollowCell
 

Similar to AIFollow where the source NPC will be set to follow the target NPC (ActorID) for the given duration (in hours, 0 indicates infinite time) or until they reach the given position (AIFollow for exterior locations, AIFollowCell for interior locations). When an NPC uses AIFollow, the player gets to choose where he/she goes. The NPC will follow the player diligently the whole way. 

As with other AI functions, issue this command only once or the results may not be as expected.

See Also: AIEscort, GetAIPackageDone, GetCurrentAIPackage
Tes3Mod:GetAIPackageDone

GetAIPackageDone
 

Returns 1 for one frame when the NPC's AI package has completed (usually returns 0).  Use this to determine when an NPC has arrived at their location when using the AITravel function.

See Also: AIEscort, AIFollow, AITravel, AIWander, GetCurrentAIPackage
Tes3Mod:GetCurrentAIPackage

GetCurrentAIPackage
 

Returns a short value based on the current AIPackage the NPC is performing.

See Also: AIEscort, AIFollow, AITravel, AIWander, GetAIPackageDone