I can get you very close to what I think you want.
Just add the these three extra lines to item_apply method in Game_Battler, in the place I've added them in the code block below:
if item.is_a?(RPG::Skill)
user.remove_state(27)
end
(replace "27" with the ID of your Stealth state)
#-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (
[email protected] && rand < item_eva(user, item)) if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end if item.is_a?(RPG::Skill) user.remove_state(27) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) end endFor these purposes, RPG Maker VX Ace actually considers attacks to be a Skill, so the Stealth will be removed by using any attack or skill, but not by item usage.
The only catch is that the Stealth state will NOT be removed if the attack/skill misses. As you can see, it is inside a "result.hit?" block. You could move those lines above this block, but then I think the "increased critical hit rate" feature of Stealth would be ignored because the crit rate isn't determined until a bit later. Or you could move those lines below this block, but that will cause any skill that applies Stealth to immediately remove it, because the Rogue just used a skill. So if the Rogue gains Stealth by some other means besides using a skill to apply it, you can go this route, and the Stealth state will be removed even when the attack/skill misses.