Sign post teleportation
This is a short "problem-solving" example, where we try to demonstrate the power of Daedalus injection using zParserExtender. GaroK asked me if there is a way to teleport to all the sign posts in Khorinis to gather information for a Gothic wiki article.
The goal is to introduce a function that will teleport you to every signpost in Khorinis with the press of a button.
The problem
In ZenGin you can teleport to named game objects with the goto vob {vobname}
command. But since the signposts do not have a vobname defined, I had to figure out a different approach.
ASCII ZEN
We want to get all the signposts position from Khorinis. The game world was loaded into one of the available world editor, I found one of the signposts and noted the visual
which dictates the model of the in-game object nw_misc_sign_01.3DS
. Alternatively, you can find the standard vanilla objects from both games on this website.
Next, the world was saved as a ASCII ZEN
format. This allows us to write a macro to search for all instances of objects with a specific visual and extract the position vector.
Tip
You can also see that the focusName
has a MOBNAME_INCITY02
string constant.
This constant is defined in the scripts and its content is used as the focus name.
The injectable script
As it is an injectable script, we have to specify the META
tag.
Lets tell zParserExtender to insert this code into the game parser.
C_Position
and C_Vob_Data
classes. const int NUM_OF_SIGNS = 54
and a const int MAX_COORDS = 3 * NUM_OF_SIGNS
- we will store 3 times 54 integers - for every signpost a x
, y
and z
coordinate. And lastly a const int
array containing all the positions. GameLoop
function, to check for a pressed key. If the key U
is pressed, the jump_to_sign
function is called. Let's look at the jump_to_sign
function now.
This function is called on every U
key press and goes through all the signposts and teleports the player to them.
At the start of the function we check if the index is not out of bounds and if it is, sets it back to 0 and starts over.
Str_Format
function for the formatted output. Firstly we get the game parser ID. Then we can use the
Par_GetSymbolValueIntArray
to access the sign_coordinates
array and assign the coordinates to the pos
variable. C_Vob_Data
helper class, get players data, and disable both the static a dynamic collision. First we create a backup of the values just so we can restore them back after the teleport.