Welcome, Guest. Please login or register.
Kingdoms of Ahln
Pages: [1]
  Print  
Author Topic: sub classing of weapons...  (Read 86 times)
Joseph
Wanderer
*
Posts: 13


View Profile
« on: December 06, 2011, 02:24:00 am »

Creating a subclass of class weapon for each weapon type is a very bad idea in my opinion. Sure it is easy to create 1 class at a time as you go along, but when your game is more complex it will be much more difficult to make additions & modify existing classes.  If I were going to subclass weapons there would only be classes for different types of weapons (ex. ranged, thrown, one hand edged, one hand blunt...)  My suggestion to eliminate subclassing of weapons would be to use weapon tables for creation. something similar to what follows (please forgive that this example isn't run ready & debugged, its just here so that you will be able to understand from reading what I mean.)

Code:
require 'lib/gameobject'
#weapon tables in a hash
#stats 0=attack 1=defense
weapons_stats = {
  "dagger" => [5, 5],
  "sword" => [10, 5]
  "mace" => [15, 1],
  "quarter staff" => [2, 18],
  "blackjack" => [5, 3],
  "quiot" => [7, 1],
  "battle axe" => [20, 4]}
#weapon types
weapon_names = {
  "dagger" => ['dagger', 'dirk', 'knife', 'butcher knife', 'stiletto'],
  "sword" => ['sword', 'kris', 'wakizashi', 'gladius'],
  "mace" => ['mace', 'pernat', 'massuelle'],
  "quarter staff" => ['quarter staff', 'staff', 'bo stick'],
  "blackjack" => ['blackjack', 'sap'],
  "quoit" => ['quoit', 'chakram'],
  "battle axe" => ['battle axe', 'executioner\'s axe', 'tabar', 'greataxe']}

class Weapon < GameObject
  include Wearable

  def initialize(type, *args)
    super
    info.position = :wield
    info.weapon_type = type
    info.attack = weapons_stats[type][0]
    info.defense = weapons_stats[type][1]
    info.layer = 0
    @movable = true
    @generic = "weapon"
  end
end

Now that being said, I would go even further with this recommendation, I would say that weapons shouldn't have generic combat attributes attached to them.  Just the "type" of weapon, and any bonuses specific to that individual weapon.  Combat resolution is a much better place to determine what base stats apply to weapons & armor involved in that event of combat.  

The reason for this recommendation is ease of future changes.  Lets say for example that you start your game w/ all dirks having attack 5 and defense 5.. and then after a few months you rework how you want to do combat, and change dirks to attack .05 defesne .003 (yeah thats a big rework to how combat is done eh?  But unbeknownst to the combat guru who is doing this rework some other admin renamed a 'dirk' to 'long-knife' and it didn't get caught in the script that the combat guru had to apply to all dirks (because they were already created.. ugh) and la-de-da you have a dirk "long-knife" in the game that is way overpowered.  If the base weapon stats are all left in tables that are a part of combat calculation the need to modify all existing items when a change to the system is made is eliminated.. and there is no chance of items not working as 'intended'.

VR,

Joseph
« Last Edit: December 06, 2011, 02:25:34 am by Joseph » Logged
Justin
Administrator
Citizen
*****
Posts: 189



View Profile
« Reply #1 on: December 06, 2011, 12:43:08 pm »

Yeah. Combat in general is not very finished.

I'm not doing much work on KoA at the moment, mainly just pulling in changes that other people would like to make or fixing bugs that people find. So if you come up with something that works, I would be glad to add it to the code! Otherwise, it may be a long time before my interest rolls back around again Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2006-2009, Simple Machines
Terra97 design by Bloc