Save-Point
KActionSpeed XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: KActionSpeed XP (/thread-7569.html)



KActionSpeed XP - kyonides - 10-31-2019

KActionSpeed XP

by Kyonides Arkanthes

Introduction

Continuing the battle add-ons production line, I present you with a scriptlet that will alter a hero's or a monster's action speed. An action can either be attacking the opponent with a sword swing or casting a spell or even consuming an item. This can now be alter via script!

Did you ever want to make a battler the fastest guy out there? Confused Now you can get him or her a good chance to strike first! Shocked
Or you can make him or her the slowest scum that has ever existed! Laughing
Or you might prefer to let luck guide them... Confused

Script
Code:
# * KActionSpeed XP
#   Scripter : Kyonides Arkanthes
#   2019-10-31

# This scriptlet allows you to modify a battler's action speed by multiplying
# it by a predefined percent. It can also slow it down or give the battler a
# good chance to get the first strike for himself alone. Speed will depend on a
# State or some Item the party might have collected sofar.
# Since monsters have no bag full of items, they solely depend on a state to get
# the speed boost.
# You can also define items or states that randomly alter anyone's speed.

module KActionSpeed
 FAST_ITEMID = 1
 SLOW_ITEMID = 2
 RANDOM_ITEMID_MAX = [3, 1000] # ItemID, SpeedMax
 FAST_STATEID = 2
 SLOW_STATEID = 3
 RANDOM_STATEID_MAX = [4, 1000] # StateID, SpeedMax
 # { ID => Percent, etc. }
 ITEMS = { 4 => 5, 5 => 10, 6 => 15 }
 STATES = { 5 => 5, 6 => 9 }
end

class Game_Battler
 alias :kyon_action_speed_gmb_mas :make_action_speed
 def make_action_speed
   speed = kyon_action_speed_gmb_mas
   action = @current_action
   if self.is_a?(Game_Actor)
     return action.speed *= 100 if KActionSpeed::FAST_ITEMID
     return action.speed = 0 if KActionSpeed::SLOW_ITEMID
     keys = $game_party.item_keys
     iid, imax = KActionSpeed::RANDOM_ITEMID_MAX
     return action.speed = rand(imax + 1) if keys.include?(iid)
     keys &= KActionSpeed::ITEMS.keys
     keys.each{|key| action.speed += speed * KActionSpeed::ITEMS[key] / 100 }
   end
   return action.speed *= 100 if @states.include?(KActionSpeed::FAST_STATEID)
   return action.speed = 0 if @states.include?(KActionSpeed::SLOW_STATEID)
   rid, rmax = KActionSpeed::RANDOM_STATEID_MAX
   return action.speed = rand(rmax + 1) if @states.include?(rid)
   keys = @states & KActionSpeed::STATES.keys
   keys.each{|key| action.speed += speed * KActionSpeed::STATES[key] / 100 }
 end
end

class Game_Party
 def item_keys() @items.keys end
end

Terms & Conditions

You must include my nickname and the current website's URL in your game credits.
Free for non commercial games.
Give me a free copy of your completed game if you include at least 2 of my scripts! Laughing + Tongue sticking out