essytas 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. data/LICENSE +19 -0
  2. data/README +3 -0
  3. data/Rakefile +44 -0
  4. data/bin/essytas +2 -0
  5. data/lib/animation.rb +74 -0
  6. data/lib/config.rb +63 -0
  7. data/lib/core.rb +242 -0
  8. data/lib/cursor.rb +43 -0
  9. data/lib/def/animations/explosion1.anim +103 -0
  10. data/lib/def/characters.def +132 -0
  11. data/lib/def/de/dialogues/test.dlg +4 -0
  12. data/lib/def/de/enemies.trans +6 -0
  13. data/lib/def/de/items.trans +84 -0
  14. data/lib/def/de/skills.trans +48 -0
  15. data/lib/def/de/spells.trans +31 -0
  16. data/lib/def/en/dialogues/test.dlg +4 -0
  17. data/lib/def/en/enemies.trans +6 -0
  18. data/lib/def/en/items.trans +78 -0
  19. data/lib/def/en/skills.trans +48 -0
  20. data/lib/def/en/spells.trans +31 -0
  21. data/lib/def/enemies.def +8 -0
  22. data/lib/def/enemies/wolf.bhv +11 -0
  23. data/lib/def/init.def +5 -0
  24. data/lib/def/items.def +153 -0
  25. data/lib/def/loot.def +2 -0
  26. data/lib/def/particles.def +66 -0
  27. data/lib/def/recipies.def +18 -0
  28. data/lib/def/skills.def +40 -0
  29. data/lib/def/spells.def +42 -0
  30. data/lib/def/spells.rb +16 -0
  31. data/lib/def/weapons.def +9 -0
  32. data/lib/ext/astar/AMap.rb +146 -0
  33. data/lib/ext/astar/node.rb +72 -0
  34. data/lib/ext/astar/priority_queue.rb +44 -0
  35. data/lib/ext/shader.rb +116 -0
  36. data/lib/game/alchemy/recipe.rb +26 -0
  37. data/lib/game/character.rb +102 -0
  38. data/lib/game/combat/bar.rb +119 -0
  39. data/lib/game/combat/battle.rb +345 -0
  40. data/lib/game/combat/control.rb +18 -0
  41. data/lib/game/combat/gui.rb +190 -0
  42. data/lib/game/combat/gui/select_item.rb +11 -0
  43. data/lib/game/combat/gui/select_spell.rb +38 -0
  44. data/lib/game/constitution.rb +48 -0
  45. data/lib/game/equipment.rb +34 -0
  46. data/lib/game/inventory.rb +37 -0
  47. data/lib/game/item.rb +54 -0
  48. data/lib/game/magic.rb +33 -0
  49. data/lib/game/map/events.rb +29 -0
  50. data/lib/game/map/fog.rb +41 -0
  51. data/lib/game/map/map.rb +247 -0
  52. data/lib/game/map/map_animation.rb +26 -0
  53. data/lib/game/map/map_loader.rb +177 -0
  54. data/lib/game/map/map_object.rb +208 -0
  55. data/lib/game/map/map_particle.rb +27 -0
  56. data/lib/game/map/player.rb +78 -0
  57. data/lib/game/map/tile.rb +35 -0
  58. data/lib/game/mind.rb +24 -0
  59. data/lib/game/npc/behaviour.rb +45 -0
  60. data/lib/game/npc/bubble.rb +28 -0
  61. data/lib/game/npc/goal.rb +93 -0
  62. data/lib/game/npc/npc.rb +95 -0
  63. data/lib/game/npc/task.rb +73 -0
  64. data/lib/game/osd/magic.rb +24 -0
  65. data/lib/game/party.rb +42 -0
  66. data/lib/game/skills.rb +64 -0
  67. data/lib/game/spell.rb +35 -0
  68. data/lib/game_window.rb +95 -0
  69. data/lib/glsl/contrast.frag +12 -0
  70. data/lib/glsl/fade.frag +11 -0
  71. data/lib/glsl/mezzotint.frag +20 -0
  72. data/lib/glsl/noise.frag +20 -0
  73. data/lib/glsl/pixelate.frag +42 -0
  74. data/lib/glsl/radialblur.frag +28 -0
  75. data/lib/glsl/sepia.frag +15 -0
  76. data/lib/glsl/shockwave.frag +24 -0
  77. data/lib/glsl/tv_screen.frag +17 -0
  78. data/lib/graphics/animations/credits.txt +1 -0
  79. data/lib/graphics/animations/explosion2.png +0 -0
  80. data/lib/graphics/backgrounds/white_ties_grass.png +0 -0
  81. data/lib/graphics/chars/ejera.png +0 -0
  82. data/lib/graphics/chars/salyjea.png +0 -0
  83. data/lib/graphics/chars/tharat.png +0 -0
  84. data/lib/graphics/combat/tharat.png +0 -0
  85. data/lib/graphics/cursors/normal.png +0 -0
  86. data/lib/graphics/fog/clouds1.png +0 -0
  87. data/lib/graphics/gui/bar_center.png +0 -0
  88. data/lib/graphics/gui/bar_left.png +0 -0
  89. data/lib/graphics/gui/bar_right.png +0 -0
  90. data/lib/graphics/gui/button_background.png +0 -0
  91. data/lib/graphics/gui/button_close.png +0 -0
  92. data/lib/graphics/gui/button_close_hi.png +0 -0
  93. data/lib/graphics/gui/button_highlight.png +0 -0
  94. data/lib/graphics/gui/charequip_background.png +0 -0
  95. data/lib/graphics/gui/charselect_background.png +0 -0
  96. data/lib/graphics/gui/container_background.png +0 -0
  97. data/lib/graphics/gui/drop_item.png +0 -0
  98. data/lib/graphics/gui/equip_Etarae.png +0 -0
  99. data/lib/graphics/gui/equip_Mensch.png +0 -0
  100. data/lib/graphics/gui/equipslot_background.png +0 -0
  101. data/lib/graphics/gui/iteminfo_background.png +0 -0
  102. data/lib/graphics/gui/msg_background.png +0 -0
  103. data/lib/graphics/gui/scrollbar_background.png +0 -0
  104. data/lib/graphics/gui/scroller.png +0 -0
  105. data/lib/graphics/gui/tile_32.png +0 -0
  106. data/lib/graphics/gui/tile_32_highlight.png +0 -0
  107. data/lib/graphics/icons/items/arrow.png +0 -0
  108. data/lib/graphics/icons/items/bandage.png +0 -0
  109. data/lib/graphics/icons/items/boots_leather.png +0 -0
  110. data/lib/graphics/icons/items/bow.png +0 -0
  111. data/lib/graphics/icons/items/credits.txt +8 -0
  112. data/lib/graphics/icons/items/harness_leather.png +0 -0
  113. data/lib/graphics/icons/items/knife.png +0 -0
  114. data/lib/graphics/icons/items/shirt_linen.png +0 -0
  115. data/lib/graphics/items/none.png +0 -0
  116. data/lib/graphics/menu/ingame_background.png +0 -0
  117. data/lib/graphics/menu/ingame_background.xcf +0 -0
  118. data/lib/graphics/menu/start_background.png +0 -0
  119. data/lib/graphics/missing.png +0 -0
  120. data/lib/graphics/osd/magic_bg.png +0 -0
  121. data/lib/graphics/particles/leaf.png +0 -0
  122. data/lib/graphics/particles/smoke.png +0 -0
  123. data/lib/graphics/pixel.png +0 -0
  124. data/lib/graphics/tiles/test.png +0 -0
  125. data/lib/gui/base.rb +278 -0
  126. data/lib/gui/button.rb +93 -0
  127. data/lib/gui/char_equip.rb +118 -0
  128. data/lib/gui/char_selector.rb +54 -0
  129. data/lib/gui/context_menu.rb +115 -0
  130. data/lib/gui/draggable.rb +18 -0
  131. data/lib/gui/grid.rb +118 -0
  132. data/lib/gui/image.rb +17 -0
  133. data/lib/gui/inventory.rb +42 -0
  134. data/lib/gui/item_info.rb +33 -0
  135. data/lib/gui/slider.rb +10 -0
  136. data/lib/gui/textfield.rb +57 -0
  137. data/lib/layer.rb +64 -0
  138. data/lib/load.rb +31 -0
  139. data/lib/main.rb +18 -0
  140. data/lib/maps/def/test.bhv +26 -0
  141. data/lib/maps/def/test.rb +14 -0
  142. data/lib/maps/test.tmx +133 -0
  143. data/lib/maps/test2.tmx +94 -0
  144. data/lib/maps/test3.tmx +29 -0
  145. data/lib/maps/test3_lower.tmx +25 -0
  146. data/lib/maps/test3_upper.tmx +25 -0
  147. data/lib/maps/test_left.tmx +25 -0
  148. data/lib/maps/test_upper.tmx +25 -0
  149. data/lib/music/Butterfly Tea - A New Hope 2K11.mp3 +0 -0
  150. data/lib/music/Greendjohn - Rebirth.mp3 +0 -0
  151. data/lib/music/credits.txt +8 -0
  152. data/lib/parse.rb +605 -0
  153. data/lib/parse_tmx.rb +114 -0
  154. data/lib/particles.rb +127 -0
  155. data/lib/sample.rb +29 -0
  156. data/lib/save.rb +44 -0
  157. data/lib/song.rb +41 -0
  158. data/lib/sounds/click1.wav +0 -0
  159. data/lib/sounds/credits.txt +2 -0
  160. data/lib/sounds/error1.wav +0 -0
  161. data/lib/sprite.rb +35 -0
  162. data/lib/states/menus.rb +17 -0
  163. data/lib/states/menus/alchemy.rb +53 -0
  164. data/lib/states/menus/equip.rb +79 -0
  165. data/lib/states/menus/ingame.rb +34 -0
  166. data/lib/states/menus/magic.rb +31 -0
  167. data/lib/states/menus/options.rb +54 -0
  168. data/lib/states/menus/start.rb +38 -0
  169. data/lib/states/states.rb +154 -0
  170. data/lib/tileset.rb +42 -0
  171. data/lib/tools/world.rb +103 -0
  172. data/lib/tools/worldmap_editor.rb +221 -0
  173. data/lib/translate.rb +368 -0
  174. metadata +255 -0
@@ -0,0 +1,18 @@
1
+
2
+ module Core::Game::Combat
3
+
4
+ # Used for scripted battles (dialogues and stuff)
5
+ class Control
6
+ def initialize(battle)
7
+ @battle = nil
8
+ end
9
+ def battle=(b)
10
+ @battle = b
11
+ end
12
+ def update
13
+ end
14
+ def draw
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,190 @@
1
+
2
+ require_relative "gui/select_spell.rb"
3
+ require_relative "gui/select_item.rb"
4
+
5
+ module Core::Game::Combat
6
+
7
+ class GUI
8
+
9
+ attr_reader :attacking, :casting, :using
10
+
11
+ def initialize
12
+ @x = 0
13
+ @y = 544
14
+ @z = 5000
15
+ @bg = Core.sprite("gui/battle_infoback")
16
+ @w = {} # Currently shown windows
17
+ @ready = []
18
+ @paused = false
19
+ @chosen = @choose = nil
20
+ @attacking = []
21
+ @casting = []
22
+ @using = []
23
+ @add = {}
24
+ end
25
+
26
+ def push(type, *parms)
27
+ case type
28
+ when :ready
29
+ ready(parms)
30
+ end
31
+ end
32
+
33
+ def open_info(obj, x, y)
34
+ if @choose and !@chosen
35
+ @chosen = obj
36
+ else
37
+ if Core.config[:combat_gui_info_window_x]
38
+ x = Core.config[:combat_gui_info_window_x]
39
+ end
40
+ if Core.config[:combat_gui_info_window_y]
41
+ y = Core.config[:combat_gui_info_window_y]
42
+ end
43
+ @w[:info] = Core::GUI::Window.new(x, y, 320, 256, "Info", true, "gui/container_background", true)
44
+ @w[:info].add(:text, Core::GUI::Textfield.new(8, 8, 304, 240, "#{obj}"))
45
+ @w[:info].title = "#{Core::Trans.enemy(obj.data.name)}"
46
+ @w[:info].save_pos(:combat_gui_info_window_x, :combat_gui_info_window_y)
47
+ end
48
+ end
49
+
50
+ def update
51
+ @w.each_value { |w|
52
+ w.update
53
+ if w.remove?
54
+ @w.delete(@w.key(w))
55
+ end
56
+ }
57
+ @add.each do |k, v|
58
+ @w.store(k, v)
59
+ end
60
+ @add = {}
61
+ w = @w[:select_spell]
62
+ if w and w.selected
63
+ @choose = lambda { cast(w.actor, @chosen, w.selected) }
64
+ end
65
+ if @choose and @chosen
66
+ @choose.call
67
+ end
68
+ end
69
+
70
+ def draw
71
+ @bg.draw(@x, @y, @z, 1024/@bg.width.to_f, 224/@bg.height.to_f)
72
+ @w.each_value { |w|
73
+ w.draw
74
+ }
75
+ end
76
+
77
+ def paused?
78
+ return @paused
79
+ end
80
+
81
+ def attacked
82
+ @attacking = []
83
+ end
84
+
85
+ def spell_cast
86
+ @casting = []
87
+ end
88
+
89
+ def item_used
90
+ @using = []
91
+ end
92
+
93
+ def abort_action(actor)
94
+ @paused = false
95
+ @choose = nil
96
+ @chosen = nil
97
+ @w[:select_spell].close! if @w[:select_spell]
98
+ @w[:select_item].close! if @w[:select_item]
99
+ setup_ready_actions(actor)
100
+ end
101
+
102
+ private
103
+
104
+ def attack(attacker, target)
105
+ @attacking = [attacker, target]
106
+ shift_ready
107
+ abort_action(@ready.first)
108
+ end
109
+
110
+ def cast(attacker, target, spell)
111
+ @casting = [attacker, target, spell]
112
+ shift_ready
113
+ abort_action(@ready.first)
114
+ end
115
+
116
+ def use(attacker, target, item)
117
+ @using = [attacker, target, item]
118
+ shift_ready
119
+ abort_action(@ready.first)
120
+ end
121
+
122
+ def ready(ary)
123
+ actor = ary.first
124
+ char = actor.character
125
+ if @ready.empty?
126
+ @w[:ready] = Core::GUI::Window.new(768, @y, 256, 224, char.name, false, "gui/container_background")
127
+ setup_ready_actions(actor)
128
+ end
129
+ @ready.push(actor)
130
+ end
131
+
132
+ def shift_ready
133
+ if @ready.empty?
134
+ @w.delete(:ready)
135
+ else
136
+ @ready.shift
137
+ if @ready.empty?
138
+ @w[:ready].close!
139
+ else
140
+ @w[:ready].title = @ready.first.character.name
141
+ setup_ready_actions(@ready.first.character)
142
+ end
143
+ end
144
+ end
145
+
146
+ def setup_ready_actions(actor)
147
+ w = @w[:ready]
148
+ w.empty
149
+ w.add(:attack, Core::GUI::Button.new(8, 8, 240, 32, Core::Trans.menu(:attack), lambda {open_attack(actor)}))
150
+ w.add(:skill, Core::GUI::Button.new(8, 48, 240, 32, Core::Trans.menu(:magic), lambda {open_spell(actor)}))
151
+ w.add(:item, Core::GUI::Button.new(8, 88, 240, 32, Core::Trans.menu(:item), lambda {open_item(actor)}))
152
+ end
153
+
154
+ def open_attack(actor)
155
+ @paused = true
156
+ @choose = lambda { attack(actor, @chosen) }
157
+ open_abort(actor)
158
+ end
159
+
160
+ def open_spell(actor)
161
+ @paused = true
162
+ if Core.config[:combat_gui_spell_select_window_x]
163
+ x = Core.config[:combat_gui_spell_select_window_x]
164
+ else
165
+ x = 192
166
+ end
167
+ if Core.config[:combat_gui_spell_select_window_y]
168
+ y = Core.config[:combat_gui_spell_select_window_y]
169
+ else
170
+ y = 192
171
+ end
172
+ @add.store(:select_spell, SelectSpell.new(x, y, actor))
173
+ @add[:select_spell].parent = self
174
+ open_abort(actor)
175
+ end
176
+
177
+ def open_item(actor)
178
+ puts("STUB: GUI.open_item")
179
+ @paused = true
180
+ open_abort(actor)
181
+ end
182
+
183
+ def open_abort(actor)
184
+ @w[:ready].empty
185
+ @w[:ready].add(:abort, Core::GUI::Button.new(8, 8, 240, 32, Core::Trans.menu(:abort), lambda {abort_action(actor)}))
186
+ end
187
+
188
+ end
189
+
190
+ end
@@ -0,0 +1,11 @@
1
+
2
+ module Core::Game::Combat
3
+
4
+ class SelectItem < Core::GUI::Window
5
+
6
+ def initialize(x, y, actor)
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -0,0 +1,38 @@
1
+
2
+ module Core::Game::Combat
3
+
4
+ class SelectSpell < Core::GUI::Window
5
+
6
+ attr_reader :selected, :actor
7
+
8
+ def initialize(x, y, actor)
9
+ super(x, y, 384, 256, Core::Trans.menu(:select_spell), true, "gui/container_background", true)
10
+ @close.proc = lambda { close!; @parent.abort_action(actor) }
11
+ save_pos(:combat_gui_spell_select_window_x, :combat_gui_spell_select_window_y)
12
+ add(:container, Core::GUI::Container.new(8, 8, 184, 240, 24))
13
+ add(:info, Core::GUI::Textfield.new(200, 8, 176, 240, ""))
14
+ @actor = actor
15
+ setup_skill_select
16
+ @selected = nil
17
+ end
18
+
19
+ private
20
+
21
+ def setup_skill_select
22
+ char = @actor.character
23
+ c = get(:container)
24
+ y = 8
25
+ char.spells.each { |spell, level|
26
+ c.add(Core::GUI::Button.new(0, y, c.w-24, c.ch, Core::Trans.spell(spell.name), lambda { clicked(spell) }))
27
+ y += c.ch
28
+ }
29
+ end
30
+
31
+ def clicked(spell)
32
+ get(:info).text = Core::Trans.spell("#{spell.name}_desc".to_sym)
33
+ @selected = spell
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,48 @@
1
+
2
+ module Core::Game
3
+ WOUND_LOCATIONS = [:head, :neck, :torso, :abdomen, :leg, :foot, :arm]
4
+ class Wound
5
+ attr_reader :location, :severity
6
+ def initialize(location, severity)
7
+ if !WOUND_LOCATIONS.include?(location)
8
+ puts("WARNING: Unknown wound location #{location}")
9
+ end
10
+ @location = location
11
+ @severity = severity
12
+ end
13
+ def location_factor
14
+ case @location
15
+ when :head
16
+ return 5
17
+ when :neck
18
+ return 3
19
+ when :torso
20
+ return 2
21
+ when :abdomen
22
+ return 3
23
+ when :leg
24
+ return 1
25
+ when :foot
26
+ return 1
27
+ when :arm
28
+ return 2
29
+ else
30
+ return 1
31
+ end
32
+ end
33
+ end
34
+
35
+ class Constitution
36
+ def initialize
37
+ @wounds = []
38
+ end
39
+ # this should only be called when needed
40
+ def update(char)
41
+ str = char.strength
42
+ dmg = 0
43
+ @wounds.each { |w|
44
+ dmg += w.severity * w.location_factor
45
+ }
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,34 @@
1
+
2
+ module Core::Game
3
+ class Equipment < Hash
4
+ @@locations = [
5
+ :head,
6
+ :torso,
7
+ :larm,
8
+ :rarm,
9
+ :legs,
10
+ :feet,
11
+ :back,
12
+ ]
13
+ def initialize
14
+ super
15
+ end
16
+ def equip(item, location, inventory)
17
+ if @@locations.include?(location)
18
+ inventory.remove(item)
19
+ ret = self[location]
20
+ inventory.add(ret) if ret
21
+ self.store(location, item)
22
+ return ret
23
+ end
24
+ end
25
+ def remove_at(location)
26
+ ret = self[location]
27
+ self[location] = nil
28
+ return ret
29
+ end
30
+ def at(loc)
31
+ return self[loc]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,37 @@
1
+
2
+ module Core::Game
3
+ # strength is an arbitrary unit; in this context it's 1 str == 1 kg of carrying
4
+ class Inventory < Array
5
+ attr_accessor :capacity, :strength
6
+ def initialize(capacity, strength)
7
+ super(capacity)
8
+ @capacity = capacity
9
+ @strength = strength
10
+ self.clear
11
+ end
12
+ def add(item)
13
+ if self.size + 1 < @capacity and item.weight + weight < @strength
14
+ self.push(item)
15
+ end
16
+ end
17
+ def remove(item, times=1)
18
+ removed = 0
19
+ self.each { |other_item|
20
+ if other_item.name == item.name
21
+ self.delete_at(self.index(other_item))
22
+ removed += 1
23
+ end
24
+ if removed >= times
25
+ return
26
+ end
27
+ }
28
+ end
29
+ def weight
30
+ weight = 0
31
+ self.each { |item|
32
+ weight += item.weight
33
+ }
34
+ return weight
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,54 @@
1
+
2
+ module Core::Game
3
+
4
+ class Item
5
+ attr_reader :name, :desc, :icon, :weight, :effects, :type, :img
6
+ attr_reader :icon_file
7
+ end
8
+
9
+ def self.items
10
+ return @items
11
+ end
12
+
13
+ def self.items=(ary)
14
+ @items = ary
15
+ end
16
+
17
+ def self.find_item(name)
18
+ @items.each { |item|
19
+ if item.name == name
20
+ return item
21
+ end
22
+ }
23
+ end
24
+
25
+ def self.itemtype_to_locations(type, equip)
26
+ ary = []
27
+ case type
28
+ when :armor
29
+ ary = [:torso]
30
+ when :cloth
31
+ ary = [:torso]
32
+ when :melee
33
+ ary = []
34
+ if equip.at(:rarm) != nil and equip.at(:rarm).type != :ranged
35
+ ary = [:larm, :rarm]
36
+ elsif equip.at(:rarm) == nil
37
+ ary = [:larm, :rarm]
38
+ end
39
+ when :pants
40
+ ary = [:legs]
41
+ when :boots
42
+ ary = [:feet]
43
+ when :ranged
44
+ ary = [:back]
45
+ if equip.at(:larm) == nil
46
+ ary.push(:rarm)
47
+ end
48
+ when :ammo
49
+ ary = [:back]
50
+ end
51
+ return ary
52
+ end
53
+
54
+ end
@@ -0,0 +1,33 @@
1
+
2
+ # Characters use this class to manage spells and casting
3
+
4
+ module Core::Game
5
+
6
+ class Magic
7
+ attr_reader :learned
8
+ def initialize(char)
9
+ @char = char
10
+ @learned = []
11
+ end
12
+
13
+ def learn(spell)
14
+ @learned.push(spell) if !@learned.include?(spell)
15
+ end
16
+
17
+ def forget(spell)
18
+ @learned.delete(spell)
19
+ end
20
+
21
+ def cast(spell, caster, target=nil)
22
+ if @learned.include?(spell) and @char.state == Core::Game::NORMAL
23
+ spell.cast(caster, target)
24
+ end
25
+ end
26
+
27
+ def cast_named(name, caster, target=nil)
28
+ cast(Core::Game.find_spell(name), caster, target)
29
+ end
30
+
31
+ end
32
+
33
+ end