Build a framework for a maintainable combat plugin

* Uses a hierarchy of WeaponClasses -> Weapons for performing attacks,
  with WeaponClass having a set of styles and associated Attacks for
  those styles. Weapons and their classes are built with an easy to use
  and clean DSL.

* Adds a BonusContainer mixin, so that Equipment, Weapons, and
  WeaponClasses can all have their own set of bonuses which apply to the
  player.

* Allows attacks to be queued to the Mobs CombatState instance from
  external code, allowing e.g., NPCs or auto-cast to queue attacks to be
  executed.
This commit is contained in:
Gary Tierney
2016-02-29 21:24:34 +00:00
parent 7731eedf3d
commit 348e5cc8dc
21 changed files with 895 additions and 80 deletions
+20
View File
@@ -0,0 +1,20 @@
BOW_WIDGET_ID = 10
BOW_SPECIAL_BAR_ID = 10
#
# create_weapon_class :longbow, widget: BOW_WIDGET_ID do
# special_bar = BOW_SPECIAL_BAR_ID
#
#
# add_style :accurate, speed: 6, range: 7
# add_style :rapid, speed: 6, range: 7
# add_style :long_range, speed: 6, range: 9
# end
#
# create_weapon_class :shortbow, widget: BOW_WIDGET_ID do
# special_bar = BOW_SPECIAL_BAR_ID
#
# add_style :accurate, speed: 4, range: 7
# add_style :rapid, speed: 3, range: 7
# add_style :long_range, speed: 4, range: 9
# end
#
+50
View File
@@ -0,0 +1,50 @@
SCIMITAR_WIDGET_ID = 81
SCIMITAR_SPECIAL_BAR_ID = 21
create_weapon_class :scimitar, widget: SCIMITAR_WIDGET_ID do
default_speed 4
special_bar SCIMITAR_SPECIAL_BAR_ID
attack_bonuses crush: -2
defence_bonuses slash: -1
add_style :accurate, attack_type: :slash, animation: 390
add_style :aggressive, attack_type: :slash, animation: 390
add_style :alt_aggressive, attack_type: :stab, animation: 391
add_style :defensive, attack_type: :slash, animation: 390
end
create_weapon :iron_scimitar do
attack_bonuses stab: 2, slash: 10
other_bonuses melee_strength: 9
end
create_weapon :steel_scimitar do
attack_bonuses stab: 3, slash: 15
other_bonuses melee_strength: 14
end
create_weapon /(black|white) scimitar/ do
attack_bonuses stab: 4, slash: 19
other_bonuses melee_strength: 14
end
create_weapon :mithril_scimitar do
attack_bonuses stab: 5, slash: 21
other_bonuses melee_strength: 20
end
create_weapon :adamant_scimitar do
attack_bonuses stab: 6, slash: 29
other_bonuses melee_strength: 28
end
create_weapon :rune_scimitar do
attack_bonuses stab: 7, slash: 45
other_bonuses melee_strength: 44
end
create_weapon :dragon_scimitar do
attack_bonuses :stab => 8, slash: 67
other_bonuses melee_strength: 66
end
@@ -0,0 +1,52 @@
TWO_HANDED_SWORD_WIDGET_ID = 82
TWO_HANDED_SWORD_SPECIAL_ID = 12
create_weapon_class :two_handed_sword, widget: TWO_HANDED_SWORD_WIDGET_ID do
default_speed 7
special_bar TWO_HANDED_SWORD_SPECIAL_ID
animations stand: 7047, walk: 7046, run: 7039, idle_turn: 7044, turn_around: 7044, turn_left: 7043, turn_right: 7044
attack_bonuses stab: -4, magic: -4
defence_bonuses range: -1
add_style :accurate, attack_type: :slash, animation: 7041
add_style :aggressive, attack_type: :crush, animation: 7041
add_style :alt_aggressive, attack_type: :crush, animation: 7048
add_style :defensive, attack_type: :slash, animation: 7049
end
create_weapon :iron_2h_sword do
attack_bonuses slash: 13, crush: 10
other_bonuses melee_strength: 14
end
create_weapon :steel_2h_sword do
attack_bonuses slash: 21, crush: 16
other_bonuses melee_strength: 22
end
create_weapon /(?:black|white) 2h sword/ do
attack_bonuses slash: 27, crush: 21
other_bonuses melee_strength: 26
end
create_weapon :mithril_2h_sword do
attack_bonuses slash: 30, crush: 24
other_bonuses melee_strength: 26
end
create_weapon :adamant_2h_sword do
attack_bonuses slash: 43, crush: 30
other_bonuses melee_strength: 31
end
create_weapon :rune_2h_sword do
attack_bonuses slash: 69, crush: 50
other_bonuses melee_strength: 70
end
create_weapon :dragon_2h_sword do
attack_bonuses slash: 92, crush: 80
other_bonuses melee_strength: 70
end
+11
View File
@@ -0,0 +1,11 @@
create_weapon_class :unarmed, widget: -1 do
default_speed 4
add_style :accurate, animation: 422, block_animation: 424
add_style :aggressive, animation: 423, block_animation: 424
add_style :defensive, animation: 422, block_animation: 424
end
create_weapon :no_weapon, :unarmed, named: true do
# Todo factor out empty blocks
end