Modding Galactic Overlord
Modding Galactic Overlord
Modding Glactic Overlord involves adding assets and scripts to a folder in the mods folder. The scripts are Javascript, so you will need some knowledge of Javascript to create a mod.
If you want to jump right in without reading a wall of text, copy the 'awesomeMod' folder from your install directory to the 'mods' directory, then start messing with the values in mods/awesomeMod/scripts/script.js file.
To start, you must create a mod in the mod folder. To do so, navigate to the install directory, copy the folder called 'Mod Template', paste it into the mods folder, and rename the folder to your mod name.
The Mod Template folder contains the required files for a mod to work. We'll go through them one by one.
First is the info.txt file.
name:(Mod Name) desc:(Mod Description) by:(Author) version:1.0
This file contains the metadata of your mod, used to display information to users. Simply replace the parenthetical values in the file with appropriate values for your mod.
The next files are the .html files which are used to point Galactic Overlord to the files you actually want to use in your mod. Let's look at images.html first.
<img id="(your id)" src="mods/(your mod folder)/images/(your filename)" />
Replace the parenthetical values with the ones appropriate for your mod. In this case 'your id' is how your mod will access the image.
You may have as many image tags in this file as you need. Each should have a unique id and point to an image file. Ids are global, so you should prepend your ids with your mod name. For example, if your mod is called awesomeMod, your ids should look like this: awesomeMod_awesomeImage.
The Mod Template/images folder contains template images for each card, which you can use as the background of new card images you create.
This process is the same for the other .html files. The audio.html file looks like this:
<audio id="(your id)"><source src="mods/(your mod folder)/audio/(your file name)" type="audio/wav"/></audio>
The process for updating this file is the same as the process for images.html. Again, you can have as many references as you like here, and you should prepend your mod name to all the ids defined.
Finally, the scripts.html file looks like this:
<script type="text/javascript" src="mods/(your mod folder)/scripts/(script file name)"></script&ht;
As always, replace the parentheticals here with appropriate values. Ids do not need to be defined here. These point to the scripts Galactic Overlord will run to add your custom cards.
Now let's get to the fun stuff! Here is how you would define a new card in any of your scripts files (though typically you only need one):
Mods.(your mod name) = {
cards: {
(your mod name)_exampleUnit: {
power: 1,
toughness: 1,
color: 'white',
type: 'creature',
name: 'Example Creature',
desc: 'Description goes here',
behavior: 'normal',
onEnter: () => {
},
onDie: () => {
},
action: () => {
//every turn, before attacking
},
img: '(id of your image)',
},
(your mod name)_exampleStructure: {
color: 'red',
type: 'structure',
name: 'Example Structure',
desc: 'Description goes here',
onEnter: () => {
},
onDie: () => {
},
action: () => {
//every turn
},
img: '(id of your image)',
},
(your mod name)_exampleAction: {
color: 'blue',
type: 'action',
name: 'Example Action',
canPlay: () => {
return true;
},
getTargets: () => {
//returns legal targets of the card
return [State.combat.playerField, State.combat.enemyField];
},
filterTargets: (t) => {return t.isCondition() ? true : false},
onUse: (target) => {
target.hasStuffHappen();
},
img: '(id of your image)',
}
}
}
Here, we're registering three cards with the Mods object under the mod (your mod name). These cards will enter the global context, so it's important to prepend their definitions with your mod name here too.
Each card has a series of values and functions associated with it. The values define how the card is displayed and its power and toughness, in the case of a creature. Here are the possible values:
- power: integer (only applies to creatures)
- toughness: integer (only applies to creatures)
- name: string (displayed at the top of the card)
- desc: string (displayed in the text box in the bottom half of the card)
- type: 'creature' | 'structure' | 'action' (defines the card type)
- behavior: 'normal' | 'hero' | 'thug' | 'assassin' (defines the targeting behavior of the card. Only applies to creatures. Default value is 'normal'.)
- color: 'white' | 'blue' | 'green' | 'red' (defines the card color)
- img: string (the id you assigned to this card's image file in images.html)
The functions are called when certain events are triggered. These are the functions that can be triggered:
- canPlay()
- Returns true or false. If it returns false, the card cannot be selected to play.
- getTargets()
- Returns a list of cards this card can legally target. If the returned list is empty, this card cannot be selected to play.
- filterTargets(t)
- Takes a list of possible targets (t), and returns a filtered list based on those targets. Should always return a list of at least 1 possible target.
- onEnter()
- This action is performed whenever the card enters the field from a player's hand.
- onDie()
- This action is performed whenever a card is discarded from play. (Only applies to creatures and structures)
- action()
- This action is performed every turn. (Only applies to creatures and structures. In the case of creatures, this action is performed before they attack.)
- onUse()
- This action is performed when a card is played from the hand. (Only applies to actions)
Each card definition is a collection of some or all of these values, which together create a unique card.
Let's create a simple mod called 'awesomeMod'.
First, we'll create a custom creature. Let's build a white creature called 'Palewing Medic' that is 1/1 and gains you one life when it enters the field.
First, we'll create an image called palewingMedic.png in the images folder, and then give it the id 'awesomeMod_palewingMedic' in the images.html file.
Then, we'll create a little jingle that plays when the medic enters called 'healed.wav', and give it the id 'awesomeMod_healed' in the audio.html file.
(Creating images and sound files are outside the scope of this tutorial)
Mods.awesomeMod = {
cards: {
awesomeMod_palewingMedic: {
power: 1,
toughness: 1,
color: 'white',
type: 'creature',
name: 'Palewing Medic',
desc: 'Enter: Gain 1 life',
behavior: 'normal',
onEnter: () => {
selfHp(1);
AudioControl.play('awesomeMod_healed');
},
img: 'awesomeMod_palewingMedic',
}
}
}
Here, the command selfHp() updates the hit points of the player whose turn it is. Use a negative number to reduce hit points. opponentHp() will do the same to the player whose turn it is not.
You can also access the players' cards with selfCards() or opponentCards().
As you can see in this example. You can use the command "AudioControl.play('(audio id)')" to play a sound effect.
That's it! Save your files, relaunch Galactic Overlord, and you should see your new mod in the Mods window!
If you'd like to get a better idea of how all the game cards work, you can check js/Cards.js in your Galactic Overlord install folder to see each card's implementation.
Keep in mind some of the cards were coded before some of the helper functions were implemented, so some of their logic may be more complicated than expected.
If your mod is not showing up in the menu, it may have errors in it. Hit ctrl+shift+i to open the developer tools and read any errors.
