Knights & Dragons: a working example of how to create a mod

A place to find all custom made campaigns, mods and to discuss the story mode and how to create mods.

Knights & Dragons: a working example of how to create a mod

Postby wololo » Mon Jul 18, 2011 12:58 pm

Advertising
Wagic 0.16 introduces some major changes, including more flexibility to create mods. This does not allow you to create full games yet, but hopefully we'll get there eventually.

To explain some of the features here I will be using a mod I worked on, called Knights and Dragons. This mod is fully functional but needs lots of tweaking to be actually fun. I don't know if I will improve/maintain it beyond the scope of this tutorial.

Image

Download Knights and Dragons
Download here

How to install:
rename your existing wagic_res or Res folder into something else, such as "Res_backup" or something. Instead of that folder, put the contents of the zip downloaded above
Then just run Wagic normally, the startup screen should look like that:

What is it
Knights and Dragons is a little turn based strategy game which borrows gameplay concepts from games such as Warcraft, or Szei's mod (which cannot be found anymore, unfortunately).
You basically have a Castle to defend (represented by your avatar), and for that, you have units that can attack the opponent's castle, and buildings that can create units.
People who played wagic previously won't be surprised by the controls, but the rules are fairly different to what you're used to:
- Colored mana is replaced by 4 resources: gold, wood, meat, and mana
- Units don't have a color, or rather, their color is just a visual indicator of what they do. For example, the Miner provides gold, and its frame color is therefore gold. The woodcutter provides wood, and its color is green. Army units are usually represented in grey, and building are represented in brown, etc...
- There is no real concept of "deck" or deck building. Instead, you choose a hero and their army, but independently of your deck, you can build your army from the ground up, just with the elements on the battlefield. There is no shop or Deck editor.
- resources don't wear out unless you use them
- units that are damaged keep the damage and do not get magically healed at the end of a turn
- "activating" a unit greys it out, it does not "tap" the unit
- Resources are not provided by activating some units, rather, the amount of resource producing units is directly related to the amount of resources you get at the beginning of each turn.

To be entirely honest, this mod was designed to prove that the Wagic engine can handle a game that does not infringe on WotC's copyrights or patents. This explains for example why there is no deck editor

Let's get started:

Think about your game rules, universe, etc...
The Wagic engine is becoming more and more flexible, but it is still limited in many ways. With experience, you'll learn how to create a game that does not go beyond these limits... But basically the idea for now is to ask yourself what kind of game you want to do. In particular, rules, balance, will you be able to provide graphics for all your units/cards, etc... You will see as we go that my example Knights & Dragons has many flaws, and needs to be tweaked if we want it to become actually good.

Copy the Res folder from Wagic's original download
My favorite way of working is to modify existing stuff rather than creating from scratch. It guarantees that my mod will work from the start, without any weird crash in case I forgot an important graphic file or something...
You can use the Res folder provided with my mod if you think it is easier

We will basically go through each folder in order to explain what needs to be modified

ai
This is where the AI decks will go (in ai/baka). Creating AI decks is fairly easy and you can find explanations on the forum [TODO: add links]. Your AI decks will actually depend on what cards are in your game, so you might want to come to this section later.
Ai's avatars go in ai/baka/avatar. Each jpeg file is associated to the matching deck number.

If you look at the AI's decks in my mod, you might be surprised to find some lines named "HINT". Those are here to guide the AI in using its decks. My mod relies a lot on tokens, and basically the AI has no idea how to build, say, a dragon, unless I teach it how to do it. The only way the AI could do this automatically would be by scanning the entire database of units and building some crazy dependency tree, so instead of going through this dangerous path, we decided to let the mod builder give some help to the AI.
[TODO: explain AI Hints in detail]

campaigns (optional)
Those are used for the story mode. I didn't include any in my mod, but you can create stories by mimicking existing campaigns that can be found in the campaign forum, or in the default Wagic download.

graphics (optional, recommended)
Wagic's graphics are all using standard png or jpg, and can be edited as much as you want. The design of you game is an essential part, and honestly it is a full time job to create the graphics for your game. In my example, I only edited the "manaicons" file, to replace some of the mana icons with gold, meat, mana, and wood.
Fonts, themes, cards... every single graphic in Wagic is editable, and your mod will look even better with its own graphics.
You don't have to change the default graphics initially, but at some point it will help you make your mode better.

Graphics are not found only in the graphics folder, they also exist in the ai folder, the campaigns folder, the themes folder... see each section for details

lang (optional, recommended)
This is an important piece: language files are used to translate Wagic, but you can also use them to "change" the english wording.
Example: Internally,Wagic still relies on some hardcoded card types such as "enchantment" or "creature". You might not like this wording for card types, but you unfortunately have to use it (for now). The good point is that although you need to use those hardcoded values in your setting files, you can change how they get displayed to the user by using language files. If you edit the english language file to say that "enchantment" gets translated to "magical artifact", all enchantments will now have a name matching your wish, will retaining some of Wagic's hardocded logic for enchantments (attach to their target, etc...)

packs (optional)
This explains how to create your own types of boosters. My mod doesn't have a shop so I didn't touch this folder, and it can be entirely removed. If you want more info on packs, checkthis post

player
This is the player's data folder. It will contain the default option file [TODO: explain the default options], as well as premade decks for the player (in the premade folder) or decks that the player can edit (directly in the player folder) (provided a deck editor is available in your game)
Player decks are created the same way AI decks are created, see above

[img]kad_deck.jpg[/img]
My mod only offers 2 decks to the player, and one of them needs to be unlocked before it can be used

profiles (remove)
This is where player profiles are saved, this folder is not necessary, and will be created by itself if it is needed (when players create a new profile)

rules
This is the meat of your mod.
The rules folder needs to contain a modrules.xml file, as well as a bunch of "game mode" .txt files. My mod only contains a "default.txt" mode, as well as the compulsory modrules.xml file.

modrules.xml contains rules that are global to your mod: how the game will globally behave, excluding the actual rules of your game. It tells what options to show on the main menu, for example.
This is basic xml, so if you don't know about xml, it is recommended that you learn a bit about it first [TODO add link]
Let's compare the one from the default Wagic, and the one from Knights and Dragons

Wagic (mtg)
Code: Select all
<?xml version="1.0" ?>


<menu>
  <main>
    <item iconId="5" displayName="Play" action="playMenu" particleFile="particle1.psi" />
    <item iconId="2" displayName="Deck Editor" action="deckEditor" particleFile="particle2.psi" />
    <item iconId="1" displayName="Shop" action="shop" particleFile="particle3.psi" />
    <item iconId="4" displayName="Options" action="options" particleFile="particle4.psi" />
    <item iconId="3" displayName="Exit" action="quit" particleFile="particle5.psi" />
  </main>

  <other>
      <item displayName="Trophy Room" action="trophies" key="btn_next" />
  </other>
</menu>


Knights and Dragons
Code: Select all
<?xml version="1.0" ?>

<general>
  <hasDeckEditor>0</hasDeckEditor>
  <hasShop>0</hasShop>
</general>

<menu>
  <main>
      <item iconId="5" displayName="Play" action="playMenu" particleFile="particle1.psi" />
      <item iconId="1" displayName="Trophy Room" action="trophies" particleFile="particle3.psi" />
      <item iconId="4" displayName="Options" action="options" particleFile="particle4.psi" />
      <item iconId="2" displayName="Exit" action="quit" particleFile="particle2.psi" />
  </main>

  <other>
  </other>
</menu>

<game>
  <canInterrupt>0</canInterrupt>
</game>

<cards>
  <general>
      <activate>
        <uiEvent>mask(128,0,0,0)</uiEvent>
      </activate>
  </general>
</cards>


Wagic has mostly everything set to the "default", since historically it's the first game working with the Wagic engine. But it still defines the icons we show on the main menu, with the "menu" xml tag. (TODO: explain the menu tag in details]

Knights and Dragons describes the main menu as well, but you will see it is missing the deck editor and the shop. Also, the trophy room was moved to one of the "main" menu items rather than the icon on the top right of the screen.

Image
modrules.xml allows to tweak the main menu

It also has a few other tags:
hasDeckEditor and hasShop are set to "0". This allows the Wagic engine to take some decisions based on this, for example not to give the opportunity to players to build their own decks from the deck selection menu.

canInterrupt is set to 0, and basically this means that the stack cannot be interrupted. The stack in my mod is therefore only used as an indication of what my opponent plays, but I cannot use it to interrupt, because there are no interruptions in my mod

cards>general>activate describes the graphical event that happens when a unit goes into "activated" mode. In MTG, this is represented by tapping the card, but this specific thing is patented by WotC, so the engine gives us the possibility to have a different effect. For now, the only alternate effect is to add a rectangle above the card, and you get to choose the color of that rectangle. Maybe we'll extend this.

Those are the few available options in modrules for now. As time goes by, we expect to add more and more customization elements in this file.

The text files in the rules folder contain the actual game modes of your game. For example, in the default Wagic, we offer classic, random 1 color, Momir, Story, etc...
Those modes are all very nice, and you can have a look at all these text files to get inspiration, but for now let's focus on the one provided in Knights VS Dragons:

Image
Only one text file in the rules folder for my mod, it will show up in the game mode selection when the player selects "play"

Code: Select all
name=Classic
[INIT]
mode=mtg
[PLAYERS]
life:200
manapool:{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{R}{R}{R}{R}{R}{R}{R}
auto=moveTo(myBattlefield) all(Hero|myLibrary)
auto=moveTo(myBattlefield) all(Main-building|myLibrary)
auto=moveTo(myBattlefield) all(Peon|myLibrary)
auto=shuffle
auto=draw:1
auto=@each my firstmain:draw:1
auto=@each my firstmain:untap all(*|MyBattlefield)


customphasering:firstmain,combatattackers,combatblockers,combatdamage,secondmain,endofturn

[PLAYER1]
auto=tutorial(Welcome to Knights & Dragons!\n\nIn this mod, your hand is empty most of the time,\nand you need to rely more on the resources\non your battlefield.)
auto=tutorial(Some of your units have building capacities, and can create\nother units or buildings.)
auto=tutorial(Gold is the most important resource, but you also\nwant to have some meat, wood, and mana handy)


If you've ever created a test, this will look familiar, the rules system is very similar the test system: you declare an init stage describing the players' various zones, and there's additional sections (PLAYERS, PLAYER1, PLAYER2) describing specific rules (abilities) that apply respectively to both player, player1 only (the human player, usually), or player 2 only (the AI, usually)

name=Classic is what name the game mode will show up in the menu. You can set this to whatever you like.
[INIT] this is the init section, in which we will put a bunch of things describing the init stage. In the case of Knights and Dragons, nothing much, really:
mode=mtg this is to explain to the engine that we want the default behavior for the game, meaning in particular that the player gets to choose their deck (historically, "mtg" is the default behavior, don't ask). I think this is not actually needed...
[PLAYERS] We are starting a set of rules that will apply to both players when the game starts:
life:200 players start with 200 life points
manapool:{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{W}{R}{R}{R}{R}{R}{R}{R} The initial resources of each player
auto=moveTo(myBattlefield) all(Hero|myLibrary)
auto=moveTo(myBattlefield) all(Main-building|myLibrary)
auto=moveTo(myBattlefield) all(Peon|myLibrary)

Some stuff that happens which allows the game to move a few essential cards from the players' decks directly into play. This allows to start each duel with a set of predefined cards in play
auto=shuffle shuffle the decks
auto=draw:1 draw one card

Image
The game looks like this when we start. There's already some resources available, and some cards have been moved from our decks to the battlefield.
I have only one card in my hand (top right), as described in the rules

auto=@each my firstmain:draw:1
auto=@each my firstmain:untap all(*|MyBattlefield)
additional rules that happen at specific phases.

If you are not familiar with those "auto" lines, please check the card coding guide, as this is exactly the same system [TODO: add link]


customphasering:firstmain,combatattackers,combatblockers,combatdamage,secondmain,endofturn
This one tells what phases are going to be in this game. There's only a set of hardocded ones that we can use for now. Those can be put several times if needed, you can imagine having several combat phases for example.

[PLAYER1] These only affect player1 (the human player).
auto=tutorial(Welcome to Knights & Dragons!\n\nIn this mod, your hand is empty most of the time,\nand you need to rely more on the resources\non your battlefield.)
auto=tutorial(Some of your units have building capacities, and can create\nother units or buildings.)
auto=tutorial(Gold is the most important resource, but you also\nwant to have some meat, wood, and mana handy)

Those are a bunch of tutorial messages, made to explain how the game works. You can also check some of those messages in the "classic.txt" rule file of Wagic. The tutorial messages are "normal" abilities but they only happen once for a given player. In particular, you can tie them to some trigger so that they display only when some specific event happens.

sets
This is where you will put your cards, your sets, and also the pictures representing them.
coding cards and sets is a complete job, and you'll need to learn how to do it.
The most complete reference is this wiki, but you will also find help in the card coding section of the forum

settings (optional)
Dafeult settings for the game, in the future we plan this folder to be empty initially

sound (optional, recommended)
This is where you put the musics and the sound effects. Most sound effects are triggered by card types when the come into play, with a few exceptions
[TODO: more explanation on sfx]
Musics have special naming conventions [TODO: more explanations here]

Themes (optional)
This is where you will put graphical themes for your game. See this guide on how to create themes.
wololo
Site Admin
 
Posts: 3726
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Knights & Dragons: a working example of how to create a

Postby Shadowfireomega » Sat Jul 30, 2011 4:49 am

nice, this looks fun! ill give it a try, i love tower defense games :D
Just checked it out, hard as heck but fun as well.
Wagic: the Homebrew Image Pack Easy Installers

"I love being wrong, for if I was always right, I would never learn anything, and that would be a sad life." -Benjamin Fisher
check out my blog http://shadowfireomega.blogspot.com/
Shadowfireomega
 
Posts: 70
Joined: Thu Apr 07, 2011 7:06 am
Location: San Antonio, Texas, USA

Re: Knights & Dragons: a working example of how to create a

Postby jeremy » Sat Jul 30, 2011 5:38 am

hi,
I tried to modify the Res.txt file within WTH and made a separate folder to try and get both games working on the PSP at once, but sadly I kept getting blue screen of deaths with only the main install working fine.
Being as this was a mod instead of just a change in campaign, I thought it was a more elegant solution.
Would you mind checking through on what I renamed wrongly or is there another file within the folder I have to change in order to do the separate install.
thanks.

http://www.megaupload.com/?d=66H56A84
jeremy
 
Posts: 96
Joined: Fri Sep 18, 2009 1:29 am

Re: Knights & Dragons: a working example of how to create a

Postby wololo » Sat Jul 30, 2011 6:33 am

your file GAME/KnightsAndDragons/KnightsAndDragons.txt should be named GAME/KnightsAndDragons/Res.txt
wololo
Site Admin
 
Posts: 3726
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Knights & Dragons: a working example of how to create a

Postby jwilkes99999 » Wed Sep 07, 2011 9:53 pm

Has anyone done an image set for this mods cards? I tried looking in the custom cards and image section but couldnt find anything. I love the mod but just like vanilla wagic Im less likely to play without card images.
jwilkes99999
 
Posts: 151
Joined: Sun Jan 16, 2011 8:58 pm

Re: Knights & Dragons: a working example of how to create a

Postby wololo » Thu Sep 08, 2011 5:14 am

Hi, unfortunately not yet, but if I have time I want to work more on this mod and balance it better, make it more enjoyable, and maybe add images at some point.
wololo
Site Admin
 
Posts: 3726
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Knights & Dragons: a working example of how to create a

Postby jwilkes99999 » Sat Sep 10, 2011 6:33 am

If you don't mind then I'm going to try and make images for the sets you've already created using open source images so that they will be distributable.
jwilkes99999
 
Posts: 151
Joined: Sun Jan 16, 2011 8:58 pm

Re: Knights & Dragons: a working example of how to create a

Postby wololo » Sat Sep 10, 2011 6:59 am

Thanks, this sounds like a great idea :)
wololo
Site Admin
 
Posts: 3726
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Knights & Dragons: a working example of how to create a

Postby jwilkes99999 » Sat Sep 10, 2011 7:24 am

I'm working on it now and hope to have it done before I go to sleep. Some of the pictures aren't going to be great since they are all open source but I think it should turn out rather nicely.

Edit: I just realized, the card images are open source but I'm using the MTG mana symbols. Does that ruin the cards for distribution?
jwilkes99999
 
Posts: 151
Joined: Sun Jan 16, 2011 8:58 pm

Re: Knights & Dragons: a working example of how to create a

Postby wololo » Sat Sep 10, 2011 8:19 am

Yup, youd rather use the icons provided with the mod, or even colored squares...
wololo
Site Admin
 
Posts: 3726
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Advertising

Next

Return to Campaigns and mods

Who is online

Users browsing this forum: No registered users and 1 guest

cron