Netruk44/uesp-wiki-content huggingface dataset:
Tes3Mod:GameHour

GameHour
 

Returns the current hour of the day in the game's time. The value is a floating point value that will be increased slightly on each frame. Game hour can be modified using the SET command to change the game time.

My favorite usage is on an item I created -- the Ring of Eternal Midnight -- which causes the GameHour to be set to 0.001 constantly once the day changes -- thus, once it becomes midnight, the ring will keep the game frozen at midnight until you remove it. When you do remove it, time will advance normally (even if you put the ring on again) until midnight is again reached.

Another good usage of setting GameHour directly is to make time pass. 'set GameHour to GameHour + 0.5' makes time advance a half-hour instantaneously. It correctly identifies new days, but I haven't yet tested whether or not it also correctly identifies time passed beyond a new day -- that is, if it is currently 11:59 PM, whether or not adding a half hour will make it 12:29 AM or simply 12:00 AM.
Tes3Mod:DaysPassed

DaysPassed
 

Global short variable which returns the total number of game days since the start of the game.

See Also: Day, GameHour, Month, Year
Tes3Mod:AddSoulGem

AddSoulGem
 

Adds a filled soulgem to the calling object's inventory using the given creature and soulgem types.

See Also: DropSoulGem
Tes3Mod:DropSoulGem

DropSoulGem
 

Presumably causes the calling object to drop a filled soulgem with the given creature's soul. Presumably the type of soulgem is calculated automatically from the value of the creature's soul.

See Also: AddSoulGem
Tes2Mod:DFRemake

This is the home page containing various design documents for the DarkBasic remake of Daggerfall. See the Project Home Page for more information.

General Design
Roadmap
Gameplay Changes
Definitions


DFELibrary
3d Objects
BSA Files

Resource Manager
Storing Data
Images
3d Objects
Dungeon
Regions

World Creation
Coordinate System
Dungeon Building
Exterior Water
Fractal Roads
Items

DarkBasic
Bugs
Tips
Wishlist
Issues
Tes2Mod:DFRemake/DFELibrary - BSA Files

General BSA
Arch3d.bsa
Blocks.bsa
Maps.bsa
Tes2Mod:DFRemake/DFELibrary - General BSA

General Design Notes
There are a number of BSA files used in Daggerfall that all have the same basic structure, though containing different data. These include:
Arch3d.bsa: 3d objects
Blocks.bsa: Block information (tells how objects are combined into larger block structures)
Maps.bsa: Overall town/dungeon maps (tells how blocks are combined to make a single location)
Dagger.snd: Sound data (is a BSA even though the extension is different)

Exported Functions
There are no general BSA exported functions in the library.


Error Codes

The following table lists the general BSA error codes:
Tes2Mod:DFRemake/DFELibrary - Arch3d.bsa

Arch3d.bsa contains 10251 3d object files which are used to build dungeon/location blocks.


General Design Notes
The arch3d file directory will be loaded the first time a 3d object is requested.
One 3d object will be loaded at a time.
Objects will be accessed/loaded by their directory value (DWORD).


Error Codes
The following table lists the Arch3d.bsa related error codes:




Functions
DFELoad3dObject : Main function to load a 3d object.
DFEHas3dObject : Checks for a currently loaded 3d object
DFEGetFirst3dObject : Start iterating through all objects in arch3d.bsa.
DFEGetNext3dObject : Continue iterating through all objects in arch3d.bsa.
DFEGet3dObjectSize : Get the memblock size in bytes for object conversion.
DFEGetFirst3dTexture : Start iterating through all textures in the current 3d object.
DFEGetNext3dTexture : Continue iterating through all textures in the current 3d object.
DFEGet3dObjectMesh : Convert the current 3d object into a single DB mesh (no textures).
DFEGetFirst3dMemblock : Start converting faces with the same texture to DB objects.
DFEGetNext3dMemblock : Continue converting faces with the same texture to DB objects.
Tes2Mod:File Formats

: 
:: 
: 
 
: 
: 
: 
: 
 
: 
:: 
: 
:: 
:: 
:: 
: 
:: 
:: 
:: 
 
 
: 
: 
 
 
 
: 
 
: 
 
 
:
Tes3Mod:AddSpell

AddSpell
 

This function adds the given spell to the calling object.  If the spell is a normal spell, it will be added to the list of the actor's known spells.  If the spell is a curse/disease it will be added to the list of spells currently affecting the calling actor.  Use RemoveSpell to remove spells added by AddSpell.

A bug related to this function is that if you add a curse type spell to a creature, then any other creature of that type you encounter from that point on will also be affected by that curse. To fix this simply call RemoveSpell in an OnDeath clause in a script attached to the creature. The fact that this happens in the first place suggests that the spell is added to the creature definition, and not just that particular instance of the creature.

See Also: RemoveSpell
Tes2Mod:DFRemake/DFELibrary - 3d Objects

See Arch3d.bsa for more information.

Error Codes
The following are the 3d object specific error codes. Note that these errors may be superceded by the Arch3d error DFERR_BAD3DOBJECT.
Tes3Mod:RemoveSpell

RemoveSpell
 

Removes the spell from the calling actors known spell list or affecting spells.  If the spell is a normal spell, it is removed from the actor's list of known spells.  If the spell is a curse/disease it is removed from the list of spells currently affecting the actor.

A bug vaguely related to this function is that if a creature dies with a curse type spell on it, then any other creature of that type you encounter from that point on will also be affected by that curse. To fix this simply call RemoveSpell in an OnDeath clause in a script attached to the creature. The fact that this happens in the first place suggests that the spell is added to the creature definition, and not just that particular instance of the creature.

See Also: RemoveEffects, RemoveSpellEffects
Tes3Mod:RemoveSpellEffects

RemoveSpellEffects
 

Removes the spell from the calling actors list of affecting spells.

See Also: RemoveEffects, RemoveSpell
Tes2Mod:DFRemake/Coordinate System

Daggerfall Coordinates ==
+X is 'East' (towards the right on the overhead map)
+Z is 'North' (towards the top of the overhead map)
-Y is up
Overall system is right-handed


DarkBasic Coordinates
Overall system is left-handed


Game Coordinates
Since we must use the left-handed system in DarkBasic, we must convert the DF coordinates slightly:
DB.X = DF.X (Same, +X is East)
DB.Y = DF.Z (+Y is North)
DB.Z = -DF.Y (Same, +Z is Up)
Tes3Mod:RemoveEffects

RemoveEffects
 

Removes all spells currently affecting the calling actor that include the given effect. Note that this is slightly different from the GetEffect function which accepts the sEffect___ ID rather than the numeric value.

See Also: GetEffect, RemoveSpell, RemoveSpellEffects
Tes2Mod:DFRemake/DFELoad3dObject

integer DFELoad3dObject (DWORD ObjectValue)

Inputs
ObjectValue - The object value from the Arch3d.Bsa directory that you wish to load.


Outputs
Returns the error code from the operation, or DFERR_SUCCESS on success.


Description
Attempts to load the given object from the arch3d.bsa file. The BSA directory is read if it has not yet been input. On success the current 3d object will be the given object.


Notes


Example
 Local ErrResult as integer
 ErrResult = DFELoad3dObject(456)
 if (ErrResult <> DFERR_SUCCESS) then End
Tes2Mod:DFRemake/DFEHas3dObject

integer DFEHas3dObject ( )

Inputs
None

Outputs
Returns 1 if there is a valid current 3d object file loaded, and 0 otherwise.

Description
Use this function to check if there a current 3d object file loaded.

Example
 if ( DFEHas3dObject() ) 
    `Do stuff
 endif
Tes2Mod:DFRemake/DFEGetFirst3dObject

integer DFEGetFirst3dObject ( )

Inputs
None

Outputs
Returns 1 on success and 0 if there are no objects to iterate through.

Description
Use this function to start iterating through all 3d objects in the arch3d.bas file. The Bsa directory is read if it has not yet been input. See DFEGetNext3dObject for more information.

Example
 Local ErrResult as integer
 ErrResult = DFEGetFirst3dObject()
Tes2Mod:DFRemake/DFEGetNext3dObject

integer DFEGetNext3dObject ( )

Inputs
None

Outputs
Returns 1 on success and 0 if there are no objects left to iterate through.

Description
Use this function to continue iterating through all 3d objects in the arch3d.bas file after an initial call to DFEGetFirst3dObject.

Example
 Local ErrResult as integer
 Local Count     as DWORD
 
 ErrResult = DFEGetFirst3dObject()
 Count = 0
 
 while ( ErrResult )
    inc Count
    print "Found object #", Count
    ErrResult = DFEGetNext3dObject() 
 endwhile
Tes2Mod:DFRemake/DFEGet3dObjectSize

DWORD DFEGet3dObjectSize ( )

Inputs
None

Outputs
Returns the size in bytes needed for the memblock to store the current 3d object.

Description
Use this function to get the size needed for a memblock allocation in order to convert the currently loaded object into a DarkBasic object (FVF format 338 currently). Returns 0 if there is no current object loaded.

Example
  Size = DFEGet3dObjectSize()
  
  if ( Size > 0 )
    make memblock 1, Size
  endif
Tes2Mod:DFRemake/DFEGetFirst3dTexture

integer DFEGetFirst3dTexture ( )

Inputs
None

Outputs
Returns -1 if there are no textures to iterate through in the current object. On success it returns the combined texture and image index (see DFEGetNext3dTexture for details).

Description
Use this function to begin iterating through all different textures in the currently loaded 3d object.

Example
 Local TexValue as integer
 
 TexValue = DFEGetFirst3dTexture()
 if (TexValue = -1) then End
Tes2Mod:DFRemake/DFEGetNext3dTexture

integer DFEGetNext3dTexture ( )

Inputs
None

Outputs
Returns -1 if there are no textures left to iterate through in the current object. On success the combined texture and image indices are returned in the format:
     Bytes 0-1: ImageIndex
     Bytes 2-3: TextureIndex

Description
Use this function to continue iterating through all textures in the current 3d object file after an initial call to DFEGetFirst3dTexture. These functions can be used to pre-load the textures used in a DF object.

Notes
These two functions are used since it is impossible/difficult to construct a single object using multiple diffuse textures in DarkBasic. To get around this, 3d objects in DB are constructed using a base object for the first texture, and then limbs for each additional texture used in the object. This lets the model be handled as a single object but easily allow multiple textures.

Example
 Local TexValue   as integer
 Local TexIndex   as DWORD
 Local ImageIndex as DWORD
 
 TexValue = DFEGetFirst3dTexture()
 
 while ( TexValue <> -1)
    TexIndex   = TexValue >> 16
    ImageIndex = TexValue && 65535
  
    print "Object uses texture ", TexIndex, " image ", ImageIndex
    TexValue = DFEGetNext3dTexture()
 endwhile
Tes2Mod:DFRemake/DFEGet3dObjectMesh

integer DFEGet3dObjectMesh ( DWORD MemblockPtr )

Inputs
MemblockPtr: The pointer to the memblock from the GET MEMBLOCK PTR command.

Outputs
Returns DFERR_SUCCESS on success and the appropriate error code on failure.

Description
This function creates a memblock object from the currently loaded DF 3d object. Use DFEGet3dObjectSize  to allocate a memblock of the required size.

Notes
This function does not create objects with textures but it can be used for wireframe model testing. It is much simpler than the other functions for object creation which require multiple calls and limb assembly.

Example
 Local ErrResult as integer
 
 make memblock 1, DFEGet3dObjectSize()
 ErrResult = DFEGet3dObjectMesh(get memblock ptr(1))
 if (ErrResult <> DFERR_SUCCESS) then End
Tes2Mod:DFRemake/DFEGetNext3dMemblock

integer DFEGetNext3dMemblock ( DWORD MemblockPtr )

Inputs
MemblockPtr: The pointer to a memblock from the GET MEMBLOCK PTR command.

Outputs
Returns -1 if there are no objects left to iterate through. On success the result is a combination of the texture and image indices:
     Bytes 0-1: ImageIndex
     Bytes 2-3: TextureIndex

Description
Use this function to continue iterating through all faces with the same texture in the current 3d object after an initial call to DFEGetFirst3dMemblock. On success, the given memblock will contain object data for all faces with the same texture image. Memblocks should be allocated with the DFEGet3dSize() function (which will over-allocate which is fine).

Example
   Local ErrResult  as integer
   Local Size       as DWORD
   Local MemblockID as DWORD
   Local MeshID     as DWORD
   Local LimbIndex  as DWORD
   Local Index      as DWORD
   
   Size = DFEGet3dObjectSize()
   make memblock 1, Size
   
   TexValue   = DFEGetFirst3dMemblock(get memblock ptr(1))
   TexIndex   = TexValue >> 16
   ImageIndex = TexValue && 65535
   
   make mesh from memblock 2, 1
   make object 3, 2, 0
   delete mesh 2
   LimbIndex = 1
   
         `Add all limbs with alternate textures
   for Index = 0 to 1024
      TexValue = DFEGetNext3dMemblock(get memblock ptr(1))
      if (TexValue  > 16
      ImageIndex = TexValue && 65535
      print "Texture Limb: " + str$(TexIndex) + ", " + str$(ImageIndex)
   
      make mesh from memblock 2, 1
      add limb 3, LimbIndex, 2
   
      delete mesh 2
      Inc LimbIndex
   next Index
   
    delete memblock 1
Tes2Mod:DFRemake/DFEGetFirst3dMemblock

integer DFEGetFirst3dMemblock ( DWORD MemblockPtr )

Inputs
MemblockPtr: The pointer to a memblock from the GET MEMBLOCK PTR command.

Outputs
Returns -1 if there are no objects to iterate through. On success the result is a combination of the texture and image indices:
     Bytes 0-1: ImageIndex
     Bytes 2-3: TextureIndex

Description
Use this function to start iterating through all faces with the same texture in the current 3d object. On success, the given memblock will contain object data for all faces with the same texture image. Memblocks should be allocated with the DFEGet3dSize() function (which will over-allocate which is fine). See DFEGetNext3dMemblock for more information.

Example
   Local ErrResult  as integer
   Local Size       as DWORD
   local TexValue   as integer
   Local TexIndex   as DWORD
   Local ImageIndex as DWORD
   
   Size = DFEGet3dObjectSize()
   make memblock 1, Size
   
   TexValue   = DFEGetFirst3dMemblock(get memblock ptr(1))
   if (TexValue = 1) then End
   TexIndex   = TexValue >> 16
   ImageIndex = TexValue && 65535
Tes2Mod:DFRemake/DFELibrary - Maps.bsa

Maps.bsa contains information to build complete locations (towns, dungeons, interior houses, etc...) from the component blocks.


General Design
The location table (MapTable, MapNames) will be loaded and stored for all regions. This requires 40 bytes per location (slightly less if allocated strings are used) which requires ~500kB for the ~11,000 exterior locations. If memory is a concern this can be reduced to ~8 bytes per record (100 kb total) if the location name is not stored. Alternatively, the records can be loaded from the file as needed (the data is in fixed array format for each region so access time is relatively fast).
The full record data (MapDItem, MapPItem) will be loaded for a region at a time as needed.
Regions will be accessed by number, 0-60.
Information will be transferred to DB by custom formatted memblocks.


Error Codes
The following table lists the Maps.Bsa related error codes:




Exported Functions
DFEIsValidRegion : Checks if a given region index is valid.
DFEGetRegionName : Returns a region name from its index.
DFEGetFirstRegionLocation : Starts interating through exterior locations in a region.
DFEGetNextRegionLocation : Continues interating through exterior locations in a region.
DFEGetFirstRegionDungeon : Starts interating through dungeons in a region.
DFEGetNextRegionDungeon : Continues interating through dungeons in a region.
DFELoadRegion : Loads the location (MapPItem) and dungeon (MapDItem) data for the given region.
DFEGetFirstDungeonBlock : Start iterating through block data in the currently selected dungeon.
DFEGetNextDungeonBlock : Continue iterating through block data in the currently selected dungeon.
Tes2Mod:DFRemake/DFELibrary - Blocks.bsa

Blocks.bsa contains information on building dungeon and location blocks from the component 3d objects. Within the Bsa file there are several differet file formats:
RDB: Hold dungeon block data (Random Dungeon Block?)
RMB: Hold location block data (towns, etc...) (Random Map Block?)
RDI: Related to dungeons (Random Dungeon Information?) but currently unknown.


General Design
The Blocks.bsa directory will be read the first time it is needed (when a RDB/RMB file is loaded or at the start of an iteration request).
One RDB/RMB file will be loaded at a time.
RDB/RMB files will be accessed/loaded according to their filename (8.3 format).
Information will be passed onto DarkBasic using memblocks with user defined structures (will required manual extraction in DB).
Object angles in dungeon blocks can be converted to degrees by multiplying by 540/1024. This results in some angles that are very large but (>360) it seems to work fine.


Error Codes
The following table lists the Blocks.bsa related error codes:




Functions
DFELoadDungeonBlock : Load a dungeon block (RDB) according to its filename.
DFEGetFirstDungeonObject : Start iterating through pieces in the current dungeon block.
DFEGetNextDungeonObject : Continue iterating through pieces in the current dungeon block.
Tes2Mod:DFRemake/DFELoadDungeonBlock

integer DFELoadDungeonBlock ( LPSTR Filename )

Inputs
Filename: The RDB file to load, ex: "N0000019.RDB". Not case sensitive.

Outputs
Returns DFERR_SUCCESS on success or the error code on any error.

Description
Attempt to load a RDB dungeon block from the blocks.bsa file.

Example
   Local ErrResult as integer
  
   ErrResult = DFELoadDungeonBlock("N0000019.RDB")
   if (ErrResult <> DFERR_SUCCESS) then End
Tes2Mod:DFRemake/DFEGetFirstDungeonObject

integer DFEGetFirstDungeonObject ( DWORD MemblockPtr )

Inputs
MemblockPtr: The pointer to a memblock from the GET MEMBLOCK PTR command.

Outputs
Returns 0 if there are no objects in the current block to iterate through or 1 on success.

Description
Begins iterating through all objects in the current dungeon block, storing information in the given memblock. Memblocks should be allocated with 256 bytes. See DFEGetNextDungeonObject for more information including the format of memblock data.

Example
   Local Result as Integer
 
   make memblock 1, 256
   Result = DFEGetFirstDungeonObject(get memblock ptr(1))
Tes2Mod:DFRemake/DFEGetNextDungeonObject

integer DFEGetNextDungeonObject ( DWORD MemblockPtr )

Inputs
MemblockPtr: The pointer to a memblock from the GET MEMBLOCK PTR command.

Outputs
Returns 0 if there are no objects left in the current block to iterate through or 1 on success.

Description
Continues iterating through objects in the current dungeon block, storing information in the given memblock, after an initial call to DFEGetFirstDungeonObject. Memblocks should be allocated with 256 bytes. The memblock structure is as follows:
        DWORD  ObjectValue;    /* The object used (from arch3d.bsa) */
        float  XPos;           /* Position of object in block */
        float  YPos;
        float  ZPos;
        float  XAngle;         /* Angle of object in block */
        float  YAngle;
        float  ZAngle;
        DWORD  GridX;          /* Dungeon grid, most likely not needed */
        DWORD  GridY;
The format will likely be extended as fields as needed.

Example
   Local Result as Integer
   Local Object as DWORD
   Local XPos   as float
   Local YPos   as float
   Local ZPos   as float
 
   make memblock 1, 256
   Result = DFEGetFirstDungeonObject(get memblock ptr(1))
 
   while ( Result )
      Object = memblock dword(1,  0)
      XPos   = memblock float(1,  4)
      YPos   = memblock float(1,  8)
      ZPos   = memblock float(1, 12)
      Print "Dungeon block as object #", ObjectValue, " at position: ", XPos, ", ", YPos, ", ", ZPos
 
      Result = DFEGetNextDungeonObject(get memblock ptr(1))
   endwhile
 
   delete memblock 1
Tes2Mod:DFRemake/Resource - Objects

This page describes the part of the Resource Manager dedicated to loading and caching 3d objects (arch3d.bsa).


General Design


RMObjects() List
RMObjects() is a global list containing all the currently cached objects. The list should only be accessed read only for object info (don't manually write data in the list unless you are familiar with things). Use the available functions for adding/removing objects from the cache.


Public Functions 
The following are the publically available object resource manager functions can be used. 

RMInitObjects : Initializes the object part of the resource manager.
RMDestroyObjects : Destroys the object part of the resource manager.
RMClearObjectCache : Deletes all regular objects currently in the cache.
RMGetFreeObjectID : Returns the next available object ID.
RMGetFreeMeshID : Returns the next available mesh ID.
RMGet3dObject : Access/load an object record.
RMGet3dObjectInstance : Create an instance of the given object.
RMGet3dObjectCopy : Create a new copy of the given object.
RMDumpObjects : Outputs info about all objects in the cache to the log file.
RMDereferenceObject : Decreases the reference count of the given object.
Tes2Mod:DFRemake/Resource - RMGetFreeObjectID

DWORD RMGetFreeObjectID ( )

Inputs
None

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

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

Notes
The only way this function can fail to return a valid object ID is if all IDs are currently in use. Since object IDs range from 1000 to 1 million, this is unlikely to occur. Object IDs returned by this function start at 1000 leaving the lower IDs available for special purposes. IDs are limited to 1 million since large object IDs seem to require too much memory and slow down the system.

Typical access time for this function is < 0.004 ms for the first 999,000 objects created.

Example
   Local NewID as DWORD
 
   NewID = RMGetFreeObjectID()
   make object box NewID, 10, 10, 10
Tes2Mod:DFRemake/Resource - RMGet3dObject

integer RMGetObject ( DWORD ObjectValue )

Inputs
ObjectValue: The object value (from the Arch3d directory) that you wish to load/access.

Outputs
Returns 1 on success and the global RMObjects() list is set to the given object. On failure 0 is returned and the RMObjects() list is set to the NULL object.

Description
This function accesses, or loads, the specified object, setting the RMObjects() list to the given object. If the object currently exists in the cache, it is merely accessed. If it doesn't exist, the object is loaded and added to the cache. If the object cannot be loaded the RMObjects() list is set to the NULL object to ensure a valid object is available.

New objects are hidden and moved far from the origin (negative direction). The intent is to never use the copy of the object in the cache, but instead to make instances and copies of the object and place them into the world as needed.

Notes
Need rough access times...

Example
   Local Result as integer
 
   Result = RMGetObject(456)
   if (not Result) then End
 
   print "Object 456 found using ID #", RMObjects().ObjectID
Tes2Mod:DFRemake/Resource - RMGet3dObjectInstance

DWORD RMGetObjectInstance ( DWORD ObjectValue )

Inputs
ObjectValue: The object value (from the Arch3d directory) that you wish to create an instance of.

Outputs
Returns the object ID of the newly created object instance.

Description
Use this function to create an instance of the given object (object value from the Arch3d directory). An instanced object shares much of its data with the original object but can be moved, rotated, and animated seperately.

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 = RMGetObjectInstance(456)
   Position Object NewID, 10, 30, 20