KBlockStates ACE

KBlockStates ACE

by Kyonides
​

Introduction

This script prevents your heroes or your enemies from choosing a target that is still afflicted by a Blocked Target alias Untargetable State.

Set the value of the TARGET_STATE Constant found in the KBlockStates module to your list of Untargetable State IDs.

Other Notes

This scriptlet seems to work with the default battle system so feel free to try it in your game project.
I have not tested it while using any other battle system.
The only reason why I came up with this idea was because Hime's script had a weird bug that has remained untouched ever since 2015...


Terms & Conditions

Free for use in your game.
Include my nickname in your game credits.
That's it.
A Convenient Script Update!​

This new installment of my enigmatic script now prevents you from using skills that target enemies if there is no enemy free of the Block Target State aka Untargetable State. Since the attack command is just a call to the Attack skill, it also gets blocked in no time. This prevents you from getting a no index error at all.

Happy Waiting Till Your Target Gets Unblocked! 😛​
This works nice now. Tried it with items, spells, and with or without anything being untargetable.

I tested it for several hours now and all seems fine—including during a boss fight where the boss "eats" a certain character creating the untargetable state (can't target anyone if they are in the boss's stomach). The others got to fight to help him out.
You just made me draw a nasty picture in my mind that I wish I can soon forget. 😛
Your description sounded too vore-ish for my taste. XD
@kyonides

Your script becomes broken when you try to add more than one state to the list.

Capture.JPG


When you try to add a second or third state to become an untargetable state, it nullifies ALL untargetable states allowing the user to target character effected with the states listed in the script.

State 20 works if it is alone, but if you add state 47 or add any other state such as 48, the character is able to be targeted even if they have state 20, 47, or 48 applied.

Hime's script, as broken as it was, states were still untargetable when you added a second or third untargetable state. With yours, just adding one more state, makes every state listed in the script targetable in the game.
@kyonides

Your script becomes broken when you try to add more than one state to the list.

When you try to add a second or third state to become an untargetable state, it nullifies ALL untargetable states allowing the user to target character effected with the states listed in the script.

State 20 works if it is alone, but if you add state 47 or add any other state such as 48, the character is able to be targeted even if they have state 20, 47, or 48 applied.

Hime's script, as broken as it was, states were still untargetable when you added a second or third untargetable state. With yours, just adding one more state, makes every state listed in the script targetable in the game.
It's designed for one state only. Just wait and Kyonides may alter it for multiple states
It's designed for one state only. Just wait and Kyonides may alter it for multiple states


I would appreciate if he can do that. Is that something you can do, @kyonides ?
Script Updated!​

Now it allows you to set different Block States in a list (an Array [something, here] object).
It also includes a bug fix for the Healing Block State.

@MoltresRider From now on you would need to use the new KBlockStates Script instead of the old one you have been using so far. It changes the configuration a little bit...

Ruby:
module KBlockStates
  ATTACK_STATE = 26
  HEALING_STATE = 27
  # Pick your favorite Blocked Target State IDs, i.e. [3, 5, 7]
  TARGET_STATES = [28]
  # some extra lines of code here
end
Can I remove

ATTACK_STATE = 26
HEALING_STATE = 27


If I do not want any states to be non-healable or not allowed to attack physically? and the script still work?

Or can I just set the values to 0 if I do not want them?


Edit: I downloaded the new script and added three states to the blocklist but the code is STILL broken! I can STILL target characters affected by an untargetable state!

I tested it with state #48 which is listed as block but I still was able to target him. He still shows up in the list of what I can target

Ruby:
module KBlockStates
  ATTACK_STATE = 0
  HEALING_STATE = 0
  # Pick your favorite Blocked Target State IDs, i.e. [3, 5, 7]
  TARGET_STATES = [20, 47, 48]
  def self.random_target_state_id
    pos = rand(TARGET_STATES.size)
    TARGET_STATES[pos]

And I was still able to use an item on someone who had state #48 inflicted
.
It's weird because in the demo State #28 does block a hero and an enemy, removing them from the lists of targets. It does that after randomly selecting a state ID. Since it only features one state ID, it will always pick the same ID. Then the random team member gets delisted so to say.

I will check that out later today but it'd be good if you could provide me with some screenshots.

By the way, I think I haven't dealt with items as of yet...
It only works when you define only one state. Adding multiple states seems to nullify all states listed in the block list
Why do you need more than one block target state anyway?

EDIT:
The next version of my script will include a block for items...
I'm able to make 2 identical states work as an untargetable state. I don't know what you've been doing that prevents you from properly using more than 1 state at any given time in battle.
Another Update Has Arrived!​

This time it includes a check or two to make sure some of the previous features work as intended. This includes the inability to use items to favor some untargetable friend or even a foe.

Even so, that's not the end of it! 😀

Now it allows you to magically (RM state-wise) Seal Your Bag! 😮

:eswt:I know, that doesn't sound like a popular feature, does it?
But don't worry, my friends! :ewink: It only works in battle and for certain heroes, the ones afflicted by that state.

Really? Or did you even think for a moment that mobsters like witches, zombies, wizards, dark elves and others would love to see you consume potions and elixirs to get cured or replenish your mana points right away?

Of course not! 😛​
Small Update​

Version 1.0.0 has been published and it brings a change in how "untargetable" your foes are.

If you need the state to TOTALLY prevent your foes AND your allies from choosing a battler with that specific state, include the state ID in the TOTAL_BLOCK_TARGET_STATES array.

Perhaps you might prefer to just block your foes from targeting you, then include the state ID in the PARTIAL_BLOCK_TARGET_STATES array instead.

Ruby:
module KBlockStates
  ATTACK_STATE = 26
  HEALING_STATE = 27
  SEALED_BAG_STATE = 28
  # Pick your favorite Blocked Target State IDs, i.e. [3, 5, 7]
  TOTAL_BLOCK_TARGET_STATES = [29]
  PARTIAL_BLOCK_TARGET_STATES = [30]
  def self.random_target_state_id
    pos = rand(TOTAL_BLOCK_TARGET_STATES.size)
    TOTAL_BLOCK_TARGET_STATES[pos]
  end
end
Targets Updated!​

Since version 1.1.0 has been released, you are now able to pick a skill scope, namely All Enemies and leave a specific note in the Skill Note Box to apply its effects on Dead Enemies only.

Note Tag for Dead Enemies
Ruby:
<dead enemies>
With the latest version of the script, I always get a crash whenever I select "Items" from the menu

Code:
KBlockStates ACE:308:in `exclude?': undefined method `scope' for nil:NilClass, NoMethodError
    from KBlockStates ACE:322:in `include?'
    from Sorting:5:in `make_item_list'
    from Window_ItemList:113:in `refresh'
    from KBlockStates ACE:299:in `actor='
    from KBlockStates ACE:329:in `command_item'
    from Kyonides BattleItems ACE:28:in `command_item'
    from Window_Selectable:212:in `call'
    from Window_Selectable:212:in `call_handler'
    from Window_Command:136:in `call_ok_handler'
    from Window_Selectable:322:in `process_ok'
    from Window_Selectable:297:in `process_handling'
    from Window_Selectable:276:in `update'
    from Scene_Base:95:in `block in update_all_windows'
    from Scene_Base:93:in `each'
    from Scene_Base:93:in `update_all_windows'
    from Scene_Base:49:in `update_basic'
    from Screenshot Take:155:in `update_basic'
    from Scene_Battle:56:in `update_basic'
    from Scene_Base:41:in `update'
    from Scene_Battle:45:in `update'
    from Scene_Base:14:in `main'
    from SceneManager:22:in `run'
    from Mapshot:986:in `run'
    from Screenshot Take:167:in `run'
    from Backtrace:10:in `block in <main>'
Maintenance Update
Version 1.1.2 Has Been Released!
​

This new release includes 2 bug fixes, namely one related to the nil item (caused by a fake item slot in the Window_ItemList class) & a missing valid_targets? method in the Game_Troop class.
Now the demo should run smoothly without any issues.
Have you considered making this script compatible with Yanfly's battle engine? This seems like the more stable of the few untargetable state scripts out there, but when paired with Yanfly's battle engine for some reason items/skills targeting the user/other actors cause a crash

Original thread: https://forums.rpgmakerweb.com/threads/kblockstates-ace.157086/