[XP] Taunt States

Started by G_G, April 07, 2012, 11:54:27 am

Previous topic - Next topic

G_G

Taunt States
Authors: game_guy
Version: 1.0
Type: State Modification
Key Term: Battle Add-on



Introduction

When Taunting an enemy, the taunter has a higher chance of being attacked by all enemies. This script, rather than using skills, it uses states to control the taunt levels.


Features


  • Customizable Taunt States

  • Can Even Be Used to Avoid Attacks




Screenshots

N/A


Demo

N/A


Script

Spoiler: ShowHide

#===============================================================================
# Taunt States
# Version 1.0
# Author game_guy
#-------------------------------------------------------------------------------
# Intro:
# When Taunting an enemy, the taunter has a higher chance of being attacked
# by all enemies. This script, rather than using skills, it uses states to
# control the taunt levels.
#
# Features:
# Customizable Taunt States
# Can Even Be Used to Avoid Attacks
#
# Instructions:
# Hop down to the CONFIGURE STATES area and you'll add your state and taunt
# configurations there. Taunt can be reversed to also Avoid attacks. To do
# this, simply set the taunt level to a negative number. The number you assign
# to the state, is the number of times it'll add/remove the member to the
# roullette when being attacked by enemies.
#
# Now to have an actor "taunt" the enemies, all you need to do is give him a
# taunt state, which can easily be done through skills or items.
#
# Credits:
# game_guy ~ Creation of this fine script.
# GrimTrigger ~ For requesting it.
#===============================================================================
module TauntStates
  STATES = {
  #=========================
  # CONFIGURE STATES
  # -Add new lines.
  # state_id => taunt_level,
  #=========================
    17 => 1,
    18 => 2,
    19 => 4,
    20 => -4,
  }
end

class Game_Actor < Game_Battler
  def calculate_taunt
    taunt = 0
    TauntStates::STATES.each {|key, value|
      taunt += value if @states.include(key)}
    return taunt
  end
end

class Game_Party
  def random_target_actor(hp0 = false)
    roulette = []
    for actor in @actors
      if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
        position = $data_classes[actor.class_id].position
        n = [4 - position + actor.calculate_taunt, 1].max
        n.times do
          roulette.push(actor)
        end
      end
    end
    if roulette.size == 0
      return nil
    end
    return roulette[rand(roulette.size)]
  end
end



Instructions

In the script. Place above main. The usual. ;3


Compatibility

Should be compatible with anything, any battle system, assuming it uses the "random_target_actor" method from Game_Party.


Credits and Thanks


  • game_guy ~ Creation of this fine script.

  • GrimTrigger ~ For requesting it.




Author's Notes

Enjoy my probable last script!

KK20

Hah, that was the idea I was gonna use. Thanks for typing this out so I didn't have to. :D

Looks good to me. I'm surprised that something as easy as this can't be found with a quick Google search. Also sounds like a good ToA script.

*tosses Rare Candy*





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

GrimTrigger

There's a problem when I go to test this out.


Script 'taunt' line 47: NoMethodError occurred.

undefined method 'include' for  []:Array


I'm testing this using the troop battle test window, 4 characters. Have a skill to apply the state....

#=========================
  # CONFIGURE STATES
  # -Add new lines.
  # state_id => taunt_level,
  #=========================
    17 => 1,
    18 => 2,
    19 => 4,                        <=======(this one I'm trying to apply with a skill)
    20 => -4,


Not entirely sure if I'm doing it wrong, or if the script has an error.

KK20

It's a typo. Go to Line 47 in the script, which should be:
taunt += value if @states.include(key)}


Add a question mark after include:
taunt += value if @states.include?(key)}





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

GrimTrigger

I did and I no longer get the error message. I tested it out, but saw no real difference in the "Taunter" being attacked. With four enemies, and four characters, he didn't appear to be getting focused fired, or even hit more than usual

G_G

Hmmm. try increasing the 4 then. Maybe to 10 for a noticeable difference.

GrimTrigger

Quote from: game_guy on April 08, 2012, 12:53:12 am
Hmmm. try increasing the 4 then. Maybe to 10 for a noticeable difference.


I doubled it and saw no real difference. I used a value of 100 and saw that it did make the enemies (5 now that I'm testing) hit the intended character about 80-90 percent of the time. At 300, it was essentially pure focus fire (which is what I want.) Perhaps the way RMXP handles it's roulette is based on large numbers (I think somewhere I read that RMXP doesn't perform as well with small numbers, but it might not be the case for this specific issue.)

So far no problems. Thanks!

lipucd

Honestly this was something I was looking for.
For a game project I'm developing I wanted a way to make attacks go elsewhere if under select status effects ( such as unable to move, yet others could still act ). With this I think I can at last get results close to what I would like. It's not perfect as it seems like with big groups the change in attacks doesn't happen till the start of the next round, and sometimes they will STILL target someone even under said status when I give them -500 or something and there are others lacking it. Still, the fact that it does effect the desision making, so that I can have status' spread around more evenly is VERY nice!

KK20

The reason why a state that gives -500 won't work is because of this line right here:
n = [4 - position + actor.calculate_taunt, 1].max
The smallest value you can have is 1. If you really wanted to, you can modify the equation to fit your needs. But whatever you do, 1 must always be the minimum value (or unspeakable errors occur). You can do something like:
n = [50 - position * 10 + actor.calculate_taunt, 1].max
But that's up to you to decide.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

G_G

There was a reason I made it limit it to 1. First of all, nothing happens when you iterate a negative number. The block never gets executed. But think about it, if you have all members with 0 or less, then enemies won't be able to attack at all. I wouldn't find something like that very fun in a game at all. I guess thats just me, if you really want to change it, just use this instead.
n = 50 - position * 10 + actor.calculate_taunt