Difference between revisions of "User:Ducks/A Simple First Mod"

From Mod Wiki
(Copying the .def file)
Line 9: Line 9:
 
* How to create your own mod
 
* How to create your own mod
 
* How to modify ETQW's .def files to change a rocket
 
* How to modify ETQW's .def files to change a rocket
* How to modify ETQW's .script files to change the player
 
  
 
'''This tutorial does not:'''
 
'''This tutorial does not:'''
* Teach you how to program or compile the game code
+
* Teach you how to program scripts or edit/compile the game code
  
 
== Basic setup ==
 
== Basic setup ==
Line 101: Line 100:
 
  "fx_airburst" "effects/impacts/rocket/explosion_air"
 
  "fx_airburst" "effects/impacts/rocket/explosion_air"
 
  }
 
  }
 +
 +
== Script Files (.script) ==
 +
Where definition files contain settings and values of entities, script files describe the ''behaviour'' of entities. All weapons, vehicles, items and projectiles are defined with script files. Script files present a 'high-level' way to access the mechanics of the game, and can be modified while the game is running.
 +
 +
''Script files are not be be confused with game code. which is programmed in C++ and contains all the low-level game behaviour. Many mods can be created entirely through script files.''

Revision as of 16:44, 29 November 2007

This is the barebones guide for creating a simple mod. It won't be a terrifically amazing mod, since it will just be ETQW with a few small changes, but it will demonstrate the basic principles.

Introduction

For this tutorial you must:

  • Have your SDK Launcher set up correctly
  • Have a good text-editor, such as Notepad

This tutorial covers:

  • How to create your own mod
  • How to modify ETQW's .def files to change a rocket

This tutorial does not:

  • Teach you how to program scripts or edit/compile the game code

Basic setup

First, we need to create the mod folder for all the files our mod will use. When you want to send your mod to someone else, all you'll need to send them is the folder, which they can then place in their ETQW directory.

The SDK Launcher includes a button to set this up for you - the 'Create...' button. Press this, and it will ask for a mod name (preferably no spaces, like 'simplemod') and a description. Our mod is going to be called 'simplemod', described as 'a simple mod'.

This will have created a directory in your ETQW directory called 'simplemod'.

Definition files (.def)

ETQW uses .def files to store information and settings for various items, weapons and objects. For example, if you open up \SDK 1.2 Beta\base\def\weapons\rocketlauncher.def in Notepad, you'll see a section about models, a section about animations, and then a section containing lots of different numbers.

This first section with numbers (which starts 'invItemDef inventory/weapons/law') contains all the information about the GDF rocket launcher, such as what model to use, its name, and lots of values about when it can be used and the spread it produces.

Further down, under 'entityDef projectile_law' are all the values for the actual (seeking) rocket (the one that flies through the air and explodes), such as the velocity it flies at ('4000 0 0', which means 'forward at 4000 units a second'), how long it's fuse is ('3', which means 'explode after 3 seconds of not hitting anything'), and gravity ('0', which means 'fly through the air in a straight line').

There's also 'entityDef projectile_law_arcing', which are the values for the non-seeking rocket, which arcs through the air because it has a 'gravity' setting of '120'.

What we're going to do is change the arcing rocket so it travels really slowly, lasts really long, and doesn't arc (i.e. make it fire in a straight line).

Copying the .def file

First, we need to know which file to modify - in this case, it's \SDK 1.2 Beta\base\def\weapons\rocketlauncher.def. However, we shouldn't modify this file, as it's the one from the SDK. Instead, it should be copied to the 'simplemod' folder.

So copy \SDK 1.2 Beta\base\def\weapons\rocketlauncher.def to \simplemod\def\weapons\rocketlauncher.def. You'll need to create the 'def' and 'weapons' folders yourself.

This means that when simplemod is launched, the game will use the simplemod rocketlauncher.def file, instead of ETQW's. So we can change this file as much as we want.

Editing the .def file

Now open \simplemod\def\weapons\rocketlauncher.def in Notepad, and find the section for the entity 'projectile_law_arcing'. It'll look like this:

entityDef projectile_law_arcing {
	"inherit"							"projectile_rocket_base"

	"dmg_damage"						"damage_law"
	"dmg_splash_damage"					"damage_law_splash"

	"launchFromBarrel"					"1"
	"health"							"0"
	"velocity"							"2000 0 0"
	"face_velocity"						"1"
	"gravity"							"120"
	"fuse"								"4"

	"snd_fly"							"sounds/weapons/law/fly"
  	"fx_trail"							"effects/base/missile_trail"

	"fx_explode"						"effects/impacts/rocket/explosion_default"
	"fx_explode_sand"					"effects/impacts/rocket/explosion_sand"
	"fx_explode_metal"					"effects/impacts/rocket/explosion_metal"
	"fx_explode_snow"					"effects/impacts/rocket/explosion_snow"
	
	"use_air_burst"						"1"
	"fx_airburst"						"effects/impacts/rocket/explosion_air"
}

We're going to change the rocket so it travels really slowly in a straight line.

First to make it slower, change the 'velocity' setting from '2000 0 0' to '100 0 0', so it only travels 100 units a second.

Next, change 'gravity' from '120' to '0', so isn't pulled down by gravity while in the air.

Lastly, change 'fuse' from '4' to '30', so it'll last 30 seconds before it explodes (unless it hits something first)

This is the result:

entityDef projectile_law_arcing {
	"inherit"							"projectile_rocket_base"

	"dmg_damage"						"damage_law"
	"dmg_splash_damage"					"damage_law_splash"

	"launchFromBarrel"					"1"
	"health"							"0"
	"velocity"							"100 0 0"
	"face_velocity"						"1"
	"gravity"							"0"
	"fuse"								"30"

	"snd_fly"							"sounds/weapons/law/fly"
  	"fx_trail"							"effects/base/missile_trail"

	"fx_explode"						"effects/impacts/rocket/explosion_default"
	"fx_explode_sand"					"effects/impacts/rocket/explosion_sand"
	"fx_explode_metal"					"effects/impacts/rocket/explosion_metal"
	"fx_explode_snow"					"effects/impacts/rocket/explosion_snow"
	
	"use_air_burst"						"1"
	"fx_airburst"						"effects/impacts/rocket/explosion_air"
}

Script Files (.script)

Where definition files contain settings and values of entities, script files describe the behaviour of entities. All weapons, vehicles, items and projectiles are defined with script files. Script files present a 'high-level' way to access the mechanics of the game, and can be modified while the game is running.

Script files are not be be confused with game code. which is programmed in C++ and contains all the low-level game behaviour. Many mods can be created entirely through script files.