Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
Hi, I tried exhuming MrMo's ABS. Apart from the ABS system, it allows the player setting certain keys with learned skills.
I wanted to use a Script Call to set automatically these hotkeys, without the player possibility to choose, but I don't know how.
I guess the answer's in the og script itself, but I can't understand ruby... Could you kindly tell what to do? :dizzy:

def update_skill
mrmo_moabs_scene_skill_update_skill
#Get all the keys
for key in @actor.skill_keys.keys
next if key.nil?
#Check is the the key is pressed
next if !Input.trigger?(key)
next if hot_key_has_value?(@skill_window.skill.id)
$game_system.se_play($data_system.decision_se)
#Record Skill
@actor.skill_keys[key] = @skill_window.skill.id
@skill_window.active = false
@shk_window.active = @shk_window.visible = true
end
end
#--------------------------------------------------------------------------
# * Check if any other hotkey has this.
#--------------------------------------------------------------------------
def hot_key_has_value?(id)
@actor.skill_keys.each {|key, value|
if value == id
@actor.skill_keys[key] = nil
end
}
return false
end
#--------------------------------------------------------------------------
# * Frame Update Skill Hot Key
#--------------------------------------------------------------------------
def update_shk
#Return if Enter isn't pressed
return if !Input.trigger?(Input::C)
#Play decision
$game_system.se_play($data_system.decision_se)
@shk_window.active = @shk_window.visible = false
@skill_window.active = true
$scene = Scene_Skill.new(@actor_index)
end
end
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
Sure, thanks for answering!
Here is where I found it, but here you can read the script without downloading it, although apart from the main script there are a few more.
In fact, I think the script makes use of Aleworks Input Module, which I can't find on google, but if you need it I can copy it here as 'spoiler'.
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
Hi, the ABS Ultimate version should be a modified version of the one I linked, changed by DerVVulfman, I didn't think I'd needed those addons, but I'll give it a look. Still, that doesn't answer my question, so I still need help! :kaoswt:
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
389
Reaction score
155
First Language
English
Primarily Uses
RMXP
Looks like all you do is
Code:
$ABS.skill_keys[key] = skill_id
where 'key' is a valid input value, which you define in the configuration:
Code:
SKILL_KEYS = {Input::Numberkeys[0] => 0,
              Input::Numberkeys[1] => 0,
              Input::Numberkeys[2] => 0,
              Input::Numberkeys[3] => 0,
              Input::Numberkeys[4] => 0,
              Input::Numberkeys[5] => 0,
              Input::Numberkeys[6] => 0,
              Input::Numberkeys[7] => 0,
              Input::Numberkeys[8] => 0,
              Input::Numberkeys[9] => 0,
              Input::Letters["A"] => 0,
              }
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
Looks like all you do is
Code:
$ABS.skill_keys[key] = skill_id
I see, thank you. So I should call a script like
Code:
$ABS.skill_keys[Input::Letters["Q"] => 0] = 1
?
Cause it doesn't seem to work... :kaoswt: Also, what I needed was setting to the hotkeys a skill already learned, and not from the database, could this be possible?
I mean, putting a certain skill_id would take a precise skill from the database, not (whichever) skill that the hero already has... Right...?
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
389
Reaction score
155
First Language
English
Primarily Uses
RMXP
Code:
$ABS.skill_keys[Input::Letters["Q"]] = 1
Also, best to explain what "doesn't seem to work" is for future cases; share the error message you receive as that is more helpful for others to work with.

And yes, it's up to you to determine how to use this script call. Obviously this was never intended as there's no documentation on it. Thus, it is you who holds all the responsibility on how it's used--that means assigning a skill whether the player knows it or not.

You'll have to explain your use-case more if you want a more specific answer.
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
You'll have to explain your use-case more if you want a more specific answer.
Okay, so, I didn't share the error message because I got none... It seems the script call just gets ignored and the project keeps going without changing anything. I'll try to explain my specific use-case, what I need is a script call that automatically assign to certain hotkeys the skills that the hero already knows.
So for example, hero knows A, B and C, this script call would assign to Key1 -> A, Key2 -> B, Key3 -> C.
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
how do you know what skills the actor already knows?
I don't. The actor may have learnt any of the skills from the database. I was wondering if there was another way to use skills in scripts, without referring to them from the database.
I mean, Skill(1) would be Skill number one in the project database, but, is there a way to write "Skill in first position in the Skill Menu"? I mean, a way to check what Skills the actor already can use in battle, and refer to them in the order they're found in the Skill Menu, rather than by their database number.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
389
Reaction score
155
First Language
English
Primarily Uses
RMXP
Downloaded the demo and saw what the problem is. Like I said before, this was not an intended script call/feature, so things are going to get hackish and look bad.

First need you to add this anywhere in your scripts list:
Code:
class Scene_Map
  attr_reader :mrmo_hud
end

Here's a properly formatted script call because things can get janky if you line-break in the wrong places.
Code:
s = $game_actors[1].skills[0]
key = Input::Numberkeys[0]
$ABS.skill_keys[key] = s
$scene.mrmo_hud.refresh_skill_hotkeys
We're getting the first actor listed in the database and assigning the first skill they know (unlike $game_actors, the array skills is zero-indexed, so 0 is the first entry, 1 is second, etc.) to the number key 0. After that, you need to refresh the HUD so that we can actually see the skill appear in the hotkeys bar.

If you want to loop through all of an actor's skills, you simply do
Code:
$game_actors[ID].skills.each do |sid|
  print sid
end
replacing ID accordingly, and removing the print line with whatever code you want. This code snippet is simply going to print out, one at a time, all the skill IDs that actor knows.

FYI, all of an actor's skills are automatically sorted in database order, not by "when the actor learned the skill."

To automatically fill the hotkeys with, say, the first 10 skills the first actor knows,
Code:
key_id = 1
actor = $game_actors[1]
actor.skills.each do |id|
key = Input::Numberkeys[key_id % 10]
 $ABS.skill_keys[key] = id
 key_id += 1
 break if key_id == 11
end
$scene.mrmo_hud.refresh_skill_hotkeys

Of course, you could just iterate one at a time and use multiple script calls if you want to finer tune your hotkeys, like
Code:
s = $game_actors[1].skills[0]
return if s.nil?
key = Input::Numberkeys[1]
$ABS.skill_keys[key] = s
Code:
s = $game_actors[1].skills[1]
return if s.nil?
key = Input::Numberkeys[2]
$ABS.skill_keys[key] = s
Code:
s = $game_actors[1].skills[2]
return if s.nil?
key = Input::Letters['Q']
$ABS.skill_keys[key] = s
..and so forth, finishing it all off with one last script call
Code:
$scene.mrmo_hud.refresh_skill_hotkeys

And to wrap this all up, if you want to use the first actor in the party rather than picking someone from the database, then replace
Code:
$game_actors[ID]
with
Code:
$game_party.actors[0]
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
Wow! Thank you so much for your interest, I really appreciate it.
So let's see, I've done what you suggested, put the small code among the other scripts, and tried your options, although I keep getting this error message:
NoMethodError occured while running script.
undefined method 'refresh_skill_hotkeys' for
#<Window_MrMo_HUD:0x7abc008>
I'm feeling guilty for asking help so much haha, I apologize and thank you again for your time. Let me know if I'm doing something wrong or what!
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
389
Reaction score
155
First Language
English
Primarily Uses
RMXP
My post assumes you are using the most updated version of the ABS, posted by DerVVulfman. The method must not exist in the older version.
 

Syddo

Villager
Member
Joined
Nov 3, 2020
Messages
19
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
ALRIGHT
It took me a while solving a bug where the actor and the caterpillar would get duplicated on the map each time after closing the menu (?!?!)
It totally works, I still wonder why some key inputs end up showing in a different order than mine?
(ex. Input::Letters["E"] will be put before Input::Letters["Q"] despite being set after it)
I guess it respects some sort of alphabetical order? That's not important anyway.
Thank you very much, you've been really helpful!
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
389
Reaction score
155
First Language
English
Primarily Uses
RMXP
I still wonder why some key inputs end up showing in a different order than mine?
That's a quirk with old Ruby hashes. They're not sorted based on the order they're inserted.

You can replace this method in Mr.Mo's HUD to sort the skill hotkeys based on the character keycode ID, which you can view in Input Script - Cybersam
Code:
  def refresh_skill_hotkeys
    icon_margin = MrMo_Hud::HOTKEY_SKILL_X + 32
    icon_height = MrMo_Hud::HOTKEY_SKILL_Y + 36
    text_height = MrMo_Hud::HOTKEY_SKILL_Y + 44
    count = 0
    #Make a loop to get all the ideas that are Hotkeyed
    $ABS.skill_keys.sort.each do |key, id| #values
      #Skip NIL values
      next if id == nil
      #Get skill
      skill = $data_skills[id]
      #Skip NIL values
      next if skill == nil
      #Get Icon
      icon = RPG::Cache.icon(skill.icon_name)
      x = (count*32) + icon_margin
      self.contents.blt(x, icon_height, icon, Rect.new(0, 0, 200, 100))
      if MrMo_Hud::HOTKEY_SKILL_COST
        number = skill.sp_cost.to_s
        x2 = x +            MrMo_Hud::HOTKEY_SKILL_COST_X
        y2 = icon_height +  MrMo_Hud::HOTKEY_SKILL_COST_Y
        self.contents.draw_text(x2, y2, 24, 24, number,2)
      end      
      if MrMo_Hud::HOTKEY_SKILL_TEXT
        if MrMo_Hud::HOTKEY_SKILL_CENTER
          self.contents.draw_text(x-12, text_height, 49, 58, skill.name.to_s,1)
        else
          self.contents.draw_text(x, text_height, 49, 58, skill.name.to_s)
        end
      end
      if MrMo_Hud::HOTKEY_SKILL_KEYS
        if key && id > 0
          if MrMo_Hud::HOTKEY_SKILL_CENTER
            self.contents.draw_text(x-12, text_height + 10, 49, 58, "["+key.chr+"]",1)
          else
            self.contents.draw_text(x, text_height + 10, 49, 58, "["+key.chr+"]")
          end
        end
      end
      #Increase Count
      count += 1
    end    
  end
But there's nothing you can do about interpolating in order of insertion. That doesn't come around until Ruby version 1.9+, which VXA runs on.
 

Latest Threads

Latest Posts

Latest Profile Posts

Evening humans! How goes the game make?
The anime characters we saw 20 years ago,
still have the same age when we see them now.
Somehow it's strange but also beautiful.
It's like no matter how much we change,
there's certain part of ourselves we can reconnect to when we see them again.
Took a long, long time, way longer than it should to be honest...but I've finally finished the big content update to my demo!
Lots of not good things happening IRL but I'm not gonna let this day end like this. Quote time:
"Success is not final, failure is not fatal: it is the courage to continue that counts." -Winston Churchill

So, keep going, lads. Whatever you do keep going. Until next time.

It's a Spanish devlog don't get scared!. (please)

Forum statistics

Threads
117,239
Messages
1,105,797
Members
153,405
Latest member
Eamon_Dev-Alera
Top