Module: Lich::Gemstone::PSMS
- Defined in:
- documented/gemstone/psms.rb
Constant Summary collapse
- FAILURES_REGEXES =
A compiled regular expression used to match common failure messages across all PSM (Player System Manager) actions.
This constant combines several game-generated failure messages into a single ‘Regexp` using `Regexp.union`, allowing centralized pattern matching for detecting failed actions.
Useful for interpreting command results and handling expected failure states in scripting logic. Note that in most cases, the match on a failure message here is not considered an error, but rather that the command succeeded, but the action itself failed for some reason.
Regexp.union( /^And give yourself away! Never!$/, /^You are unable to do that right now\.$/, /^You don't seem to be able to move to do that\.$/, /^Provoking a GameMaster is not such a good idea\.$/, /^You do not currently have a target\.$/, /^Your mind clouds with confusion and you glance around uncertainly\.$/, /^But your hands are full\!$/, /^You are still stunned\.$/, /^You lack the momentum to attempt another skill\.$/, )
Class Method Summary collapse
-
.assess(name, type, costcheck = false, forcert_count: 0) ⇒ Boolean, Object
Assess the validity or cost of a given PSM (Player System Manager) skill.
-
.available?(name, ignore_cooldown = false) ⇒ Boolean
Determines if a given PSM skill is available for use (not in cooldown, and not overexerted).
-
.can_forcert?(times) ⇒ Boolean
Determines whether the character is eligible to perform the given number of forced roundtime (forcert) rounds.
-
.find_name(name, type) ⇒ Hash?
Finds a Player System Manager (PSM) skill by name within the specified category.
-
.max_forcert_count ⇒ Integer
Determines the maximum number of forced roundtime (forcert) activations allowed based on the character’s Multi-Opponent Combat (MOC) training.
-
.name_normal(name) ⇒ String
Normalizes a name for internal lookup consistency.
Class Method Details
.assess(name, type, costcheck = false, forcert_count: 0) ⇒ Boolean, Object
Assess the validity or cost of a given PSM (Player System Manager) skill.
This method checks if a named PSM skill exists in a given category (‘type`), and either:
- Verifies if the character has enough stamina to use it (when `costcheck` is true),
- Or retrieves the rank of the skill from Infomon (when `costcheck` is false).
If the skill cannot be found, it logs an error and raises an exception to halt execution.
or the Infomon rank of the skill otherwise.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'documented/gemstone/psms.rb', line 101 def self.assess(name, type, costcheck = false, forcert_count: 0) return false unless forcert_count <= max_forcert_count name = self.name_normal(name) seek_psm = self.find_name(name, type) # this logs then raises an exception to stop (kill) the offending script if seek_psm.nil? Lich.log("error: PSMS request: #{$!}\n\t") raise ArgumentError, "Aborting script - The referenced #{type} skill #{name} is invalid.\r\nCheck your PSM category (Armor, CMan, Feat, Shield, Warcry, Weapon) and your spelling of #{name}.", (caller.find { |call| call =~ /^#{Script.current.name}/ }) end # otherwise process request case costcheck when true base_cost = seek_psm[:cost] base_cost.each do |cost_type, cost_amount| if forcert_count > 0 return false unless (cost_amount + (cost_amount * ((25 + (10.0 * forcert_count)) / 100))).truncate < XMLData.public_send(cost_type) else return false unless cost_amount < XMLData.public_send(cost_type) end end return true else Infomon.get("#{type.downcase}.#{seek_psm[:short_name]}") end end |
.available?(name, ignore_cooldown = false) ⇒ Boolean
Determines if a given PSM skill is available for use (not in cooldown, and not overexerted).
This method checks if the skill is not listed in the cooldowns or debuffs (specifically “Overexerted”). It uses the ‘Lich::Util.normalize_lookup` method to check for the skill’s presence in these lists.
142 143 144 145 146 |
# File 'documented/gemstone/psms.rb', line 142 def self.available?(name, ignore_cooldown = false) return false if Lich::Util.normalize_lookup('Debuffs', 'Overexerted') return false if Lich::Util.normalize_lookup('Cooldowns', name) unless ignore_cooldown return true end |
.can_forcert?(times) ⇒ Boolean
Determines whether the character is eligible to perform the given number of forced roundtime (forcert) rounds.
This method checks if the character’s Multi-Opponent Combat (MOC) training allows at least the specified number of forcert rounds, based on the result of max_forcert_count.
159 160 161 |
# File 'documented/gemstone/psms.rb', line 159 def self.can_forcert?(times) max_forcert_count >= times end |
.find_name(name, type) ⇒ Hash?
Finds a Player System Manager (PSM) skill by name within the specified category.
This method searches for a PSM skill (such as a combat maneuver, armor skill, feat, etc.) by matching the normalized ‘long_name` or `short_name` within the specified type’s lookup table.
69 70 71 72 73 |
# File 'documented/gemstone/psms.rb', line 69 def self.find_name(name, type) name = self.name_normal(name) Object.const_get("Lich::Gemstone::#{type}").method("#{type.downcase}_lookups").call .find { |h| h[:long_name].eql?(name) || h[:short_name].eql?(name) } end |
.max_forcert_count ⇒ Integer
Determines the maximum number of forced roundtime (forcert) activations allowed based on the character’s Multi-Opponent Combat (MOC) training.
The number of forcert rounds scales with ranks in MOC as follows:
- 0–9 ranks: 0 forcert rounds
- 10–34 ranks: 1 forcert round
- 35–74 ranks: 2 forcert rounds
- 75–124 ranks: 3 forcert rounds
- 125+ ranks: 4 forcert rounds
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'documented/gemstone/psms.rb', line 178 def self.max_forcert_count case Skills.multi_opponent_combat when 0..9 0 when 10..34 1 when 35..74 2 when 75..124 3 else # 125+ 4 end end |
.name_normal(name) ⇒ String
Normalizes a name for internal lookup consistency.
Converts the input string to a standardized format (e.g., downcased, underscored) using ‘Lich::Util.normalize_name`.
53 54 55 |
# File 'documented/gemstone/psms.rb', line 53 def self.name_normal(name) Lich::Util.normalize_name(name) end |