Jump to content
Sign in to follow this  
FrogBlots

A Poaching Skill? [HELP]

Recommended Posts

Hello. As you can probably tell I am new to the forum, and though I've been playing with RPGMaker since the Playstation version, I haven't put enough time and effort into it to be even remotely an expert. I didn't start learning about simple functions until about two months ago, and it's been a mere week and a half since I started looking into scripting. I do think it's fun, and am slowly (very slowly) picking up the lingo. I came to this forum in hopes for assistance.

 

I've been searching literally all day and have found nothing solid I could use to produce the desired effect myself, especially with my limited scripting knowledge, so I was hoping someone could help me out!

 

I've been using Yanfly's Class System, and decided to make a few classes with exclusive traits and skills. One such was a hunter class, that could potentially defeat a foe and obtain a pelt (or slime, or an exoskeleton, etc.) from it. My problem is...I don't know how to do that. I.E. I don't know how to make those drops specific to that class and ability.

 

I've made a few attempts, namely with Yanfly's Steal Item, but though I was able to put in an attribute for 'PELT', not only am I certain it did nothing (I'm amazed it didn't crash my game), but there's no way to destingquish a pelt from any other item even with notetags (Even if I was able to label the item <steal pelt>, there's still no way for the enemy to identify it as a pelt; there's no number for it as a pelt, only as an item).

 

I've thought of using modern algebra's drop options or tsukihime's tag manager to aid in this, but I still wouldn't know how to connect it exclusively to the Hunter class in that case (particularly the former), nor am I skilled enough in common events (and what I assume would require variables) to make it call-able.

 

I was wondering if anyone could make a script for such a thing? And if not, could they tell me how to do so without one?

 

I'd happily repay you in any way I could, and I think anything you could tell me would be a great learning experience for me.

Edited by FrogBlots

Share this post


Link to post
Share on other sites

Before I would give an answer, what would you like the skill to be?

 

Is it something necessarily accessible by one class?

Would the skill have a rate of success over getting pelt? Or only when the monster dies? etc.

Share this post


Link to post
Share on other sites

I would like it to be exclusive to one class, yes.

If at all possible, I'd like the success to be on a killing blow, but if that's too difficult to ask then a percentage of error is more than fine.

 

 

The steal type only works for "items" "weapons" "armor" and "gold". It says so right in the script :P

 

Haha, yeah. I don't know why I thought it would work. Further proof I'm a true beginner at this sort of thing.

Share this post


Link to post
Share on other sites

Hmm, could you be more specific what Killing Blow you mean? Anyways, assign a tag note called <poach> on a skill you want and paste this script on your script section:

module Poached_Items
  Poach_Item = 1 #id of item to be taken when using Poach Skill.
end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias skill_poach_skill_use   use_item
  #--------------------------------------------------------------------------
  # * Aliased Method: Use Skill/Item
  #--------------------------------------------------------------------------
  def use_item(*args)
    skill = args[0]
    if skill.is_a?(RPG::Skill)
      if $data_skills[skill.id].note =~ /<poach>/i
        $game_party.gain_item($data_items[Poached_Items::Poach_Item], 5)
      end
    end
    skill_poach_skill_use(*args)
  end
end

when ever you use the skill with the tag note <poach> on your skill database, you will gain an item depending on the item id given inside the module.

$game_party.gain_item($data_items[Poached_Items::Poach_Item], 5)

this section gains that item. 5 is the amount of the item you would gain. I didn't make any success rate since I want to know what rate you want it to be.

Share this post


Link to post
Share on other sites

I'm sorry for the lack of clarity. I meant if the poacher kills the enemy themself, but this is absolutely perfect! Thank you so, so much for the assistance, and if I could repay you in any way, let me know.

 

EDIT: Quick question: am I able to add more item ID # so more items could be stolen? If not it's fine. I am just curious.

I also seem to be having a difficult time making the move function in playtesting. I pasted the script and applied the ID # to the line that said Poach_Item = n. I also added <poach> to the skill notetag, and even gave the enemy the item to be safe. Is there something else I need to change?

Edited by FrogBlots

Share this post


Link to post
Share on other sites

If you want the item to be given only at the time the enemy dies, then we have to change a bit of the script.

 

Here's the script now:

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# [RGSS3] Poach Skill
# Author: Soulpour777
# Requested by: FrogBlots (rpgmakervxace.net)
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

module Poached_Items
  Poach_Item = [1, 2, 3, 4, 5] #id of item to be taken when using Poach Skill.
  Poach_Amount = 1 #amount of poached items
  Poach_Chance_Percentage = 1 #percentage of getting an item poached
  
  def self.poach_chance
    poach_chance_calc = rand(100)
    $game_system.poach_chance = poach_chance_calc
  end
  
end

class Game_System
  attr_accessor :poach
  attr_accessor :poach_chance
  
  alias poach_system_init initialize
  def initialize
    poach_system_init
    @poach = false
  end
  
end

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias skill_poach_skill_use   use_item
  #--------------------------------------------------------------------------
  # * Aliased Method: Use Skill/Item
  #--------------------------------------------------------------------------
  def use_item(*args)
    skill = args[0]
    if skill.is_a?(RPG::Skill)
      if $data_skills[skill.id].note =~ /<poach>/i
        Poached_Items.poach_chance
          if $game_system.poach_chance >=  Poached_Items::Poach_Chance_Percentage
            $game_system.poach = true
          end
      end
    end
    skill_poach_skill_use(*args)
  end
end

class Game_Battler < Game_BattlerBase
  def die
    @hp = 0
    clear_states
    clear_buffs
      if self.is_a?(Game_Enemy)
          if $game_system.poach
            $game_party.gain_item($data_items[Poached_Items::Poach_Item[rand(Poached_Items::Poach_Item.size)]], Poached_Items::Poach_Amount)
            $game_system.poach = false
          end
      end
  end
end

That will enable you to gain the item inside the array of Poached items list, not just one poached item. You can just assign them on this line:

Poach_Item = [1, 2, 3, 4, 5]

this means item 1, item 2, item 3, item 4 and 5, so you can just change what item id the pelts, skins, or any other item you want to get from the enemy. Also, it would only be given once they die.

Poach_Chance_Percentage = 1

this line is the percentage or number of chance to poach the item. You can just change it to 75 if you want the chance of getting a poached item at 75%. It is the rating of drop.

Share this post


Link to post
Share on other sites

This is absolutely amazing! Thank you so much for the help.

 

I still feel I must be doing something wrong, as I still can't get the skill to work in playtesting even with 100% accuracy, so I think I may be missing a step in all this. Do any components need a notetag besides the skill itself?

 

Sorry for all the questions. I make sure to try figuring it out on my own first.

Share this post


Link to post
Share on other sites

On your Skills tab, place the note tag <poach>. All skills tagged with <poach> will activate the Poaching Ability. You must save before playtesting for it to work when you installed the script :)

 

2dj1j1C.jpg

 

Note that the skill should be applied on the enemy, not on the Actor :)

Share this post


Link to post
Share on other sites

I thank you for being so helpful and incredibly patient with me. Even doing all that you instructed, I think I must be missing something important, since I just can't seem to get the skill to function properly. I'll provide as much visuals as I can in an effort to rectify my mistake.

 

Here is my dummy enemy.

RYmp1ii.png

I put the item in his drops, because I wasn't sure if it was necessary or not. The steals were there to test skills for the thief class.

 

This is the skill in its current form:

YOCmYhL.png

 

Here is the class I made to use the ability:

3uhEpVM.png

 

And here are the settings of the code as they are now:

0mFio1z.png

 

I tried to give the enemy the ability too, because I wasn't exactly sure what you meant by 'applied on', and I also attempted to give it the tag and got no results. If you can tell me where I went wrong it would help a lot, and thanks again for making this wonderful script.

Share this post


Link to post
Share on other sites

You did the instructions correctly. However, it would be unnecessary to include the Pelt drop on the enemy, since once you use Poach and the enemy dies, the item would be automatically included on your inventory (whatever item id the Pelt is).

 

The reason why it won't work for enemies is because of this script's section: 

      if self.is_a?(Game_Enemy)
          if $game_system.poach
            $game_party.gain_item($data_items[Poached_Items::Poach_Item[rand(Poached_Items::Poach_Item.size)]], Poached_Items::Poach_Amount)
            $game_system.poach = false
          end

it means that if the actor used the Poach Skill and the one that died was a Game Enemy, then would it be the only chance you will get a random item from the Poach Item list.

 

So let us set up your Poach Skill, for example, I added a <poach> tag on one of my skills. Whenever I use it on Battle:

 

ZdPx5Uo.jpg

 

Note that my Eric's Triple Attack is tagged with <poach>. Whenever I use it to kill a Slime and the slime dies... here's the result on my inventory:

 

ZMqCgJl.jpg

 

Now, the reason why you're not getting any item when you Poach a monster is because you gave a high percentage.

Poach_Chance_Percentage = 100

as you gave it is the highest :)

 

this means that only if the chance is equal or greater than 100 will you get an item. That means that the lower the Poach_Chance_Percentage is, the higher the chance of you getting an item.

 

try to set it up to 20 for play testing :)

Edited by SoulPour777

Share this post


Link to post
Share on other sites

Aha! Thank you for showing me how to fix my problem. It works perfectly now.

Again, this is a great script, and I appreciate the work you put into making it for me. I know I keep saying it, but if I can repay you for your kindness let me know. :)

Share this post


Link to post
Share on other sites

Just in case you do not want 100 as the highest rating for the drop, check this part of the script:

  def self.poach_chance
    poach_chance_calc = rand(100)
    $game_system.poach_chance = poach_chance_calc
  end

Notice that rand(100) there? it means that its going to compare that to your Poach_Chance_Percentage. You can change it to rand(400) for example. It means that the rating of chance is from 0 to 400. So if you placed 100 on your Poach_Chance_Percentage, it actually means that:

 

when you used the Poach Skill, a random number between 0 to 400 would be generated. if that number is higher or equal to your Poach_Chance_Percentage, then an item will be added on your inventory, whether it be Pelt, Skin, Bone, or any raw material that you may have added from the list.

 

Where goes the 400? It's the range. :)

Share this post


Link to post
Share on other sites

I'm a bit confused... which script is it that's used to add note tags again?

 

If you're talking about this script, its under the enemy.

 

If you're talking about note tags, it can be used anytime.

Share this post


Link to post
Share on other sites

I am not sure what you meant. Any script can do note tags. Note tags are like reminders and can be read inside a script. As far as I know there's no Note Tag reader script. This is because reading or scanning a note tag from note tags in the database are done depending on which script function that is.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×