Jump to content


Photo

Ruby/RGSS3 questions that don't deserve their own thread


  • Please log in to reply
1472 replies to this topic

#1461 stderr

stderr

    Newbie

  • Ace Member
  • 7 posts

Posted 21 July 2014 - 10:50 AM

I am currently working on a skill system script. Therefore i need to find out whether the skill-target is an actor or an enemy. To get started i had a look at Fomars "IncreaseSkillLvlByUse" script. He uses the "def item_apply(user, item)" method from "Game_Battler" to recognize the use of a skill.

Spoiler

However, this does not work for me, as i need the target to find out whether it is an actor or an enemy. I messed around with the "@result" variable, which did not work (obviously because the comment at it was not clear and i couldnt find anything in the docs.)

After some search i found the class "Game_Action" and specifically the method evaluate_item_with_target(target).

Spoiler

Which does not get called during battle, as it seems....

 

So could someone pls point me to the method where a skill is used and i can get the target (actor or enemy) and therefore its database id?


Edited by stderr, 21 July 2014 - 10:55 AM.


#1462 Bearform

Bearform

    Queen of Brain Farts

  • Ace Member
  • 7 posts
  • LocationOz
  • RM Skill - Artist

Posted 21 July 2014 - 12:01 PM

I'd say learn how to use the game's variables and switches pretty well first, and then learn Ruby. Well a lot of people suggest learning ruby, I just learned RGSS3 (which is still ruby, but only relevant to vx ace).

 

Then again I'm not the greatest at coding...

Okay, thanks! I'll learn how the engine works first :) Annndd maybe RGSS3 only because I'm lazy.



#1463 JunLi

JunLi

    ...?!?

  • Ace Member
  • 34 posts
  • RM Skill - Designer

Posted 21 July 2014 - 03:12 PM

 

 

Does anyone know what's going on?

 

 

Now of course that's wrong. First, you aliased the second command and didn't initialize it. Second thing is that is the command_personal being the method sticking with the new key method? Why not make a new method that accesses that directly? Such things, makes it a complete error.

Sorry. I forgot to mention that this code is in the Scene_Menu class, and I'm just altering the methods already present. That's why I'm aliasing. I just took the default code, added my little bit, and stripped out the already-present code, aliasing the methods so that the default methods aren't completely overwritten. The methods should already be initialized in the Scene_Menu class.

 

EDIT: Actually, that last part you said about a new method to call instead of "command_personal" was right. I made a new method, and now it works fine. Thanks for the help.


Edited by JunLi, 21 July 2014 - 03:36 PM.

Current projects:

Spoiler

 

Finished Works:

Spoiler

 

 

I don't claim to be good, nor do I claim to know a whole lot. I do, however, have a lot of bad ideas. It's those bad ideas that spark good ideas, and that's what I'm all about.

 

I also have good ideas, but I rarely can bring them to fruition.


#1464 Euphoria

Euphoria

    Advanced Member

  • Ace Member
  • 547 posts
  • RM Skill - Jack of All Trades

Posted 21 July 2014 - 03:43 PM

 

I'd say learn how to use the game's variables and switches pretty well first, and then learn Ruby. Well a lot of people suggest learning ruby, I just learned RGSS3 (which is still ruby, but only relevant to vx ace).

 

Then again I'm not the greatest at coding...

Okay, thanks! I'll learn how the engine works first :) Annndd maybe RGSS3 only because I'm lazy.

 

No problem, and just remember that DP3 has some great video tutorials on this site, for when you decide to try RGSS3


My Website:

 Click--->Temporary_TAG.png <--- Click

 

 

I support:

6LOfEM3.png Theo_Banner.png Untitled_1.png


#1465 stderr

stderr

    Newbie

  • Ace Member
  • 7 posts

Posted 23 July 2014 - 06:50 AM

I am currently working on a skill system script. Therefore i need to find out whether the skill-target is an actor or an enemy. To get started i had a look at Fomars "IncreaseSkillLvlByUse" script. He uses the "def item_apply(user, item)" method from "Game_Battler" to recognize the use of a skill.

Spoiler

However, this does not work for me, as i need the target to find out whether it is an actor or an enemy. I messed around with the "@result" variable, which did not work (obviously because the comment at it was not clear and i couldnt find anything in the docs.)

After some search i found the class "Game_Action" and specifically the method evaluate_item_with_target(target).

Spoiler

Which does not get called during battle, as it seems....

 

So could someone pls point me to the method where a skill is used and i can get the target (actor or enemy) and therefore its database id?

Nvm, found the solution myself.

If anyone is interested:

In class Scene_Battle, the method use_item (around line 590).

The targets variable was the one i was looking for. Adding a small line of code after its initialized will print out the database ids of the current enemies for that skill.

targets.each {|target|
    if target.is_a?(Game_Enemy)
      puts target.enemy_id.to_s
    end
    }

Its not perfect, because other effects like reflect get calculated after that, but a good point to get started. Gonna work with that and see how it turns out.

It obviously does not handle the skill usage outside of battles, but i suppose it should work using the apply_item method and checking for $game_party.in_battle.


Edited by stderr, 23 July 2014 - 06:51 AM.


#1466 Evgenij

Evgenij

    Advanced Member

  • Ace Member
  • 90 posts
  • RM Skill - Coder

Posted 23 July 2014 - 08:07 AM

If you tell what you want to do when you have the enemy id, we could find some other solutions for your problem


logoaa.png


#1467 stderr

stderr

    Newbie

  • Ace Member
  • 7 posts

Posted 23 July 2014 - 04:11 PM

As i said, Im working on a skill system. The characters get Skillpoint XP for using skills on the enemy or healing skills on the party. If one character has enough XP that skill will level up and occasionally the character will learn new skills. Basically like Grandia 1.  I need the enemy database ID because every enemy has its "skillpoint modifier" and a "character max lvl" up until it can give skillpoint XP, for balancing obviously.



#1468 JunLi

JunLi

    ...?!?

  • Ace Member
  • 34 posts
  • RM Skill - Designer

Posted 23 July 2014 - 07:23 PM

I have a new question:
How would I go about pulling the contents of an array or hash individually?
 
Let's say I have "array = ["Hi", "Hello", "How are you?"]," and I want to show each greeting separately without calling each one individually. Basically, I want to mass-produce different objects that each call a different greeting. How would I go about doing that?

 
I hope I'm clear enough in my asking...


Current projects:

Spoiler

 

Finished Works:

Spoiler

 

 

I don't claim to be good, nor do I claim to know a whole lot. I do, however, have a lot of bad ideas. It's those bad ideas that spark good ideas, and that's what I'm all about.

 

I also have good ideas, but I rarely can bring them to fruition.


#1469 Trvc

Trvc

    Advanced Member

  • Ace Member
  • 32 posts
  • LocationCalifornia
  • RM Skill - Coder

Posted 23 July 2014 - 11:01 PM

I have a new question:
How would I go about pulling the contents of an array or hash individually?


array.each do |item|
  #code about item goes here
end

hash.each do |key, value|
  #code about key or value goes here
end

Current Project: Living World System. (I'll post about it eventually and when I do I'll link the post from this sig)


#1470 JunLi

JunLi

    ...?!?

  • Ace Member
  • 34 posts
  • RM Skill - Designer

Posted 24 July 2014 - 01:38 AM

That helped. Thanks.

Now, I've got another problem...

 

How do I go about running that method repeatedly, while changing a specific variable?

 

Example:

Spoiler

 

It works fine if I put in the specific variables for "i" and "id," but I want to basically run through a checklist automatically, pulling up the desired information. In this case, "i" would be the individual arrays (constants to access from), and "id" would be the specific fields (dynamically editable) I want accessed.

 

EDIT: Actually, I think I figured it out.


Edited by JunLi, 24 July 2014 - 01:59 AM.

Current projects:

Spoiler

 

Finished Works:

Spoiler

 

 

I don't claim to be good, nor do I claim to know a whole lot. I do, however, have a lot of bad ideas. It's those bad ideas that spark good ideas, and that's what I'm all about.

 

I also have good ideas, but I rarely can bring them to fruition.


#1471 stderr

stderr

    Newbie

  • Ace Member
  • 7 posts

Posted Yesterday, 10:40 AM

So, my skillsystem works so far. And ive managed to draw a scene where the progress is presented.

However, the handler for the "ok" button only gets called once? And i have no idea why.

Heres the pretty standard code:

class Scene_SkillProgress < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    @skillProgess_window = Window_SkillProgress.new(@actor)
    @skillProgess_window.set_handler(:cancel,   method(:return_scene));
    @skillProgess_window.set_handler(:ok,       method(:change_Page));
  end

  def change_Page

    @skillProgess_window.pageNumber += 1;
    @skillProgess_window.refresh();
  end

end

The called refresh method redraws the content based on the page number. Which works. However as said, i can only click once. After the first "ok" the whole handler processing for "ok" and "cancel" freezes.


Edited by stderr, Yesterday, 11:05 AM.


#1472 Trvc

Trvc

    Advanced Member

  • Ace Member
  • 32 posts
  • LocationCalifornia
  • RM Skill - Coder

Posted Yesterday, 02:18 PM

So, my skillsystem works so far. And ive managed to draw a scene where the progress is presented.
However, the handler for the "ok" button only gets called once? And i have no idea why.
Heres the pretty standard code:

class Scene_SkillProgress < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    @skillProgess_window = Window_SkillProgress.new(@actor)
    @skillProgess_window.set_handler(:cancel,   method(:return_scene));
    @skillProgess_window.set_handler(:ok,       method(:change_Page));
  end

  def change_Page

    @skillProgess_window.pageNumber += 1;
    @skillProgess_window.refresh();
    @skillProgess_window.activate();  # add this line here
  end

end
The called refresh method redraws the content based on the page number. Which works. However as said, i can only click once. After the first "ok" the whole handler processing for "ok" and "cancel" freezes.


Perhaps try adding this line?

Current Project: Living World System. (I'll post about it eventually and when I do I'll link the post from this sig)


#1473 stderr

stderr

    Newbie

  • Ace Member
  • 7 posts

Posted Yesterday, 04:27 PM

Omg it works!

Ty so much. :D

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users