How can I make a skill which does different things in and out of battle?

I want to make a Teleport skill which, when used in battle, causes the party to escape, but when used from the field, causes the party to warp back to a specified location in the central hub town.

Is this possible?
You should be able to use common event and add it to skill. Then make that common event just abort battle. That way it has an additional effect. Then add to that same common event after "abort battle" what else you want it to do.
You should be able to use common event and add it to skill. Then make that common event just abort battle. That way it has an additional effect. Then add to that same common event after "abort battle" what else you want it to do.
It won't cause a conflict? Like, the game won't crash if you try and run the escape battle command when not in battle? Or crash if you try and teleport when not on the field?

I also had another skill I wanted to do this with...

In Battle: Increases party's evasion.

Out of Battle: Halves encounter rate.
Close, but not quite.

Something like this will work:

Conditional Branch: Script: $game_party.in_battle? Abort BattleElse TeleportBranch EndYou'll have to look for the right commands to use for Escape and Teleport (maybe teleport using variables if you could go back to different locations, otherwise have another series of conditional branches to determine where to go).That way, there'll be no potential crashes by trying to escape when you're NOT in battle, and if you ARE in battle, it won't make you escape and then immediately teleport. You'll do one, or the other, but not both.
Close, but not quite.

Something like this will work:

Conditional Branch: Script: $game_party.in_battle? Abort BattleElse TeleportBranch EndYou'll have to look for the right commands to use for Escape and Teleport (maybe teleport using variables if you could go back to different locations, otherwise have another series of conditional branches to determine where to go).That way, there'll be no potential crashes by trying to escape when you're NOT in battle, and if you ARE in battle, it won't make you escape and then immediately teleport. You'll do one, or the other, but not both.
VMxFWsu.png


I did it exactly as you said (I only set it to teleport to one specific place) and it doesn't seem to work. Crashes upon using the warp skill.
it's $game_party.in_battle without the ?
Thanks Xypher. Sorry PushesTheButtons - I should have checked that.


The correct script to look at, if you'd wanted to follow it up yourself and are comfortable doing so, would be Game_Party.
it's $game_party.in_battle without the ?
It seems to work like that. 🙂

Thanks.

Edit: WAAAAAIT A SECOND!!

There's a problem!

This skill lets you escape from ANY battle, even boss battles!

This.... is a problem >_>

How can I fix this?
Make the skill only available in the battles you want to allow the player to escape from. Or use a switch to say when it should and shouldn't be allowed, and then add another condition inside the $game_party.in_battle check to see if the switch is on or off.


Are your battles random encounters set up on the map properties, or are they all events that use Call Battle Processing?
It seems to work like that. 🙂

Thanks.

Edit: WAAAAAIT A SECOND!!

There's a problem!

This skill lets you escape from ANY battle, even boss battles!

This.... is a problem >_>

How can I fix this?
When engaging a boss fight conditional branch: If Hero has Teleport Skill: Yes: Remove Teleport Skill. Then add Teleport Skill (another version, but with the same name and does nothing when used). At the end of the battle remove that Skill and add the regular spell back.

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-make-a-skill-which-does-different-things-in-and-out-of-battle.15978/