Skip to content
Browse files

Merge pull request #4 from Arsakes/iron_smelting

Iron smelting
  • Loading branch information...
2 parents ddd9f47 + 24ce8e9 commit 9d8ce4178e37943cbf33c90f53faf030a07007dc @alriddoch alriddoch committed
View
27 data/buildings.xml
@@ -99,6 +99,31 @@
<string>structure</string>
</list>
</map>
+
+ <map>
+ <map name="attributes">
+ <map name="bbox">
+ <list name="default">
+ <float>-1.1575</float>
+ <float>-1.1225</float>
+ <float>-0.99</float>
+ <float>1.1575</float>
+ <float>1.1225</float>
+ <float>1.749</float>
+ </list>
+ <string name="visibility">public</string>
+ </map>
+ <map name="mass">
+ <float name="default">400</float>
+ <string name="visibility">public</string>
+ </map>
+ </map>
+ <string name="id">bloomery</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>structure</string>
+ </list>
+ </map>
<map>
<map name="attributes">
@@ -428,7 +453,7 @@
<string>structure</string>
</list>
</map>
-
+
<map>
<map name="attributes">
<map name="bbox">
View
99 data/construction.xml
@@ -72,7 +72,40 @@
<string>wall</string>
</list>
</map>
-
+
+ <map>
+ <map name="attributes">
+ <map name="bbox">
+ <list name="default">
+ <float>-0.1</float>
+ <float>-0.1</float>
+ <float>0</float>
+ <float>0.1</float>
+ <float>0.1</float>
+ <float>0.2</float>
+ </list>
+ <string name="visibility">public</string>
+ </map>
+ <map name="burn_speed">
+ <float name="default">1</float>
+ <string name="visibility">public</string>
+ </map>
+ <map name="mass">
+ <float name="default">2</float>
+ <string name="visibility">public</string>
+ </map>
+ <map name="material">
+ <string name="default">wood</string>
+ <string name="visibility">public</string>
+ </map>
+ </map>
+ <string name="id">charcoal</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>material</string>
+ </list>
+ </map>
+
<map>
<map name="attributes">
<map name="mass">
@@ -168,6 +201,68 @@
<float>0</float>
<float>0.1</float>
<float>0.1</float>
+ <float>0.2</float>
+ </list>
+ <string name="visibility">public</string>
+ </map>
+ <map name="burn_speed">
+ <float name="default">1</float>
+ <string name="visibility">public</string>
+ </map>
+ <map name="mass">
+ <float name="default">2</float>
+ <string name="visibility">public</string>
+ </map>
+ <map name="material">
+ <string name="default">stone</string>
+ <string name="visibility">public</string>
+ </map>
+ </map>
+ <string name="id">hematite</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>material</string>
+ </list>
+ </map>
+
+ <map>
+ <map name="attributes">
+ <map name="bbox">
+ <list name="default">
+ <float>-0.201</float>
+ <float>-0.069</float>
+ <float>0</float>
+ <float>0.201</float>
+ <float>0.069</float>
+ <float>0.062</float>
+ </list>
+ <string name="visibility">public</string>
+ </map>
+ <map name="burn_speed">
+ <float name="default">1</float>
+ <string name="visibility">public</string>
+ </map>
+ <map name="mass">
+ <float name="default">20</float>
+ <string name="visibility">public</string>
+ </map>
+ </map>
+ <string name="id">iron_ingot</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>material</string>
+ </list>
+ </map>
+
+ <map>
+ <map name="attributes">
+ <map name="bbox">
+ <list name="default">
+ <float>-0.1</float>
+ <float>-0.1</float>
+ <float>0</float>
+ <float>0.1</float>
+ <float>0.1</float>
<float>0.5</float>
</list>
<string name="visibility">public</string>
@@ -202,7 +297,7 @@
<string>thing</string>
</list>
</map>
-
+
<map>
<map name="attributes">
<map name="bbox">
View
10 data/operations.xml
@@ -1,5 +1,5 @@
<atlas>
-
+
<map>
<string name="id">chop</string>
<string name="objtype">op_definition</string>
@@ -47,6 +47,14 @@
<string>root_operation</string>
</list>
</map>
+
+ <map>
+ <string name="id">earthwork_bloomery</string>
+ <string name="objtype">op_definition</string>
+ <list name="parents">
+ <string>root_operation</string>
+ </list>
+ </map>
<map>
<string name="id">extinguish</string>
View
42 data/tasks.xml
@@ -1,5 +1,5 @@
<atlas>
-
+
<map>
<map name="activation">
<string name="operation">craft</string>
@@ -37,6 +37,25 @@
<string name="name">world.tasks.Bisect.Bisect</string>
</map>
</map>
+
+ <map>
+ <map name="activation">
+ <string name="operation">earthwork_bloomery</string>
+ <string name="target">world</string>
+ <string name="tool">shovel</string>
+ </map>
+ <map name="attributes">
+ </map>
+ <string name="id">build_bloomery</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>task</string>
+ </list>
+ <map name="script">
+ <string name="language">python</string>
+ <string name="name">world.tasks.BuildBloomery.BuildBloomery</string>
+ </map>
+ </map>
<map>
<map name="activation">
@@ -93,7 +112,7 @@
<string name="name">world.tasks.Delve.Delve</string>
</map>
</map>
-
+
<map>
<map name="activation">
<string name="operation">attack</string>
@@ -248,6 +267,25 @@
<map>
<map name="activation">
+ <string name="operation">craft</string>
+ <string name="target">bloomery</string>
+ <string name="tool">tongs</string>
+ </map>
+ <map name="attributes">
+ </map>
+ <string name="id">iron_smelting</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>task</string>
+ </list>
+ <map name="script">
+ <string name="language">python</string>
+ <string name="name">world.tasks.IronSmelting.IronSmelting</string>
+ </map>
+ </map>
+
+ <map>
+ <map name="activation">
<string name="operation">cut</string>
<string name="target">tree</string>
<string name="tool">axe</string>
View
25 data/tools.xml
@@ -431,6 +431,31 @@
<map name="attributes">
<map name="bbox">
<list name="default">
+ <float>-0.075</float>
+ <float>-0.008</float>
+ <float>-0.062</float>
+ <float>0.075</float>
+ <float>0.008</float>
+ <float>0.484</float>
+ </list>
+ <string name="visibility">public</string>
+ </map>
+ <map name="mass">
+ <float name="default">1.5</float>
+ <string name="visibility">public</string>
+ </map>
+ </map>
+ <string name="id">tongs</string>
+ <string name="objtype">class</string>
+ <list name="parents">
+ <string>thing</string>
+ </list>
+ </map>
+
+ <map>
+ <map name="attributes">
+ <map name="bbox">
+ <list name="default">
<float>0.05</float>
<float>0.05</float>
<float>1</float>
View
101 rulesets/mason/world/tasks/BuildBloomery.py
@@ -0,0 +1,101 @@
+#This file is distributed under the terms of the GNU General Public license.
+#Copyright (C) 2011 Peter <elminister@interia.pl> (See the file COPYING for details).
+
+#NOT YET READY
+
+from atlas import *
+from physics import *
+from physics import Quaternion
+from physics import Point3D
+from physics import Vector3D
+
+import server
+
+class BuildBloomery(server.Task):
+ """A task for creating a Bloomery by consuming 1 charcoal, 1 hematite and 1 pile of earth"""
+
+ def earthwork_bloomery_operation(self, op):
+ """ Op handler for bloomery op which activates this task """
+
+ if len(op) < 1:
+ sys.stderr.write("Bloomery_build task has no target in bloomery_build op")
+
+ # FIXME Use weak references, once we have them
+ self.target = server.world.get_object_ref(op[0].id)
+ self.tool = op.to
+
+ self.pos = Point3D(op[0].pos)
+
+ def tick_operation(self, op):
+
+ """ Op handler for regular tick op """
+ target=self.target()
+ if not target:
+ # print "Target is no more"
+ self.irrelevant()
+ return
+
+ self.rate = 0.5 / 0.75
+ self.progress += 1
+
+ if not target:
+ print "Target is no more"
+ self.irrelevant()
+ return
+
+ res=Oplist()
+
+ if self.progress < 1:
+ # print "Not done yet"
+ return self.next_tick(0.75)
+
+ self.progress = 0
+ # counter for charcal, hematite and pilef of earth
+ charcoal_count = 0
+ hematite_count = 0
+ earth_count = 0
+ count = 0
+ # List which stores the to be consumed entities
+ raw_materials = []
+
+ # Make sure only 1 part of each attribute is being consumed as per the recipe.
+ for item in self.character.contains:
+ if item.type[0] == str("hematite"):
+ if hematite_count <= 0 :
+ raw_materials.append(item)
+ hematite_count = hematite_count + 1
+ if item.type[0] == str("charcoal"):
+ if charcoal_count <= 0 :
+ raw_materials.append(item)
+ charcoal_count = charcoal_count + 1
+ #we accept only piles of earth not dirt or some other shit
+ if item.type[0] == str("pile") and item.material == str("earth"):
+ print "Pile of earth was found in inventory"
+ if earth_count <= 0 :
+ raw_materials.append(item)
+ earth_count = earth_count + 1
+ if (hematite_count+charcoal_count+earth_count) == 3 :
+ break
+ else:
+ print "No materials in inventory"
+ self.irrelevant()
+ return
+
+ chunk_loc = target.location.copy()
+ chunk_loc.coordinates = target.location.coordinates
+ chunk_loc.orientation = target.location.orientation
+
+ count = earth_count + charcoal_count + hematite_count
+
+ # consume the materials stores in the list raw_materials
+ while (count > 0) :
+ tar = raw_materials.pop()
+ set = Operation("set", Entity(tar.id, status = -1), to = tar)
+ res.append(set)
+ count = count - 1
+
+ create=Operation("create", Entity(name = "bloomery", type = "bloomery", location = chunk_loc), to = target)
+ res.append(create)
+ self.progress = 1
+ self.irrelevant()
+ return res
View
66 rulesets/mason/world/tasks/IronSmelting.py
@@ -0,0 +1,66 @@
+#This file is distributed under the terms of the GNU General Public license.
+#Copyright (C) 2011 Peter <elminister@interia.pl> (See the file COPYING for details).
+
+
+
+from atlas import *
+from physics import *
+from physics import Quaternion
+from physics import Point3D
+from physics import Vector3D
+
+import server
+
+class IronSmelting(server.Task):
+ """A task for making iron in bloomery"""
+
+ def craft_operation(self, op):
+ """ Op handler for crafting op which activates this task """
+
+ if len(op) < 1:
+ sys.stderr.write("IronSmelting task has no target in crafting op")
+
+ # FIXME Use weak references, once we have them
+ self.target = server.world.get_object_ref(op[0].id)
+ self.tool = op.to
+
+ def tick_operation(self, op):
+
+ """ Op handler for regular tick op """
+ if self.target() is None:
+ # print "Target is no more"
+ self.irrelevant()
+ return
+
+ self.rate = 0.1 / 0.75
+ self.progress += 0.1
+ bloomery_location = self.target().location.copy()
+
+ res=Oplist()
+
+ if square_distance(self.character.location, self.target().location) > self.target().location.bbox.square_bounding_radius() + 0.1:
+ self.rate = 0
+ self.progress -= 0.1
+ # no progress
+
+ if self.progress < 1:
+ # print "Not done yet"
+ return self.next_tick(0.75)
+
+
+ # Destroy bloomery, bloomeries were for single use only!
+ set = Operation("set", Entity(self.target().id, status = -1), to = self.target())
+ res.append(set)
+
+
+ # A bit naive iron ingot can not be made without anvil & hammer but..
+
+ # Create iron stab in place of bloomery
+ print "Trying to create iron ingot"
+ create = Operation("create", Entity(name = "iron_ingot", type = "iron_ingot"), to = self.character )
+ res.append(create)
+
+ self.progress = 1
+ self.irrelevant()
+
+ return res

0 comments on commit 9d8ce41

Please sign in to comment.
Something went wrong with that request. Please try again.