[DIY] [0.60] Total Sheep Tutorial - Mob, Meat & More

Post here your released mods

[DIY] [0.60] Total Sheep Tutorial - Mob, Meat & More

Postby Effix » Wed Sep 05, 2012 4:05 pm

Thanks to Yetichow and his excellent Deerfarm Tutorial I can now guide you all through adding sheep and all the good stuff that naturally comes with those lovely furry animals.

Image

Part 0: Backup!
Messing up is quite easy, for example one typo can do the trick. So backup the full game without any edits, backup your saves and backup individual files that you edit.


Part 1: Let there be sheep
A sheep is a living entity, so we go to the file Towns/data/livingentities.xml with a text editor (after backing it up. ok.. last backup reminder).
Keeping in line with the pattern of the last entry, add the following code before the final closing tag (</livingentities>):
Code: Select all
<sheep>
      <type>FRIENDLY</type>
      <name>Sheep</name>
      <habitat>grass</habitat>
      <attack>1d59+170</attack>
      <attackSpeed>5</attackSpeed>
      <defense>1d59+170</defense>
      <healthPoints>1d74+213</healthPoints>
      <attackVerb esES="muerde">bites</attackVerb>
      <attackVerbInfinitive esES="morder">bite</attackVerbInfinitive>
      <damage>1d44+128</damage>
      <movePCT>1d2</movePCT>
      <walkSpeed>75</walkSpeed>
      <action>qkillsheep</action>
      <facingDirections>true</facingDirections>
      <building>sheepfarm</building>
      <buildingTime>2880</buildingTime>
      <drop>
         <item>rawlambchop</item>
         <PCT>30</PCT>
      </drop>
      <drop>
         <item>bones</item>
         <PCT>70</PCT>
      </drop>
   </sheep>


I like goat milk, I assume sheep milk is similar, so I also add another entry while we're here:

Code: Select all
<milkedsheep>
      <type>FRIENDLY</type>
      <name>Sheep</name>
      <habitat>grass</habitat>
      <attack>1d59+170</attack>
      <attackSpeed>5</attackSpeed>
      <defense>1d59+170</defense>
      <healthPoints>1d74+213</healthPoints>
      <attackVerb esES="muerde">bites</attackVerb>
      <attackVerbInfinitive esES="morder">bite</attackVerbInfinitive>
      <damage>1d44+128</damage>
      <movePCT>1d2</movePCT>
      <walkSpeed>75</walkSpeed>
      <action>qkillsheep</action>
      <facingDirections>true</facingDirections>
      <maxAge>1d1440+1440</maxAge>
      <maxAgeLiving>sheep</maxAgeLiving>
      <drop>
         <item>rawlambchop</item>
         <PCT>30</PCT>
      </drop>
      <drop>
         <item>bones</item>
         <PCT>70</PCT>
      </drop>
   </milkedsheep>   


As you can see this one has a max. age, making it turn into a regular sheep after a while so you can milk it again.

Adding these entries has some consequences and I don't think we can run the game without fixing at least some of the new references we added.
So let's see what the consequences are:
A - we said the sheep is a living thing but we didn't point to any graphics.
B - we said there's a new action named qkillsheep and a possible (See the PCT value) drop of a new item named rawlambchop. We also need an action to turn a sheep into a milked sheep. The habitat value decides on what type of terrain the sheep can spawn, but we need to do some more work to actually make them spawn on a new map.
C - we tied the sheep to a building named sheepfarm
The rest of the values are copied from another animal to keep things balanced.


A: Graphics
Sheep sprites are already in living2.png, thanks Towns team for that! 8-) I guess they left them out to balance the amount of animals on the different map types.
So yeah, this part will be easy, we just edit Towns/graphics.ini by adding the following entries:
Code: Select all
[sheep]TILE_X = 6
[sheep]TILE_Y = 0
[sheep]TILE_HEIGHT = 64
[sheep]TEXTURE_FILE = living2.png

[milkedsheep]TILE_X = 6
[milkedsheep]TILE_Y = 0
[milkedsheep]TILE_HEIGHT = 64
[milkedsheep]TEXTURE_FILE = living2.png


Details:
- TILE_X: 6th sprite from the left in Towns\data\graphics\living2.png if you start counting from 0, TILE_Y: Row 0 from the top if you start counting from 0. The coordinate system is based on a grid of 64 pixel wide x 32 pixel high tiles - check this example grid to explain it further.
- We only supplied a height, this is because the default width happens to be what we need (default = 64 pixels wide x 32 pixels high).
- this is an ini file, the structure is not like the livingentities xml file we edited. No closing tag this time, just a list of values with some empty rows for easy reading.


B: Actions
To fix the new actions we add the following to Towns/data/actions.xml, again before the last closing tag (</actions>).
Code: Select all
   <action>
      <id>qkillsheep</id>
      <name esES="Matar">Kill</name>
      <generatedItem>rawlambchop</generatedItem>
      <priorityID>butcheringkilling</priorityID>
      <queue>
         <pickFriendly useSource="true">sheep,milkedsheep</pickFriendly>
         <wait>36</wait>
         <destroyFriendly />
         <createItem>rawlambchop</createItem>
      </queue>
   </action>
   <action>
      <id>qmilksheep</id>
      <priorityID>gatheringharvesting</priorityID>
      <queue>
         <pickFriendly>sheep</pickFriendly>
         <wait>32</wait>
         <createFriendly>milkedsheep</createFriendly>
         <createItem>milk</createItem>
      </queue>
   </action>
   <action>
      <id>qbutchersheep</id>
      <priorityID>butcheringkilling</priorityID>
      <queue>
         <pickFriendly>sheep,milkedsheep</pickFriendly>
         <move>butchertable</move>
         <wait>32</wait>
         <destroyFriendly />
         <unlock />
         <createItem>rawlambchop</createItem>
      </queue>
   </action>


You do butchering through the production menu, I assume all the other ways of ending a sheep's life counts as killing (I wonder if Highlanders will punch them :twisted: ).

In Part 3 we'll cover a way to get some sheep into an existing map, but for the sheep to spawn on a new map we go to Towns\data\campaigns\c1 (YetiChow told me that this path is different if you bought Towns through Desura, I assume it's similar though) and then the folder of the map type that you want to add the sheep to, I'll just cover the normal map but you can repeat the same steps for other types. Now open the file gen_livingentities.xml and add the code below to the end of the file, before the closing tag:
Code: Select all
   <add>
      <entity>sheep</entity>
      <qtty>15</qtty>
      <pointx>1d200-1</pointx>
      <pointy>1d200-1</pointy>
      <level>1d11</level>
   </add>   

The quantity value (qtty) differs a bit per map type, you can look at the cow entry to see what's appropriate for a certain map type.


Part 2: Lambchops
Now we have even more references to rawlambchop, let's do something about that:
First we go to Towns/data/items.xml and add the following 2 entries before the closing tag:
Code: Select all
   <rawlambchop>
      <name esES="Chuleta de cordero crudo">Raw lamb chop</name>
      <description esES="¿Vas a comerte ésto?">Do you really want to eat this?</description>
      <type>rawfood</type>
      <canBeEaten>true</canBeEaten>
      <stackable>true</stackable>
      <stackableSize>1</stackableSize>
      <foodValue>1</foodValue>
      <foodFillPCT>25</foodFillPCT>
      <foodEatTime>180</foodEatTime>
      <foodEffects>bellyache,slow</foodEffects>
      <value>35</value>
   </rawlambchop>
   <cookedlambchop>
      <name esES="Chuleta de cordero cocinados">Cooked lamb chop</name>
      <type>prepfood.cooked</type>
      <canBeEaten>true</canBeEaten>
      <stackable>true</stackable>
      <stackableSize>1</stackableSize>
      <foodValue>4</foodValue>
      <foodFillPCT>105</foodFillPCT>
      <foodEatTime>84</foodEatTime>
      <value>90</value>
   </cookedlambchop>


Next we add the reference to the graphics, again in Towns/graphics.ini:
Code: Select all
[rawlambchop]TILE_X = 1
[rawlambchop]TILE_Y = 4
[rawlambchop]TEXTURE_FILE = sheep.png

[cookedlambchop]TILE_X = 2
[cookedlambchop]TILE_Y = 4
[cookedlambchop]TEXTURE_FILE = sheep.png


Now for the image, download sheep.png and move it to Towns\data\graphics
We'll leave consequence C (the farm) for the next part of the tutorial.


Part 3: The Sheep Farm
If you checked out sheep.png then you noticed you already have the graphics for the farm. So let's go to Towns/graphics.ini again and add:
Code: Select all
[sheepfarm]TILE_X = 0
[sheepfarm]TILE_Y = 0
[sheepfarm]TILE_WIDTH = 192
[sheepfarm]TILE_HEIGHT = 128
[sheepfarm]TEXTURE_FILE = sheep.png

[ui_sheepfarm]TILE_X = 3
[ui_sheepfarm]TILE_Y = 2
[ui_sheepfarm]TILE_HEIGHT = 64
[ui_sheepfarm]TEXTURE_FILE = sheep.png


Next we have to add a building, similar to what we did with the items. Open Towns/data/buildings.xml and add the code before the closing tag:

Code: Select all
   <sheepfarm>
      <name esES="Granja de ovejas">Sheep farm</name>
      <width>3</width>
      <height>3</height>
      <groundData>1001E0111</groundData>

      <type>SPAWN</type>

      <canBeBuiltUnderground>false</canBeBuiltUnderground>

      <mustBeBuiltOver>humus</mustBeBuiltOver>
      <mustBeBuiltOver>jungle</mustBeBuiltOver>
      <mustBeBuiltOver>grass</mustBeBuiltOver>
      <mustBeBuiltOver>grass1</mustBeBuiltOver>
      <mustBeBuiltOver>grass2</mustBeBuiltOver>
      <mustBeBuiltOver>grass3</mustBeBuiltOver>
      <mustBeBuiltOver>grassnoflower</mustBeBuiltOver>
      <mustBeBuiltOver>grassnoflower1</mustBeBuiltOver>
      <mustBeBuiltOver>grassnoflower2</mustBeBuiltOver>

      <prerequisite>rmwood</prerequisite>
      <prerequisite>rmwood</prerequisite>
      <prerequisiteFriendly>sheep</prerequisiteFriendly>

      <automatic>true</automatic>
   </sheepfarm>


You can comment out the sheep requirement if you don't want to start a new map to test things. Here's how you comment it out:
Code: Select all
<!-- <prerequisiteFriendly>sheep</prerequisiteFriendly> //-->

Don't forget to remove it once you have things going, a game without challenges gets boring fast.

What's left is the interface button so we can actually place the farm. Open Towns/data/menu_right.xml and look for a list of buildings at the bottom of the file. The most logical position would be after the last farm in the list (badger farm), insert the following code:
Code: Select all
<item code="BUILD" parameter="sheepfarm" icon="ui_sheepfarm" />


Part 4: Cooking things up
We already added the cookedlambchop item when we added rawlambchop, including the graphics. So what's left is a way to turn raw into cooked. There's 2 parts to this: the action to turn raw into cooked and adding something to the production menu to execute that action.
Let's do the action, first, go back to Towns/data/actions.xml and again add the code before the closing tag:
Code: Select all
   <action>
      <id>qcookedlambchop</id>

      <priorityID>foodmaking</priorityID>

      <queue>
         <pick>rawlambchop</pick>
         <move>kitchentable</move>
         <wait>32</wait>
         <destroyItem />
         <unlock />
         <move>stove,cookingfire</move>
         <wait>32</wait>
         <unlock />
         <createItem>cookedlambchop</createItem>
      </queue>
   </action>


Now for the production menu, open Towns/data/menu_production.xml and again find the appropriate spot, I would suggest under Cooking and after the last meat (roast). Insert this:
Code: Select all
<item code="QUEUE" parameter="qcookedlambchop" />


Part 5: That rug really tied the room together
If all went well you should be able to run the game and enjoy your new sheepfest.
I want to take it a bit further though, let's get that furry wool and make it possible to turn it into a rug for your rooms.
Not just the sheep sprites are already in the game, there's also a little piece of wool in items.png that we could use.
However, I didn't really like how that one looked as a rug, so that's why there's a new one in sheep.png.

Graphics:
It doesn't make a lot of sense but for the sake of variation I'll use that piece of wool from items.png for the sheep hide and the new graphics for the rug.
Go to Towns/graphics.ini and add:
Code: Select all
[sheephide]TILE_X=7
[sheephide]TILE_Y=27
[sheephide]TEXTURE_FILE = items.png

[woolenrug]TILE_X=0
[woolenrug]TILE_Y=4
[woolenrug]TILE_WIDTH = 64
[woolenrug]TILE_HEIGHT = 32
[woolenrug]TEXTURE_FILE = sheep.png


I'm sure you know how to make these two the same if you don't like the variation. I think we can actually leave out TILE_WIDTH and TILE_HEIGHT because they are the same as the default values, but it doesn't hurt.

Now we'll add the 2 as items, go to Towns/data/items.xml and add the following code, before the closing tag:

Code: Select all
   <sheephide>
      <name esES="Piel de oveja">Sheep hide</name>
      <type>rawmaterials.hides</type>
      <stackable>true</stackable>
      <stackableSize>1</stackableSize>
      <value>35</value>
   </sheephide>
   
   <woolenrug>
      <name esES="Alfombra de lana">Woolen rug</name>
      <zone>zpersonal</zone>
      <zone>zdining</zone>
      <zone>ztavernroom</zone>
      <zone>ztavern</zone>
      <stackable>true</stackable>
      <stackableSize>1</stackableSize>
      <alwaysOperative>false</alwaysOperative>
      <value>40</value>
   </woolenrug>


- As you can see we are restricting the rug to a few zones. You could also restrict it to indoor or outdoor or leave out any restrictions, see other items in the file on how to do that.
- For now it only takes a bit of time to turn a sheep hide into a rug so we raise the value of the rug only slightly (the 35 comes from looking at the other hides).

Next we add the needed actions, open Towns/data/actions.xml again and add the code below, before the closing tag:

Code: Select all
   <action>
      <id>qsheephide</id>

      <priorityID>butcheringkilling</priorityID>

      <queue>
         <pickFriendly>sheep</pickFriendly>
         <move>skinner</move>
         <wait>32</wait>
         <destroyFriendly />
         <unlock />
         <createItem>sheephide</createItem>
      </queue>
   </action>
   <action>
      <id>qwoolenrug</id>

      <priorityID>itemconstruction</priorityID>

      <queue>
         <pick>sheephide</pick>
         <move>skinner</move>
         <wait>20</wait>
         <destroyItem />
         <unlock />
         <createItem>woolenrug</createItem>
      </queue>
   </action>


As you can see the rug is made with the skinning table, doesn't make a whole lot of sense but I thought it was the most appropriate choice.

The last thing to do is add buttons to the menus to make use of it all. We don't need special graphics for this, it just uses the item's graphics.

We need a way to get the hides in the production menu and we need a way to place the rug.

First the production menu, open Towns/data/menu_production.xml and again find the appropriate spot. I suggest after qunifallowhide under Vanity -> Hides and materials. Insert the following:
Code: Select all
<item code="QUEUE" parameter="qsheephide" />


Now open Towns/data/menu_right.xml and look for Decorative -> Indoor and add the bit below after the qchesstable line:

Code: Select all
<item code="QUEUEANDPLACE" parameter="qwoolenrug" />



That should be all, I hope you made it and learned how to make your own variations of this. Hopefully you can now also add rugs for the other hides or maybe even some fancy arabian carpets. Have fun!


Files we edited:
Towns/graphics.ini
Towns/data/actions.xml
Towns/data/buildings.xml
Towns/data/items.xml
Towns/data/livingentities.xml
Towns/data/menu_production.xml
Towns/data/menu_right.xml

Files we added:
Towns/data/graphics/sheep.png


p.s. I left some things from experiments in sheep.png, I might do something with it but not sure. For now you may use it for whatever you like.


Updated to 0.60
What's new & relevant?
- Items have values, for buying/selling at the caravan
- UI icons can now be in your custom image
- All entries in graphics.ini need to have a texture file reference (no more TILESET_EXTRAS value)
Last edited by Effix on Mon Oct 01, 2012 5:43 pm, edited 14 times in total.
User avatar
Effix
 
Posts: 178
Joined: Mon Jun 18, 2012 11:18 am
Location: The Netherlands

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Aduvash » Wed Sep 05, 2012 5:53 pm

I haven't read this yet but thanks in advance, I'm going to make a mod which adds a lot more plants and some more animals so I'll add sheep. Right now I'm trying to work out how to add a new berry bush and I scrolled through your guide and noticed you added something about cooking, so that will help me add a pie type for it.

Edit: How do you make stuff spawn on the world? such as a blueberry bush, I can't figure it out.
You are a primitive human not an insult; a forum game. [Currently dead] Note that this was the first forum game on the towns forum, I'm a trend setter. :D
More Plants and Animals! [0.50]
Image
User avatar
Aduvash
 
Posts: 699
Joined: Mon Apr 30, 2012 1:17 pm
Location: New York State, USA

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Colombo » Wed Sep 05, 2012 7:34 pm

Nice. Great. Like woolen products! Wanna make a descriptive guide of all Towns files?:)
User avatar
Colombo
 
Posts: 737
Joined: Mon Jan 23, 2012 5:55 pm

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Effix » Wed Sep 05, 2012 9:19 pm

Aduvash wrote:I haven't read this yet but thanks in advance, I'm going to make a mod which adds a lot more plants and some more animals so I'll add sheep. Right now I'm trying to work out how to add a new berry bush and I scrolled through your guide and noticed you added something about cooking, so that will help me add a pie type for it.

Edit: How do you make stuff spawn on the world? such as a blueberry bush, I can't figure it out.


I'm afraid your question is very valid, I just abandoned my mixed terrain map to get a new one and I see no sheep at all. Maybe I'm overlooking something or maybe this is hardcoded, because I just used the same values as an existing animal.
For my tutorial it means you really need to comment out that sheep requirement for the sheep farm in Part 3 to get things started.
User avatar
Effix
 
Posts: 178
Joined: Mon Jun 18, 2012 11:18 am
Location: The Netherlands

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Aduvash » Wed Sep 05, 2012 9:33 pm

Hmm... We'll have to wait for a dev to chime in, unless one of the other modders know.
You are a primitive human not an insult; a forum game. [Currently dead] Note that this was the first forum game on the towns forum, I'm a trend setter. :D
More Plants and Animals! [0.50]
Image
User avatar
Aduvash
 
Posts: 699
Joined: Mon Apr 30, 2012 1:17 pm
Location: New York State, USA

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby YetiChow » Thu Sep 06, 2012 4:43 am

You need to find Gen_Living.xml and Gen_items.xml for each map (they're in the campaign folder with the Gen_map.xmls; different people have differnt file paths depending on how they purchased Towns e.g. Desura or BMT). Gen_Living adds all the living (i.e. moving) entities to the map; it's the one you use to get your sheep to spawn. Other items (trees, flowers or potential berry bushes) are generated according to the Gen_Items.xml. Again you can copy/paste the cow code and change it to sheep to get sheep to spawn as part of the map generation, and the same for the items.aml (although of course you'd have to copy an item; I'd reccomend one of the flowers or else mushrooms if you want a little bit more of a challenge).

BTW, that's a very very good tutorial you have there - you've explained almost every kind of modding possible at the moment in a very clear yet detailed manner. Bravo :D
What's that you're eating? A nice, juicy apple? You weren't supposed to eat that you fool, you were supposed to make it into a pie! - last words recorded words of Francis D'Avre before he went looking for snowcherries, but found a hungry Yeti instead.
User avatar
YetiChow
 
Posts: 3149
Joined: Wed Apr 25, 2012 9:26 am
Location: Cramped between a Yeti's small intestine and its stomach... trying not to dissolve!

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Effix » Thu Sep 06, 2012 8:47 am

Awesome, many thanks, I totally overlooked that campaigns folder. I tried it and a sheep is staring at my townies on a new map :D Included it in the tutorial.
User avatar
Effix
 
Posts: 178
Joined: Mon Jun 18, 2012 11:18 am
Location: The Netherlands

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Aduvash » Thu Sep 06, 2012 1:35 pm

Ah, it works, one problem, I can only harvest blueberry manually, if you don't understand, I mean that it works like how you can only cut down fruit trees if they have no fruit or if you right click on them.
You are a primitive human not an insult; a forum game. [Currently dead] Note that this was the first forum game on the towns forum, I'm a trend setter. :D
More Plants and Animals! [0.50]
Image
User avatar
Aduvash
 
Posts: 699
Joined: Mon Apr 30, 2012 1:17 pm
Location: New York State, USA

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Effix » Thu Sep 06, 2012 2:09 pm

Aduvash wrote:Ah, it works, one problem, I can only harvest blueberry manually, if you don't understand, I mean that it works like how you can only cut down fruit trees if they have no fruit or if you right click on them.


Did you copy the fruittree's code and edit that? Perhaps this came along with that somehow. Try using blue radish or something as a start.

Note that there's 3 different actions for radish, one is harvest a wild plant, one is harvest a planted plant and one is to get seed. Only harvest planted plant goes through the production menu.

menu_production.xml:
Code: Select all
<item code="QUEUE" parameter="qharvestpblueberry" />

(notice the letter P for 'planted')

actions:
Code: Select all
   <action>
      <id>qharvestblueberry</id>
      <name esES="Recolectar">Gather</name>
      <generatedItem>blueberry</generatedItem>
      <priorityID>gatheringharvesting</priorityID>
      <queue>
         <move useSource="true">blueberryplant</move>
         <wait>36</wait>
         <replaceCellItem>harvestingblueberryplant</replaceCellItem>
         <createItem>blueberry</createItem>
      </queue>
   </action>
   <action>
      <id>qharvestpblueberry</id>
      <name esES="Recolectar">Gather</name>
      <generatedItem>blueberry</generatedItem>
      <priorityID>gatheringharvesting</priorityID>
      <queue>
         <move useSource="true">plantedblueberryplant</move>
         <wait>36</wait>
         <replaceCellItem>plantedharvestingblueberryplant</replaceCellItem>
         <createItem>blueberry</createItem>
      </queue>
   </action>
   <action>
      <id>qblueberryseed</id>
      <name esES="Plantar semilla de rábano azul">Plant blue berry seedling</name>
      <priorityID>gatheringharvesting</priorityID>
      <queue>
         <pick>blueberry</pick>
         <wait>20</wait>
         <destroyItem />
         <createitem>blueberryseed</createitem>
      </queue>
   </action>


Hope that helps, good luck.
User avatar
Effix
 
Posts: 178
Joined: Mon Jun 18, 2012 11:18 am
Location: The Netherlands

Re: [DIY] Total Sheep Tutorial - Mob, Meat, Farm, Hide & Rug

Postby Aduvash » Thu Sep 06, 2012 2:34 pm

What's weird is that if you right click the blueberry and shift click gather you can mass gather the blueberries with that, only the button for it doesn't work. Also, in the action file my code looks pretty much the same as yours.

I honestly don't know, here's the data file and the graphics file, unzip a new version of towns and put those in, people who think they know what the problem is can troubleshoot, it doesn't break the mod but it's an inconvenience having to shift click them instead of clicking the button, anyhoo, here's the link:

If you figure it out you get a cookie.
The blueberry bush image is placeholder by the way.
You are a primitive human not an insult; a forum game. [Currently dead] Note that this was the first forum game on the towns forum, I'm a trend setter. :D
More Plants and Animals! [0.50]
Image
User avatar
Aduvash
 
Posts: 699
Joined: Mon Apr 30, 2012 1:17 pm
Location: New York State, USA

Next

Return to Released mods

Who is online

Users browsing this forum: No registered users and 0 guests

cron