Ruleset and unit graphics manipulation

everything else
Post Reply
Corbeau
Member
Posts: 990
Joined: Thu Jan 01, 1970 12:00 am

Ruleset and unit graphics manipulation

Post by Corbeau »

I'm working on a different ruleset (*very* different) and one of the essential things I need is adding a new unit. However, is that something that can be done on a ruleset level? I can use an existing unit slot (for example, Crusaders are completely useless), only need to change the existing unit image. However, as far as I know, that would probably need having to grab the new image file outside the ruleset directory for everyone wanting to play that version of the game. Or am I wrong? Any possible solutions to this?
wieder
Member
Posts: 1781
Joined: Thu Jan 01, 1970 12:00 am

Post by wieder »

Currently you can only use existing images. It's easier with building because the graphics are not that important there and you can even use some more generic image of a building. Something like universities and academies are using.

What kind of unit you are planning to implement?
Corbeau
Member
Posts: 990
Joined: Thu Jan 01, 1970 12:00 am

Post by Corbeau »

A very, very short version: add another class of units, extremely ineffective, but also extremely cheap, easy to raise in case of a sudden invasion or breach. Name of class: Militia. Consists if existing Warriors (price 5 shields or less) and Partisans (also cheaper than original), but need something in between, alongside Musketeers. I'd call them Skirmishers, also extremely cheap and innefective, but to be used in emergencies. I already have an image, I edited Musketeers to look a bit more in line, and for Skirmishers took existing image from musketeers and turned blue into gray. Looks fine, only a slight problem with implementation.

Also, I've seen that there are some existing unused extra slots in the units.png file. Any way to call them from the ruleset?
User avatar
HanduMan
Member
Posts: 115
Joined: Thu Jan 01, 1970 12:00 am

Post by HanduMan »

Corbeau wrote:I'm working on a different ruleset (*very* different) and one of the essential things I need is adding a new unit. However, is that something that can be done on a ruleset level?
Yes it is. Adding new units is done by modifying a ruleset. Ruleset is where you define what kind of units can exist in a game. So, if you need to add a new unit then you add it in the units.ruleset (or in some new additional unit definition file of your choise).
Corbeau wrote:I can use an existing unit slot (for example, Crusaders are completely useless), only need to change the existing unit image. However, as far as I know, that would probably need having to grab the new image file outside the ruleset directory for everyone wanting to play that version of the game. Or am I wrong? Any possible solutions to this?
Now we are talking about tilesets which are separate from the rulesets. In tileset you define some images for some units used or not used in any ruleset. So, if you need to add new graphics for your new units, you need to edit the tileset you are using in the game. Ruleset acts on the server while each client joining a game can choose whatever tileset they prefer for a game, and change it whenever they want to, even during the game. So, if you intend your ruleset to be multiplayer-playable, you need to make sure it is supported by all commonly known tilesets. Unless you can deliver your own customised tileset to all players involved.

Let's take that Militia for example. When you define it in units.ruleset it could be something like
[unit_militia]
name = _("Militia")
class = "Land"
tech_req = "None"
obsolete_by = "None"
graphic = "u.militia"
graphic_alt = "u.warriors"
...
The line 'graphic' & 'graphic_alt' lines direct the freeciv client to seek for a sprite named "u.militia" for the Militia unit from the tlilset currently used by the client. If it cannot be found then a sprite named "u.warriors" is taken. That way your new units are being displayed at least with some image if the used tileset does not include your sprites for them. I'm not sure if it generates a run-time error on the client if no graphics is not found for a unit or does it just leave it blank when that happens.
Corbeau wrote:Also, I've seen that there are some existing unused extra slots in the units.png file. Any way to call them from the ruleset?
In tileset there is a spec file defining the contents of each image and the whereabouts of individual sprites contained therein. The sprites are dispersed in a grid the dimesions of which are defined in the beginning of the spec file:
[grid_main]
x_top_left = 0 ; starting position of coordinates
y_top_left = 0
dx = 64 ; width and height of each slot for a sprite (in pixels)
dy = 48

The location of each sprite is then defined by coordinates:
0, 18, "u.warriors"
So, the sprite for 'warriors' is the 19th image on the first row of the image file defined in the spec file. So, if you are adding a new sprite for 'Militia', you can add for example
1, 18, "u.militia"
in the units.spec file in your chosen tileset folder (that slot seems to be unused in the Amplio2 tileset) and include your graphics at the respective coordinates in the image file.

More appropriate way to add new graphics would be to create a new image file with a spec for them and the *include it in the main .tilespec file. That way it would also be easier to inject the 'addons' in all tilesets necessary.

Did I make it any clearer or just confuse you more? Hope not the latter.
Post Reply