Medal System
This article covers the medal system which is developed alongside base melees in the base melee repository. A standalone download will be available on Lorry shortly. Described briefly, the medal system is a rule which awards player medals for crazy or courageous achievements.
Description
The medal system is a rule which can be added to any OpenClonk scenario and awards medals to players. Medals are awarded for special or courageous achievements and come with rewards in the sense of clunkers. For examples of medals have a look at the complete list of medals in the basic rule. Medals themselves are represented by single definitions in OpenClonk and the player can earn more than one of each type. The medal system should incentivize players to undertake more courageous and experimental actions and result into more fun while playing. The amount of medals you have earned can be viewed by typing
/medals <player name>
while being ingame. Substitute <player name> with any player in the round to see the medals he has earned so far.
List of Medals
Medal | Index | Reward | Description |
---|---|---|---|
Hat-trick | 1 | 25 | Awarded when three enemies are killed in a row. |
Miner | 2 | 50 | Awarded for mining at least one thousand clunkers during a single round. |
Decorated | 3 | 50 | Awarded when you get awarded with more than ten medals in a single round. |
Kamikaze | 4 | 25 | Awarded when you kill yourself and an enemy clonk simultaneously. |
Pyromania | 5 | 40 | Awarded for setting 100 objects on fire in a single round. |
Critical Hit | 6 | 20 | Awarded for dealing more than 40 damage in a single hit. |
Demolition | 7 | 50 | Awarded for destroying ten structures. |
Medal Scripting
Now we dive into the mode technical part of the medal system and explain how medals can be created. If you want to create a medal yourself this is a must read. A medal is a single object definition with a script, possibly supported by multiple appendto scripts. The medal definition is placed in
Medals.ocd/
and the appendto scripts are placed in
Scripts.ocd/System.ocg/
The latest version of the medal rule can be found here and should always be used when developing new medals. If you want to create a new medal, first copy the template medal and rename the object to your new medal name. Also be sure to change the ID and the StringTables of the medal.
Now let's have a look at the template medal's scripts and walk through the code. First we find the usual header, where you can put your name as author and a name
// A medal should have a name. local Name = "$Name$";
and description
// A medal should have description. local Description = "$Description$";
These entries should remain the same, and will automatically grab the right translation from your already up to date string tables.
There are three other trivial entries as well
// A medal should have this function and return true. public func IsMedal() { return true; }
this piece of script you can also leave as is. It just tells any other object requesting that this definition is in fact a medal! Then we have
// A medal should have this function and return a unique index. // Consult the list of existing medals to get a unique index. // The medal index can be any integer between 0 and 254. public func GetMedalIndex() { return 0; }
The internal storing of medals in the player file and or league requires medals to have a unique identifier. This identifier has to be between 0 and 254 cause of league requirements on the storage of extra data. If you add a medal you can make sure the identifier is unique by looking into the MedalList.txt and your medal there when you want to contribute to the medal rule. As last we have
// A medal can have a reward in clunker which needs to be // returned by this function. public func GetMedalReward() { return 0; }
which should return the reward a player gets in clunker when being awarded this medal. Keep this a fair amount based on the difficulty and likelihood to obtain such a medal.