• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Substitube's Charms

Resource Substitube's Charms 2023-05-12

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
493
wrigty12 submitted a new resource:

Substitube's Charms - Graphics for most of Substitube's Charms

I recently watched Substitube's Charms video, and decided to add yet another collectable to my game; so I attempted to turn their charm ideas into sprites!

These are just sprites. No code for these to work provided (at least, yet!)

Missing: Link Charm (wasn't going to use it, and I didn't like how my rough attempt looked)
Changed: Key Charm (The version Substitube created looked odd when I tried spriting it, so I tried...

Read more about this resource...
 
Ooh, I was just thinking about how fun these all seemed! Here's the code for most of them! (I feel like you've definitely done the harder work with spriting them lol, most of these are just a few lines)

I did skip a few of these -
  • Link Charm, because I'm not familiar with chaining mechanics
  • Seeker Charm, because I think something that involves checking for reloaded saves and altering events is going to be a little complex
  • Balance Charm, same thing but for rewriting encounter probabilities
  • Twin Charm, because even though the multiplying is simple, I can't for the life of me figure out how to get the name of the currently-running event
I haven't playtested any of this - I assumed, since these are all just checks for if there's an item in the bag added to existing mechanics, that quick copies would work fine, but feel free to let me know if something's gone wrong/if I've left any typos here!
Substitube didn't give exact numbers here, so I'm going to just give a flat $5000. You could toy around with this number however you like - base it on average party level, foe's skill level, etc.

In Battle_StartAndEnd, right above these lines -
Ruby:
    # Pick up money scattered by Pay Day
    if @field.effects[PBEffects::PayDay] > 0
Add:
Ruby:
    @field.effects[PBEffects::PayDay] += 5000 if $bag.has?(:GOLDCHARM)

Alternatively, say you'd like this to work like the Amulet Coin -

In Battle_StartAndEnd, right below these lines -
Ruby:
      tMoney *= 2 if @field.effects[PBEffects::AmuletCoin]
      tMoney *= 2 if @field.effects[PBEffects::HappyHour]
Add:
Ruby:
      tMoney *= 2 if $bag.has?(:GOLDCHARM)
In Overworld_WildEncounters, right above this line -
Ruby:
  # Trigger events that may alter the generated Pokémon further
Add:
Ruby:
  if ($bag.has?(:SMARTCHARM) && rand(100) < 50)
    specialmoves = genwildpoke.species_data.tutor_moves + genwildpoke.species_data.get_egg_moves
    genwildpoke.learn_move(specialmoves.sample)
  end
(This will also sample TM moves - I can make a utility script to distinguish between TM and tutor moves, but I wanted to keep it simple here)
In Overworld_WildEncounters, right above this line -
Ruby:
  # Trigger events that may alter the generated Pokémon further
Add:
Ruby:
  genwildpoke.ability_index = 2 if ($bag.has?(:KEYCHARM) && rand(100) < 50)
(Note that this assumes that Pokemon only have one possible Hidden Ability and two possible regular abilities, you may need to play around more if you've changed how abilities work.)
In Overworld_WildEncounters, under this section -
Ruby:
    # Some abilities alter the level of the wild Pokémon
    if first_pkmn
      case first_pkmn.ability_id
      when :HUSTLE, :PRESSURE, :VITALSPIRIT
        level = encounter[3] if rand(100) < 50   # Highest possible level
      end
    end
add this line:
Ruby:
    level = encounter[3] if $bag.has?(:PROMOCHARM)   # Highest possible level
Substitube said this would always happen, rather than being a 50% chance of happening like with Pressure, but if you want it to be chance-based as well, you'll add this instead:
Ruby:
    level = encounter[3] if ($bag.has?(:PROMOCHARM) && rand(100) < 50)  # Highest possible level
In Overworld_Fishing, change this line
Ruby:
  speedup = ($player.first_pokemon && [:STICKYHOLD, :SUCTIONCUPS].include?($player.first_pokemon.ability_id))
to
Ruby:
  speedup = (($player.first_pokemon && [:STICKYHOLD, :SUCTIONCUPS].include?($player.first_pokemon.ability_id)) || $bag.has?(:LURECHARM))
In Overworld_WildEncounters, above this line -
Ruby:
itemrnd = rand(100)
add
Ruby:
  chances = [60, 20, 5] if $bag.has?(:CLOVERCHARM)
Note that this means that the Clover Charm doesn't stack with Compound Eyes. I might toy around with an easy way to make them stack, I'll come back to that idea.
In Overworld_WildEncounters, change this line
Ruby:
    elsif first_pkmn.hasAbility?(:SYNCHRONIZE)
to
Ruby:
    elsif first_pkmn.hasAbility?(:SYNCHRONIZE) || $bag.has?(:SPIRITCHARM)
This will keep Synchronize's rate, so whether it's 100% or not depends on the MORE_ABILITIES_AFFECT_WILD_ENCOUNTERS setting. (Or you can mess around with it however you want, of course, I'm not the boss)
I've simplified this a bit. Substitube's checked if your Pokemon had just fainted in your last battle, and only lasted until the next encounter - that'd add a bit of work to keep track of. So instead, this just checks if any of your Pokemon are fainted,

In Overworld_WildEncounters, right above this line -
Ruby:
if !Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
add
Ruby:
    if $bag.has?(:MERCYCHARM) && $player.able_pokemon_count < $player.pokemon_count
      encounter_chance /= 2
      min_steps_needed *= 2
    end
This will make it apply if the player has any fainted Pokemon in their party. If you want to be extra generous, you could change pokemon_count to party_count, and it would apply if the player had an egg in their party, too.
There's a few places to change, since it has a variety of effects.

For Pokemon being less likely to flee, in Battler_UseMove, change these lines -
Ruby:
    if tryFlee && wild? &&
       @battle.rules["alwaysflee"] && @battle.pbCanRun?(@index
to
Ruby:
    if tryFlee && wild? &&
       @battle.rules["alwaysflee"] && @battle.pbCanRun?(@index) &&
       (!$bag.has?(:HEARTCHARM) || (rand(100) < 50))
This is a 50% chance of fleeing if the player has a Heart Charm, compared to a 100% otherwise if the Pokemon could flee.

For the increased encounter rate, in Overworld_WildEncounters, right above this line
Ruby:
if !Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
Add
Ruby:
    if $bag.has?(:HEARTCHARM)
      encounter_chance *= 2
      min_steps_needed /= 2
    end

For happiness increasing with each step, in Overworld, under this line:
Ruby:
      pkmn.changeHappiness("walking") if rand(2) == 0
Add:
Ruby:
      pkmn.changeHappiness("walking") if $bag.has?(:HEARTCHARM)
Happiness mechanics are surprisingly more in-depth than I realize, so to clarify a little more: This doesn't double happiness gain, but instead applies the benefit twice. The reason why that matters is because happiness-raising actions offer diminishing returns as happiness increases- for example, walking increases by 2, but by 1 if happiness is greater than 200.

So, with this setup, if a Pokemon was at 199 happiness, they would receive +2 happiness for the regular step (if the random chance occurred), and then +1 for the Heart Charm, bonus, because now they're at 200 happiness. So that comes out to +3 happiness instead of +4 if the happiness was just doubled.

If you'd like the Heart Charm to just increase all happiness gains, then instead of all this, you could go to the script section Pokemon and add something there. You could do like the Luxury Ball and just add an extra point for having it in the bag -
Ruby:
      gain += 1 if @poke_ball == :LUXURYBALL
      gain += 1 if $bag.has?(:HEARTCHARM)
Or you could do a multiplier like the Soothe Bell.
Ruby:
      gain = (gain * 1.5).floor if hasItem?(:SOOTHEBELL)
      gain = (gain * 1.5).floor if $bag.has?(:HEARTCHARM)
Substitube didn't mention the exact odds, so I'll just point to this line in Overworld_WildEncounters -
Ruby:
  # Give Pokérus
  genwildpoke.givePokerus if rand(65_536) < Settings::POKERUS_CHANCE

If I wanted to do, say, 50% chance with the viral charm, I could change it to this:
Ruby:
  # Give Pokérus
  genwildpoke.givePokerus if (rand(65_536) < Settings::POKERUS_CHANCE) || ($bag.has?(:VIRALCHARM) && rand(100) < 50)
 
Last edited:

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
493
I was playing with the code too. I did Balance Charm and Twin Charm in the following way:

Balance Charm - I think what I figured out works well
In Overworld_WildEncounters > choose_wild_pokemon function, add
Ruby:
if $bag.has?(:BALANCECHARM)
    enc_list.each { |e| e[0] = 100/enc_list.length }
end
before
Ruby:
enc_list.sort! { |a, b| b[0] <=> a[0] }   # Highest probability first

Twin Charm - I just added one line to the pbItemBall funciton, since that's is where this would apply.
Ruby:
alias tdw_charm_item_ball pbItemBall
def pbItemBall(item, quantity = 1)
    quantity*=2 if $bag.has?(:TWINCHARM) && !GameData::Item.get(item).is_important?
    tdw_charm_item_ball(item, quantity)
end
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
For the twin charm, shouldn't it scan for just hidden items, and not all ItemBalls? ItemBalls would double all items... You could use something like this for just hidden items.

Ruby:
  event_name = $game_map.events[@event_id].name  # Use the event_id to get the event and its name
  if event_name[/hiddenitem/i] && $bag.has?(:TWINCHARM)
    quantity *= 2
  end
 

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
493
@wrigty12
Before I start a charm case, have you had any progress on yours?
I did create one for my game. However, I made it in a way that was kinda hacky so I didn't feel like it was releasable as a plugin. I can always try to compile what I did and send it your direction
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
I did create one for my game. However, I made it in a way that was kinda hacky so I didn't feel like it was releasable as a plugin. I can always try to compile what I did and send it your direction
I would greatly appreciate it. I saw you were talking about working on one, so I didn't want to spend time on it, if there's a template out there. I'll make sure to credit you, and if I can improve it, I'll send it back to you.
 
Back
Top