That;s the general success flag, it is true if ANY effect is applied on the target (including damage, added states, other effects and stealing).
I haven't checked the steal script much, but this specific variable won't help in this case.
Checking for the stolen item won't help either, because that only stores the last stolen item, and not the amount of items the enemy still has.
Getting all the items the enemy has can be done with this line:
You must replace the enemy here with a valid
Game_Enemy object, such as:
Code:
$game_troop[index] # Gets the enemy at the index from the current troop
So, the variable mentioned returns an array of
RPG::Enemy::StealItem objects, which are simple objects with 3 variables, from which you only need 2 for checking their item type (weapon, armor, item or gold) and item ID.
Without adding more boring details, here is a shortcut method you can use to check if an enemy has the specified item or not:
Spoiler
Code:
class Game_BattlerBase
def check_pocket(type,id,amount=1)
itms = stealable_items.select {|it| it.kind == type && it.data_id == id }
return itms.size >= amount
end
end
Put this snippet anywhere below the default scripts.
You would use it like this:
Code:
enemy.check_pocket(type,id,amount)
The
type must be any of the following:
1 = Item
2 = Weapon
3 = Armor
4 = Gold
The
id must be the database ID of the item you check for.
And the
amount must be the amount of items you want to check for. You can also omit this argument, in which case 1 is used for this by default.
For example:
Code:
enemy.check_pocket(1,34,2)
This would return true if the enemy has at least 2 from Item 34 in their "pockets".
Now for actual usage...
For your first scenario, you would need an enemy AI script, I guess.
I saw some good ones which let you use scripted conditions for enemy skill usage in the enemy note-box. Get one of these (I think Tsukihime made one), and you should be able to use this code part in the note-tag:
Code:
check_pocket(type,id,amount)
Simply as that, since I guess, this piece of code will be executed on the enemy object itself, so no need to specify the enemy in this case.
For the second scenario, you can use this in the damage formula:
Code:
a.check_pocket(type,id,amount) ? formula1 : formula2
This checks if the attacker (so, the enemy) has the specified item or not.
If it has, execute
formula1, otherwise execute
formula2.
The formulas here are your own damage formulas, so enter whatever you want there, just like you do with your other damage formulas.
Using this means that the skill with these type of damage formulas must only be used by enemies!
Well, technically, you can use these skills even for actors, but the item check will always return false for them.
For the third scenario...
This can get complicated, since you can't use the damage formula for this one, because the stealing happens only after the damage is executed.
I don't have time to get this done, but with a little research, adding a little code here and there might make the trick.
You could try using common events, but I don't remember how to get the last target of the actors for the item check, so this requires some research too.
Anyway, coffee disappeared, so my break is over.
😀
Ohh, and as a final note, I did not test anything I wrote, so in case it doesn't work, don't punch me!
😛