Skrit & Code


Wednesday, June 15, 2005 - 17:55

DSMod

Q: Can you force Reload Templates and Skrit in-game?
A: You can make changes to skrits, components, and templates and type either "reload gos" (which will reload global objects only) or "reload contentdb" (which will reload the entire contentdb including skrits).

Also, if you add 'skrit_retry=true' to your command line parameters you will be prompted to "swing again" if your skrit generates errors on startup. This way you can make the changes to the one skrit then try it again to see if it still generates errors without exiting out of the game.

Skrit

Q: How Can You Find a Specific Goid in a Characters Inventory by Template Name?
A: GetItemFromTemplate will retrieve the go of the first specified template name found in an actors inventory:

template_go$ = actor_go$.Inventory.GetItemFromTemplate(Template_Name$);

Q: What are scid bits?
A:

Format
GetScidBits ( Scid scid, DWORD defValue )

Arguments
Scid: scid to get the bits for defvalue: Default value to return if the object has no bits associated with it.

Description
GetScidBit is great for getting a boolean value from the bit field, but some times it is useful to store information other then boolean values for an object. If we want to store an integer value then getting the number a bit at a time is difficult.

Generators for example can have a number of actors that they should spawn. We can pack the number of actors remaining to be spawned in the ScidBits value. When a generator leaves the world then is reloaded we can get the entire ScidBits field and extract out our int value from it. Generator_advanced_a2 for instance uses this key:

ScidBits Key
------------
lower 16 bits, number remaining creatures to spawn
17th bit = modified
18th bit = active

Q: What world event types are supported?
A:
WE_CONSTRUCTED
This should get sent to any GO right after it's been constructed and as the last thing in the init/load procedure.
WE_DESTRUCTED
This should be sent to any GO right before it's deleted.
WE_JOB_DESTRUCTED
Sent just to job when it's being deleted during normal gameplay. We_destructed is sent to job on gomind shutdown.
WE_ENTERED_WORLD
Object entered the world frustum.
WE_LEFT_WORLD
Object left the world frustum.
WE_FRUSTUM_MEMBERSHIP_CHANGED
When frustum membership of the go changes the data1 contains OLD membership.
WE_FRUSTUM_ACTIVE_STATE_CHANGED
When the active frustums mask changes, this is broadcast. Data1 contains the OLD mask.
WE_UPGRADED
Object has been upgraded by siege (visible for screen player).
WE_DOWNGRADED
Object has been downgraded by siege (visible for screen player).
WE_EXPIRED_AUTO
Object has automatically expired outside of world frustum and will be deleted next.
WE_EXPIRED_FORCED
Object has been force-expired and will be deleted next.
WE_PRE_SAVE_GAME
Called right before the game is saved.
WE_POST_SAVE_GAME
Called right after the game is saved.
WE_POST_RESTORE_GAME
Called right after the game is restored.
WE_TERRAIN_TRANSITION_DONE
Notify object that it's task is complete.
WE_WORLD_STATE_TRANSITION_DONE
State change that was requested is done.
WE_CAMERA_COMMAND_DONE
Notify object that camera command is done.
WE_PLAYER_CHANGED
Called right after player reassignment. Old player* is stored in data1.
WE_PLAYER_DATA_CHANGED
Broadcast when any stats on a Player change.
WE_SCIDBITS_CHANGED
Sent to an object when its scidbits change.
WE_MP_MACHINE_CONNECTED
When a machine connects to our box.
WE_MP_MACHINE_DISCONNECTED
When a machine disconnects from our box.
WE_MP_FAILED_CONNECT
When this machine attemps to connect to a remote session bug has been banned.
WE_MP_SESSION_CHANGED
A session has been enumerated or changed, index in data1.
WE_MP_SESSION_TERMINATED
Session removed from the enumeration, index in data1.
WE_MP_SESSION_ADDED
Session added to the enumeration, index in data1.
WE_MP_SESSION_CONNECTED
Sent after netpipe finished the host or connect procedure.
WE_MP_PLAYER_CREATED
Sent whenever a player object is created on local machine.
WE_MP_PLAYER_DESTROYED
Sent whenever a player object is destroyed on local machine.
WE_MP_PLAYER_READY
Player is now ready, playerid in data1.
WE_MP_PLAYER_NOT_READY
Player no longer ready, playerid in data1.
WE_MP_PLAYER_WORLD_STATE_CHANGED
Whenever the player object's world state changes, this gets broadcast.
WE_MP_PLAYER_SET_CHARACTER_LEVEL
Whenever the player's character level is updated.
WE_MP_SET_MAP
Sent when the server selects a map
WE_MP_SET_MAP_WORLD
Sent when the server selects a map world.
WE_MP_SET_GAME_TYPE
Sent when the server selects a game type.
WE_MP_TERRAIN_FULLY_LOADED
When no new siege nodes have been loaded this sim... only sent in JIP mode.

Q: What is a SkritBot?
A: The skritbot commands are not available in retail, only with DSMod. Skritbots are skrits that sit in a special place and can manage the game from a high level. They do receive time and can be used to do automated testing. In fact you'll see some of the skritbots we made in the "auto" directory off the root of logic.dsres. For example mp.skrit is one I made to automate setting up a multiplayer game for testing. Not that it works with your version of DSR (where we disabled multiplayer) but it is illustrative of what skritbots can do.

To use a skritbot on the command line it's easy. Just use:

skritbot=name_of_skrit?param1=value1¶m2=value2 etc.

on the command line when you launch the game. For example I would launch the bot on the host as:

skritbot=auto/mp?players=1

and on the client as:

skritbot=auto/mp?host=sbilas-2

You may find skritbots useful in a number of ways. If you look in the auto/test folder you'll find all the bots created by our unit testers to automate things like spell tests and pcontent generation. I suggest taking a look.

Important: skritbot is not available in retail (for security reasons) so you cannot use it in your mods. It is purely meant for automated testing and debugging support.

Q: How do I make complex NPC conversations in Dungeon Siege?
A: Please refer to the following Siege Univerity tutorials:

Getting Started

Q: What Engine Function Prefixes are available and what do they mean?
RC - Request on a specific client.
RS - Request to server and relay to clients.
S - Request on server only and do not relay to clients.

Q: How do I get started templating?
A: The easiest way to learn how to create templates is to copy what is already there. Find a template simular to what you want, copy it, and try modifying it to do what you want.

In addition Siege U 201 and Siege U 302 should help give you a solid understanding of how templates work in general.

Custom UI

Q: What is Notify and How Can I use it to Create Custom UI?
A: Notify is just an interface into the game that does a block of work according to the string you pass in (the notify string gets passed into an event handler that's hard-coded). So those events are handled internally and follow no particular naming convention or standard. You should use skrit to create your own events because notify is just for internal usage (though you are welcome to use a notify call if it does what you need it to do).

Q: How do I tile a texture in a UIWindow?
A: Textures can be tiled by setting wrap_mode to tiled and adjusting the uvcoords to display the desired number of tiles. If you want two tiles of the
entire texture across and two down, just set uvcoords to 0,0,2,2. uvcoords are floating point numbers, which comes in handy when you want to make sure a
texture isn't stretched to fill an area. Here's an example that fills an 800x600 screen with a 64x64 pixel texture without stretching the texture:

[t:window,n:test_layout_grid]
{
   
alpha = 0.25; common_control = false;
   
draw_order = 1;
   
pass_through = true;
   
texture = b_gui_ig_mnu_elem_grid_sm;
   
rect = 0,0, 800, 600;
   
uvcoords = 0.0, 0.0,12.5,9.375;
   
wrap_mode = tiled;
}

DSDLL's

Q: Can you override Dungeon Siege functions with DSDLL's?
A: Yes, mostly! FuBi is built in such a way that it doesn't care where its functions come from, and when it finds duplicate functions it will just ignore the second version. So to override game functions, you just need to make sure that your functions are scanned before the game imports its own functions. Dungeon Siege supports this directly if you rename the DLL's extension to .dsdl0 (that's a zero at the end). The system scans functions in this order: .dsdl0 files alphabetically, DungeonSiege.exe, then .dsdll files alphabetically.

Important: the signatures for your override functions must be identical to the functions they're trying to override, otherwise they will either get ignored, or you'll get a crash.

Unlike normal .dsdll exports, a .dsdl0 that overrides game functions can have crazy unexpected behavior. Your overrides will be called for skrit and incoming RPC's, but not for in-game C++ code (those will still call the old versions). If messing with .dsdll's is considered deep modding, then using .dsdl0 overrides is extreme level 150 burrowing-to-the-Earth's-core modding. So use them with extreme caution, or you may shoot your eye out!

Q: Why don't my dsdll's work after the 1.11.1 DSMod Patch?
A: Simply rename your dsdll's to ds2dll and they should work again.