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.
- data/LICENSE +19 -0
- data/README +3 -0
- data/Rakefile +44 -0
- data/bin/essytas +2 -0
- data/lib/animation.rb +74 -0
- data/lib/config.rb +63 -0
- data/lib/core.rb +242 -0
- data/lib/cursor.rb +43 -0
- data/lib/def/animations/explosion1.anim +103 -0
- data/lib/def/characters.def +132 -0
- data/lib/def/de/dialogues/test.dlg +4 -0
- data/lib/def/de/enemies.trans +6 -0
- data/lib/def/de/items.trans +84 -0
- data/lib/def/de/skills.trans +48 -0
- data/lib/def/de/spells.trans +31 -0
- data/lib/def/en/dialogues/test.dlg +4 -0
- data/lib/def/en/enemies.trans +6 -0
- data/lib/def/en/items.trans +78 -0
- data/lib/def/en/skills.trans +48 -0
- data/lib/def/en/spells.trans +31 -0
- data/lib/def/enemies.def +8 -0
- data/lib/def/enemies/wolf.bhv +11 -0
- data/lib/def/init.def +5 -0
- data/lib/def/items.def +153 -0
- data/lib/def/loot.def +2 -0
- data/lib/def/particles.def +66 -0
- data/lib/def/recipies.def +18 -0
- data/lib/def/skills.def +40 -0
- data/lib/def/spells.def +42 -0
- data/lib/def/spells.rb +16 -0
- data/lib/def/weapons.def +9 -0
- data/lib/ext/astar/AMap.rb +146 -0
- data/lib/ext/astar/node.rb +72 -0
- data/lib/ext/astar/priority_queue.rb +44 -0
- data/lib/ext/shader.rb +116 -0
- data/lib/game/alchemy/recipe.rb +26 -0
- data/lib/game/character.rb +102 -0
- data/lib/game/combat/bar.rb +119 -0
- data/lib/game/combat/battle.rb +345 -0
- data/lib/game/combat/control.rb +18 -0
- data/lib/game/combat/gui.rb +190 -0
- data/lib/game/combat/gui/select_item.rb +11 -0
- data/lib/game/combat/gui/select_spell.rb +38 -0
- data/lib/game/constitution.rb +48 -0
- data/lib/game/equipment.rb +34 -0
- data/lib/game/inventory.rb +37 -0
- data/lib/game/item.rb +54 -0
- data/lib/game/magic.rb +33 -0
- data/lib/game/map/events.rb +29 -0
- data/lib/game/map/fog.rb +41 -0
- data/lib/game/map/map.rb +247 -0
- data/lib/game/map/map_animation.rb +26 -0
- data/lib/game/map/map_loader.rb +177 -0
- data/lib/game/map/map_object.rb +208 -0
- data/lib/game/map/map_particle.rb +27 -0
- data/lib/game/map/player.rb +78 -0
- data/lib/game/map/tile.rb +35 -0
- data/lib/game/mind.rb +24 -0
- data/lib/game/npc/behaviour.rb +45 -0
- data/lib/game/npc/bubble.rb +28 -0
- data/lib/game/npc/goal.rb +93 -0
- data/lib/game/npc/npc.rb +95 -0
- data/lib/game/npc/task.rb +73 -0
- data/lib/game/osd/magic.rb +24 -0
- data/lib/game/party.rb +42 -0
- data/lib/game/skills.rb +64 -0
- data/lib/game/spell.rb +35 -0
- data/lib/game_window.rb +95 -0
- data/lib/glsl/contrast.frag +12 -0
- data/lib/glsl/fade.frag +11 -0
- data/lib/glsl/mezzotint.frag +20 -0
- data/lib/glsl/noise.frag +20 -0
- data/lib/glsl/pixelate.frag +42 -0
- data/lib/glsl/radialblur.frag +28 -0
- data/lib/glsl/sepia.frag +15 -0
- data/lib/glsl/shockwave.frag +24 -0
- data/lib/glsl/tv_screen.frag +17 -0
- data/lib/graphics/animations/credits.txt +1 -0
- data/lib/graphics/animations/explosion2.png +0 -0
- data/lib/graphics/backgrounds/white_ties_grass.png +0 -0
- data/lib/graphics/chars/ejera.png +0 -0
- data/lib/graphics/chars/salyjea.png +0 -0
- data/lib/graphics/chars/tharat.png +0 -0
- data/lib/graphics/combat/tharat.png +0 -0
- data/lib/graphics/cursors/normal.png +0 -0
- data/lib/graphics/fog/clouds1.png +0 -0
- data/lib/graphics/gui/bar_center.png +0 -0
- data/lib/graphics/gui/bar_left.png +0 -0
- data/lib/graphics/gui/bar_right.png +0 -0
- data/lib/graphics/gui/button_background.png +0 -0
- data/lib/graphics/gui/button_close.png +0 -0
- data/lib/graphics/gui/button_close_hi.png +0 -0
- data/lib/graphics/gui/button_highlight.png +0 -0
- data/lib/graphics/gui/charequip_background.png +0 -0
- data/lib/graphics/gui/charselect_background.png +0 -0
- data/lib/graphics/gui/container_background.png +0 -0
- data/lib/graphics/gui/drop_item.png +0 -0
- data/lib/graphics/gui/equip_Etarae.png +0 -0
- data/lib/graphics/gui/equip_Mensch.png +0 -0
- data/lib/graphics/gui/equipslot_background.png +0 -0
- data/lib/graphics/gui/iteminfo_background.png +0 -0
- data/lib/graphics/gui/msg_background.png +0 -0
- data/lib/graphics/gui/scrollbar_background.png +0 -0
- data/lib/graphics/gui/scroller.png +0 -0
- data/lib/graphics/gui/tile_32.png +0 -0
- data/lib/graphics/gui/tile_32_highlight.png +0 -0
- data/lib/graphics/icons/items/arrow.png +0 -0
- data/lib/graphics/icons/items/bandage.png +0 -0
- data/lib/graphics/icons/items/boots_leather.png +0 -0
- data/lib/graphics/icons/items/bow.png +0 -0
- data/lib/graphics/icons/items/credits.txt +8 -0
- data/lib/graphics/icons/items/harness_leather.png +0 -0
- data/lib/graphics/icons/items/knife.png +0 -0
- data/lib/graphics/icons/items/shirt_linen.png +0 -0
- data/lib/graphics/items/none.png +0 -0
- data/lib/graphics/menu/ingame_background.png +0 -0
- data/lib/graphics/menu/ingame_background.xcf +0 -0
- data/lib/graphics/menu/start_background.png +0 -0
- data/lib/graphics/missing.png +0 -0
- data/lib/graphics/osd/magic_bg.png +0 -0
- data/lib/graphics/particles/leaf.png +0 -0
- data/lib/graphics/particles/smoke.png +0 -0
- data/lib/graphics/pixel.png +0 -0
- data/lib/graphics/tiles/test.png +0 -0
- data/lib/gui/base.rb +278 -0
- data/lib/gui/button.rb +93 -0
- data/lib/gui/char_equip.rb +118 -0
- data/lib/gui/char_selector.rb +54 -0
- data/lib/gui/context_menu.rb +115 -0
- data/lib/gui/draggable.rb +18 -0
- data/lib/gui/grid.rb +118 -0
- data/lib/gui/image.rb +17 -0
- data/lib/gui/inventory.rb +42 -0
- data/lib/gui/item_info.rb +33 -0
- data/lib/gui/slider.rb +10 -0
- data/lib/gui/textfield.rb +57 -0
- data/lib/layer.rb +64 -0
- data/lib/load.rb +31 -0
- data/lib/main.rb +18 -0
- data/lib/maps/def/test.bhv +26 -0
- data/lib/maps/def/test.rb +14 -0
- data/lib/maps/test.tmx +133 -0
- data/lib/maps/test2.tmx +94 -0
- data/lib/maps/test3.tmx +29 -0
- data/lib/maps/test3_lower.tmx +25 -0
- data/lib/maps/test3_upper.tmx +25 -0
- data/lib/maps/test_left.tmx +25 -0
- data/lib/maps/test_upper.tmx +25 -0
- data/lib/music/Butterfly Tea - A New Hope 2K11.mp3 +0 -0
- data/lib/music/Greendjohn - Rebirth.mp3 +0 -0
- data/lib/music/credits.txt +8 -0
- data/lib/parse.rb +605 -0
- data/lib/parse_tmx.rb +114 -0
- data/lib/particles.rb +127 -0
- data/lib/sample.rb +29 -0
- data/lib/save.rb +44 -0
- data/lib/song.rb +41 -0
- data/lib/sounds/click1.wav +0 -0
- data/lib/sounds/credits.txt +2 -0
- data/lib/sounds/error1.wav +0 -0
- data/lib/sprite.rb +35 -0
- data/lib/states/menus.rb +17 -0
- data/lib/states/menus/alchemy.rb +53 -0
- data/lib/states/menus/equip.rb +79 -0
- data/lib/states/menus/ingame.rb +34 -0
- data/lib/states/menus/magic.rb +31 -0
- data/lib/states/menus/options.rb +54 -0
- data/lib/states/menus/start.rb +38 -0
- data/lib/states/states.rb +154 -0
- data/lib/tileset.rb +42 -0
- data/lib/tools/world.rb +103 -0
- data/lib/tools/worldmap_editor.rb +221 -0
- data/lib/translate.rb +368 -0
- metadata +255 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
module Core::Game
|
|
3
|
+
module Alchemy
|
|
4
|
+
|
|
5
|
+
class Recipe
|
|
6
|
+
attr_accessor :name, :icon, :output, :input, :level
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.recipies
|
|
10
|
+
return @recipies
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.recipies=(ary)
|
|
14
|
+
@recipies = ary
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.find_recipe(name)
|
|
18
|
+
@recipies.each { |item|
|
|
19
|
+
if item.name == name
|
|
20
|
+
return item
|
|
21
|
+
end
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
require_relative "inventory.rb"
|
|
3
|
+
require_relative "skills.rb"
|
|
4
|
+
require_relative "constitution.rb"
|
|
5
|
+
require_relative "mind.rb"
|
|
6
|
+
require_relative "equipment.rb"
|
|
7
|
+
require_relative "magic.rb"
|
|
8
|
+
|
|
9
|
+
module Core::Game
|
|
10
|
+
def self.characters
|
|
11
|
+
return @characters
|
|
12
|
+
end
|
|
13
|
+
def self.characters=(ary)
|
|
14
|
+
@characters = ary
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Character
|
|
18
|
+
attr_reader :name, :age, :weight, :strength, :charset, :gender
|
|
19
|
+
attr_reader :inventory, :skills, :const, :mind, :equipment, :race, :magic
|
|
20
|
+
attr_reader :endurance, :state, :agility, :spells, :influences
|
|
21
|
+
attr_accessor :health
|
|
22
|
+
# health is only used as a percentage for easier displaying, the real stuff is in @const
|
|
23
|
+
|
|
24
|
+
def setup
|
|
25
|
+
@health = @endurance = 100
|
|
26
|
+
@inventory = Core::Game::Inventory.new(20, @strength)
|
|
27
|
+
@skills = Core::Game::Skills.new
|
|
28
|
+
@const = Core::Game::Constitution.new
|
|
29
|
+
@mind = Core::Game::Mind.new
|
|
30
|
+
@equipment = Core::Game::Equipment.new
|
|
31
|
+
@magic = Core::Game::Magic.new(self)
|
|
32
|
+
@state = Core::Game::NORMAL
|
|
33
|
+
@spells = {}
|
|
34
|
+
Core::Game.spells.each { |spell|
|
|
35
|
+
@spells.store(spell, 0)
|
|
36
|
+
}
|
|
37
|
+
@charset = @file
|
|
38
|
+
@file = Core.sprite(@file)
|
|
39
|
+
@influences = []
|
|
40
|
+
setup_skills
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def validate
|
|
44
|
+
if @agility > 100
|
|
45
|
+
@agility = 0
|
|
46
|
+
elsif @agility < 0
|
|
47
|
+
@agility = 0
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def update
|
|
52
|
+
@influences.each { |inf|
|
|
53
|
+
inf.update(self)
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def consume(item)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def calc_status
|
|
61
|
+
if @endurance <= 25
|
|
62
|
+
@state = Core::Game::UNCONSCIOUS
|
|
63
|
+
elsif @endurance <= 0
|
|
64
|
+
@state = Core::Game::DEAD
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def weaken(amount)
|
|
69
|
+
if @state != Core::Game::DEAD
|
|
70
|
+
@endurance -= amount
|
|
71
|
+
calc_status
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def rest(amount)
|
|
76
|
+
if @state != Core::Game::DEAD
|
|
77
|
+
@endurance -= amount
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def wake
|
|
82
|
+
if @state != Core::Game::DEAD
|
|
83
|
+
@state = Core::Game::NORMAL
|
|
84
|
+
calc_status
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def setup_skills
|
|
91
|
+
@skills.list[Core::Game.find_skill(:healing)] = @healing
|
|
92
|
+
@skills.list[Core::Game.find_skill(:crafting)] = @crafting
|
|
93
|
+
@skills.list[Core::Game.find_skill(:botany)] = @botany
|
|
94
|
+
@skills.list[Core::Game.find_skill(:healing_magic)] = @healing_magic
|
|
95
|
+
@skills.list[Core::Game.find_skill(:mind)] = @mind
|
|
96
|
+
@skills.list[Core::Game.find_skill(:elemental)] = @elemental
|
|
97
|
+
@skills.list[Core::Game.find_skill(:ranged)] = @ranged
|
|
98
|
+
@skills.list[Core::Game.find_skill(:melee)] = @melee
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
|
|
2
|
+
module Core::Game::Combat
|
|
3
|
+
|
|
4
|
+
class Bar
|
|
5
|
+
attr_reader :value, :max
|
|
6
|
+
attr_accessor :visible, :x, :y, :z
|
|
7
|
+
def initialize(x, y, z, w, h, scheme, max, background)
|
|
8
|
+
schemes = [:health, :endurance, :timer]
|
|
9
|
+
@background = background
|
|
10
|
+
@x, @y, @z = x, y, z
|
|
11
|
+
@w, @h = w, h
|
|
12
|
+
@scheme = scheme
|
|
13
|
+
@value = @max = max
|
|
14
|
+
@speed = @sub = @add = 0
|
|
15
|
+
@fade = 256
|
|
16
|
+
@visible = true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update
|
|
20
|
+
if !@visible
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
if @sub > 0
|
|
24
|
+
@value -= @speed
|
|
25
|
+
@sub -= @speed
|
|
26
|
+
else
|
|
27
|
+
@sub = 0
|
|
28
|
+
end
|
|
29
|
+
if @add > 0
|
|
30
|
+
@value += @speed
|
|
31
|
+
@add -= @speed
|
|
32
|
+
else
|
|
33
|
+
@add = 0
|
|
34
|
+
end
|
|
35
|
+
if @fade > 0 and @fade <= 255
|
|
36
|
+
@fade -= @speed
|
|
37
|
+
elsif @fade <= 0
|
|
38
|
+
@fade = 0
|
|
39
|
+
@visible = false
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def fade(speed=15)
|
|
44
|
+
@speed = speed
|
|
45
|
+
@fade = 255
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def draw
|
|
49
|
+
if !@visible
|
|
50
|
+
return
|
|
51
|
+
end
|
|
52
|
+
if @background
|
|
53
|
+
cb = Gosu::Color.new(255, 0, 0, 0)
|
|
54
|
+
Core.window.draw_quad(@x, @y, cb, @x+@w, @y, cb, @x+@w, @y+@h, cb, @x, @y+@h, cb, @z)
|
|
55
|
+
case @scheme
|
|
56
|
+
when :health
|
|
57
|
+
cl = Gosu::Color.new(255, 255, 0, 0)
|
|
58
|
+
cr = Gosu::Color.new(255, 0, 255, 0)
|
|
59
|
+
else
|
|
60
|
+
cl = Gosu::Color.new(255, 0, 0, 0)
|
|
61
|
+
cr = Gosu::Color.new(255, 255, 255, 255)
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
# TODO fluent fade
|
|
65
|
+
case @scheme
|
|
66
|
+
when :health
|
|
67
|
+
if @value >= (@max / 4) * 3
|
|
68
|
+
cl = cr = Gosu::Color.new(255, 0, 255, 0)
|
|
69
|
+
elsif @value >= @max / 2
|
|
70
|
+
cl = cr = Gosu::Color.new(255, 255, 255, 0)
|
|
71
|
+
elsif @value >= @max / 4
|
|
72
|
+
cl = cr = Gosu::Color.new(255, 255, 180, 0)
|
|
73
|
+
else
|
|
74
|
+
cl = cr = Gosu::Color.new(255, 255, 0, 0)
|
|
75
|
+
end
|
|
76
|
+
when :timer
|
|
77
|
+
if @value >= (@max / 4) * 3
|
|
78
|
+
cl = cr = Gosu::Color.new(255, 255, 0, 0)
|
|
79
|
+
elsif @value >= @max / 2
|
|
80
|
+
cl = cr = Gosu::Color.new(255, 255, 180, 0)
|
|
81
|
+
elsif @value >= @max / 4
|
|
82
|
+
cl = cr = Gosu::Color.new(255, 255, 255, 0)
|
|
83
|
+
else
|
|
84
|
+
cl = cr = Gosu::Color.new(255, 0, 255, 0)
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
cl = cr = Gosu::Color.new(255, 255, 255, 255)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
if @fade <= 255
|
|
91
|
+
f = @fade
|
|
92
|
+
if f < 0
|
|
93
|
+
f = 0
|
|
94
|
+
end
|
|
95
|
+
cl.alpha = f
|
|
96
|
+
cr.alpha = f
|
|
97
|
+
end
|
|
98
|
+
if @value > 0
|
|
99
|
+
w = @value / (@max / @w.to_f)
|
|
100
|
+
Core.window.draw_quad(@x, @y, cl, @x+w, @y, cr, @x+w, @y+@h, cr, @x, @y+@h, cl, @z)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def subtract(amount, speed)
|
|
105
|
+
@sub = amount
|
|
106
|
+
@speed = speed
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def add(amount, speed)
|
|
110
|
+
@add = amount
|
|
111
|
+
@speed = speed
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def set(val)
|
|
115
|
+
@value = val
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
end
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
|
|
2
|
+
module Core::Game
|
|
3
|
+
|
|
4
|
+
def self.enemies
|
|
5
|
+
return @enemies
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.enemies=(ary)
|
|
9
|
+
@enemies = ary
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.find_enemy(name)
|
|
13
|
+
@enemies.each { |enemy|
|
|
14
|
+
if enemy.name == name
|
|
15
|
+
return enemy
|
|
16
|
+
end
|
|
17
|
+
}
|
|
18
|
+
return nil
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.weapons
|
|
22
|
+
return @weapons
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.weapons=(hash)
|
|
26
|
+
@weapons = hash
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.find_weapon(name)
|
|
30
|
+
@weapons.each { |w|
|
|
31
|
+
if w.name == name
|
|
32
|
+
return w
|
|
33
|
+
end
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Combat
|
|
38
|
+
|
|
39
|
+
# For enemies
|
|
40
|
+
class Behaviour
|
|
41
|
+
def initialize(hash)
|
|
42
|
+
@actions = {}
|
|
43
|
+
hash.each { |k, v|
|
|
44
|
+
i = 0
|
|
45
|
+
v.each { |action|
|
|
46
|
+
if !@actions[k]
|
|
47
|
+
@actions.store(k, {})
|
|
48
|
+
end
|
|
49
|
+
@actions[k].store(i, action)
|
|
50
|
+
i += 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def execute(sym)
|
|
56
|
+
ary = @actions[sym].values.flatten(1)
|
|
57
|
+
ary.each { |str|
|
|
58
|
+
params = str.split(" ")
|
|
59
|
+
self.send(params.shift, params)
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def vanish(*args)
|
|
66
|
+
puts("STUB: Behaviour.vanish")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def drop(items)
|
|
70
|
+
items.each { |item|
|
|
71
|
+
puts("STUB: Behaviour.drop(#{item})")
|
|
72
|
+
}
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def attack(target)
|
|
76
|
+
target = target.first
|
|
77
|
+
puts("STUB: Behaviour.attack(#{target})")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
class Background
|
|
83
|
+
def initialize(file, color=nil)
|
|
84
|
+
@sprite = Core.sprite("backgrounds/#{file}")
|
|
85
|
+
if !color
|
|
86
|
+
@color = Gosu::Color::WHITE
|
|
87
|
+
else
|
|
88
|
+
@color = color
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
def update
|
|
92
|
+
end
|
|
93
|
+
def draw
|
|
94
|
+
@sprite.draw(0, 0, 0, 1024/@sprite.width.to_f, 768/@sprite.height.to_f, @color)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
class Weapon
|
|
99
|
+
attr_reader :name, :type, :effects, :icon
|
|
100
|
+
def initialize(name, type, effects, icon)
|
|
101
|
+
@name, @type, @effects, @icon = name, type, effects, Core.sprite("icons/#{icon}")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
class Enemy
|
|
106
|
+
attr_reader :name, :strength, :type, :weapons, :behaviour, :graphic
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Superclass for enemies and actors
|
|
110
|
+
class BattleObject
|
|
111
|
+
attr_reader :target
|
|
112
|
+
def initialize(graphic, x, y, z=Core::MAPOBJECT_Z, color=Gosu::Color::WHITE)
|
|
113
|
+
@frame = 0
|
|
114
|
+
@x, @y, @z = x, y, z
|
|
115
|
+
@color = color
|
|
116
|
+
if File.exists?("graphics/combat/#{graphic}.png")
|
|
117
|
+
@graphics = Gosu::Image.load_tiles(Core.window, "graphics/combat/#{graphic}.png", -4, -4, false)
|
|
118
|
+
@frame = 4
|
|
119
|
+
else
|
|
120
|
+
@graphics = [Core.sprite("missing")]
|
|
121
|
+
end
|
|
122
|
+
@target = nil
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def update(pause)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def draw
|
|
129
|
+
if @graphics[@frame]
|
|
130
|
+
@graphics[@frame].draw(@x, @y, @z, 1, 1, @color)
|
|
131
|
+
else
|
|
132
|
+
@graphics.first.draw(@x, @y, @z, 1, 1, @color)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def attacked(hit)
|
|
137
|
+
@target = nil
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def name
|
|
141
|
+
return ""
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
class BattleEnemy < BattleObject
|
|
146
|
+
attr_reader :data
|
|
147
|
+
attr_writer :gui
|
|
148
|
+
def initialize(enemy, x, y, z)
|
|
149
|
+
super(enemy.graphic, x, y, z)
|
|
150
|
+
@data = enemy
|
|
151
|
+
@gui = nil
|
|
152
|
+
@frame = 8
|
|
153
|
+
@w, @h = @graphics.first.width, @graphics.first.height
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def update(pause)
|
|
157
|
+
super
|
|
158
|
+
x, y = Core.window.mouse_x, Core.window.mouse_y
|
|
159
|
+
if Core.inside?(x, y, @x, @y, @x+@w, @y+@h) and Core.window.pressed?(Gosu::MsLeft)
|
|
160
|
+
if x - 160 < 0
|
|
161
|
+
x = 160
|
|
162
|
+
elsif x > 1024-320
|
|
163
|
+
x = 1024-320
|
|
164
|
+
end
|
|
165
|
+
if y - 128 < 0
|
|
166
|
+
y = 128
|
|
167
|
+
elsif y > 512
|
|
168
|
+
y = 512
|
|
169
|
+
end
|
|
170
|
+
@gui.open_info(self, 256, 160)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def draw
|
|
175
|
+
super
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def name
|
|
179
|
+
return @data.name
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Party member
|
|
184
|
+
class Actor < BattleObject
|
|
185
|
+
attr_reader :character
|
|
186
|
+
attr_accessor :ready_shown
|
|
187
|
+
def initialize(char, x, y, z)
|
|
188
|
+
super(char.charset, x, y, z)
|
|
189
|
+
@character = char
|
|
190
|
+
@health = Bar.new(x - 8, y - 8, 100, 48, 6, :health, 100, false)
|
|
191
|
+
@health.set(@character.health)
|
|
192
|
+
@next = Bar.new(x - 8, y - 16, 100, 48, 6, :health, 600 - (@character.agility*5), false)
|
|
193
|
+
@next.visible = false
|
|
194
|
+
@ready = false
|
|
195
|
+
@ready_shown = false
|
|
196
|
+
@moving = false
|
|
197
|
+
@ready_time = 600 - (@character.agility*5)
|
|
198
|
+
end
|
|
199
|
+
def update(pause)
|
|
200
|
+
super
|
|
201
|
+
if !pause
|
|
202
|
+
if @moving
|
|
203
|
+
@health.x, @health.y = @x - 8, @y - 8
|
|
204
|
+
@next.x, @health.y = @x - 8, @y - 16
|
|
205
|
+
end
|
|
206
|
+
if @ready_time == 0
|
|
207
|
+
ready!
|
|
208
|
+
@ready_time = -1
|
|
209
|
+
elsif @ready_time > 0
|
|
210
|
+
@ready_time -= 1
|
|
211
|
+
@next.visible = true
|
|
212
|
+
@next.set(@next.max - @ready_time)
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
@health.update
|
|
216
|
+
@next.update
|
|
217
|
+
end
|
|
218
|
+
def draw
|
|
219
|
+
super
|
|
220
|
+
@health.draw
|
|
221
|
+
@next.draw
|
|
222
|
+
end
|
|
223
|
+
def ready?
|
|
224
|
+
return @ready
|
|
225
|
+
end
|
|
226
|
+
def ready!
|
|
227
|
+
@next.fade
|
|
228
|
+
@ready = true
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def name
|
|
232
|
+
return @character.name
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
class Party
|
|
237
|
+
attr_reader :members
|
|
238
|
+
def initialize(party)
|
|
239
|
+
@members = []
|
|
240
|
+
create_actors(party)
|
|
241
|
+
end
|
|
242
|
+
private
|
|
243
|
+
def create_actors(party)
|
|
244
|
+
x = y = 0
|
|
245
|
+
party.members.each { |char|
|
|
246
|
+
# TODO this is crap
|
|
247
|
+
@members.push(Actor.new(char, 640+rand(48)+(x*128), 128+(y*96)+rand(48), 50))
|
|
248
|
+
y += 1
|
|
249
|
+
if y >= 4
|
|
250
|
+
y = 0
|
|
251
|
+
x += 1
|
|
252
|
+
end
|
|
253
|
+
}
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
class Battle
|
|
258
|
+
attr_reader :enemies, :background
|
|
259
|
+
|
|
260
|
+
def initialize(party, enemies, bg, control=nil)
|
|
261
|
+
@background = Background.new(bg)
|
|
262
|
+
@enemies = []
|
|
263
|
+
@party = Party.new(party)
|
|
264
|
+
@control = control
|
|
265
|
+
if @control
|
|
266
|
+
@control.battle = self
|
|
267
|
+
end
|
|
268
|
+
@gui = GUI.new
|
|
269
|
+
x = y = 0
|
|
270
|
+
enemies.each { |e|
|
|
271
|
+
# TODO this is crap too
|
|
272
|
+
e = BattleEnemy.new(e, 64+(x*64)+rand(32), 128+(y*96)+rand(48), 50)
|
|
273
|
+
y += 1
|
|
274
|
+
if y >= 4
|
|
275
|
+
y = 0
|
|
276
|
+
x += 1
|
|
277
|
+
end
|
|
278
|
+
e.gui = @gui
|
|
279
|
+
@enemies.push(e)
|
|
280
|
+
}
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def attack(attacker, target)
|
|
284
|
+
puts("STUB: Battle.attack(#{attacker.name}, #{target.name})")
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def spell(attacker, targets, spell)
|
|
288
|
+
puts("STUB: Battle.spell(#{attacker.name}, #{targets.name}, #{spell.name})")
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def item(attacker, target, item)
|
|
292
|
+
puts("STUB: Battle.item(#{attacker.name}, #{target.name}, #{item.name})")
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def update
|
|
296
|
+
pause = @gui.paused?
|
|
297
|
+
@background.update
|
|
298
|
+
@control.update
|
|
299
|
+
if !@gui.attacking.empty?
|
|
300
|
+
attack(@gui.attacking.first, @gui.attacking.last)
|
|
301
|
+
@gui.attacked
|
|
302
|
+
end
|
|
303
|
+
if !@gui.casting.empty?
|
|
304
|
+
spell(@gui.casting.first, @gui.casting[1], @gui.casting.last)
|
|
305
|
+
@gui.spell_cast
|
|
306
|
+
end
|
|
307
|
+
if !@gui.using.empty?
|
|
308
|
+
item(@gui.using.first, @gui.using[1], @gui.using.last)
|
|
309
|
+
@gui.item_used
|
|
310
|
+
end
|
|
311
|
+
@enemies.each { |enemy|
|
|
312
|
+
enemy.update(pause)
|
|
313
|
+
}
|
|
314
|
+
@party.members.each { |actor|
|
|
315
|
+
actor.update(pause)
|
|
316
|
+
if actor.ready? and !actor.ready_shown
|
|
317
|
+
@gui.push(:ready, actor)
|
|
318
|
+
actor.ready_shown = true
|
|
319
|
+
elsif !actor.ready?
|
|
320
|
+
actor.ready_shown = false
|
|
321
|
+
end
|
|
322
|
+
}
|
|
323
|
+
@gui.update
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def draw
|
|
327
|
+
@background.draw
|
|
328
|
+
@control.draw
|
|
329
|
+
@enemies.each { |enemy|
|
|
330
|
+
enemy.draw
|
|
331
|
+
}
|
|
332
|
+
@party.members.each { |actor|
|
|
333
|
+
actor.draw
|
|
334
|
+
}
|
|
335
|
+
@gui.draw
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
require_relative "bar.rb"
|
|
344
|
+
require_relative "control.rb"
|
|
345
|
+
require_relative "gui.rb"
|