211
Turok 2 Seeds of Evil Modding/Mapping / Re: Scripting Guide
« on: April 04, 2017, 04:45:19 PM »
After you unzip the "game.kpf" file use this to view and copy files to your Turok 2 directory. In your Turok 2 directory create a "scripts" folder and a "defs/actors" folder.
If we wanted to display the damage done to an enemy on the screen, the first thing we need to do is create a script for enemies.
So first create a new file and call it "Enemy.txt" and place it in the scripts folder. Edit the file and create a class named Enemy and add the OnDamage callback function like so:
Now we just have to hook this script up to all the enemies in the game, but for testing let's just hook it up to the Raptoid enemy.
All the definitions of everything in the game is in the folder "defs". enemies are in "defs/actors/enemies.txt"
So first let's copy the "defs/actors/enemies.txt" file that was in the game.kpf that you unzipped before, and paste that into "Turok 2 - Seeds of Evil/defs/actors/enemies.txt"
Edit the file and the first entry is the Raptoid enemy. It's already defined all the properties and components needed by enemies in the game so we are going to add our custom script component class to the enemy by adding:
That's all you need to do. Run the game - make sure you're in developer mode by opening the console and typing "developer 1" if you weren't you need to close and reopen the game after setting it. When a Raptoid is damaged it should display that damage text.
If we wanted to display the damage done to an enemy on the screen, the first thing we need to do is create a script for enemies.
So first create a new file and call it "Enemy.txt" and place it in the scripts folder. Edit the file and create a class named Enemy and add the OnDamage callback function like so:
Code: [Select]
class Enemy : ScriptObject
{
kActor@ self;
Enemy(kActor@ actor)
{
@self = actor;
}
void OnDamage(kDamageInfo& in dmgInfo)
{
Hud.AddMessage("Enemy took " + dmgInfo.hits + " damage");
}
}
Now we just have to hook this script up to all the enemies in the game, but for testing let's just hook it up to the Raptoid enemy.
All the definitions of everything in the game is in the folder "defs". enemies are in "defs/actors/enemies.txt"
So first let's copy the "defs/actors/enemies.txt" file that was in the game.kpf that you unzipped before, and paste that into "Turok 2 - Seeds of Evil/defs/actors/enemies.txt"
Edit the file and the first entry is the Raptoid enemy. It's already defined all the properties and components needed by enemies in the game so we are going to add our custom script component class to the enemy by adding:
Code: [Select]
Begin_Component "kexScriptComponent"
scriptClass "Enemy"
End_Component
That's all you need to do. Run the game - make sure you're in developer mode by opening the console and typing "developer 1" if you weren't you need to close and reopen the game after setting it. When a Raptoid is damaged it should display that damage text.