Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RPGXP: Battle engine redux?

Omio

Member

Alright, so lemme kick off by saying that I do have a limited knowledge of scripting.

However, something I notice more often than not is that I need to choose something that RPG Maker XP doesn't consider valid (ie. enemy and skill-user, or all allies AND enemies), and I'm looking for variables that are hard-to-fetch (ie. skill user's [HP/total] as %).

All I'm requesting is a system that allows for a bit more flexibility in whom/what to choose for variables. If it's injections into Game_BattleAction and a few other places, then I'm all for it, and I AM willing to collaborate with any potential takers. If it's just Common Events pointing to a custom-scripted event, then that's also very much viable as a "toolkit" for people to use on here too.
 
I don't know about allies and enemies, but for something like HP percent, you can use the event commands
d900695bd3.png

Is there anything else you'd need the script to do?
 

Omio

Member

The script would need to enable something like being able to "swap" a user's HP with an enemy by % (your example helps a bit, thanks) for the most part. Other things, I can probably add on my own afterward, I just really can't tangle with the scripting engine that well when it comes to battles.

To run through the process:

Case 1:
> At <30% HP, enemy uses "Swap" skill.
>> Target's new HP = (Enemy's HP/Enemy's MaxHP)*Target's MaxHP
>> Enemy's new HP = (Target's HP/Target's MaxHP)*Enemy's MaxHP
> Battle resumes like normal afterward.

Case 2:
> Enemy uses "Homemade Explosive" skill.
>> if rand(20)>10: Targets opposite party, else: targets EVERYONE.

I have a feeling now that everything I'm asking for is natively supported somewhere. ><;

Edit: I'm trying to think of other cases where the script I suggested would actually come in handy, but I can't think of anything serious that's all that useful. >.<;
 
Oh for enemies too, right. How could I miss that? XD
To access the current battler's information, you can put this anywhere and then you can read their info with a script call.
Code:
class Scene_Battle

  attr_reader :active_battler

  attr_reader :target_battlers

end
Then use $scene.active_battler or $scene.target_battlers in a script call in a common event. It will work in a battle event though, but it will use whatever enemy is currently attacking when the code fires, so be careful.
Also, use $scene.target_battlers[0] if there is only one target as it is an array of battlers.
To do your swap skill, it'd be something like this (this is purely theoretical, I haven't tested it)
2b4a427958.png


It's very difficult to fiddle with the targeting system that's implemented, and from quickly browsing over it, I can't seem to find an effective way to do so. Perhaps someone else here is more familiar with the battle system and can show me otherwise :P
In the mean time, I suggest creating two copies of the skill and one which triggers the other two. Run the calculations in the first common event and then force a skill use of one of the other two.
 

Omio

Member

So, after following your suggestions...
f728c97f14.png

73b7f28e13.png
...and fully implementing it for testing...
c4625984e4.png
...I get this:
5587787b69.png


Testing with $scene.target_battlers[0] on the first line to see if that makes a difference...

...It says "Miss", but it actually procs! WE LIVE!

Here's the edited code for anyone else that was reading along, I personally slapped it as a Common Event, but as long as it's a script handled by RPG Maker XP's 'Script...' function, and called in battle, you should be fine.
Code:
t=$scene.target_battlers[0]

c=$scene.active_battler

 

thp = (c.hp.to_f/c.maxhp.to_f)

chp = (t.hp.to_f/t.maxhp.to_f)

 

t.hp = (thp*t.maxhp.to_f).to_i

c.hp = (chp*c.maxhp.to_f).to_i

Summary of thread so far:
Inject this in Scene_Battle:
Code:
class Scene_Battle

  attr_reader :active_battler

  attr_reader :target_battlers

end
Make the 'Swap' attack call this script:
Code:
t=$scene.target_battlers[0]

c=$scene.active_battler

 

thp = (c.hp.to_f/c.maxhp.to_f)

chp = (t.hp.to_f/t.maxhp.to_f)

 

t.hp = (thp*t.maxhp.to_f).to_i

c.hp = (chp*c.maxhp.to_f).to_i
...and you're laughin'.
-------------------------------------------------------
Now, case #2: Targeting all enemies and all party members. (Currently working on that)

Edit: ...I've introduced an animation bug, but... ...I managed, though the results are a little buggy! xD
Injected into Scene_Battle 4:
58195e8d9f.png

and
a73fc28162.png

There's a little extra stuff for you to figure out your way there. Anyways, onto the Common Event:
12fc44c601.png

Here's the copy/pasta code I have:
Code:
$scene.set_target_battlers(8)

$scene.make_skill_action_result

$scene.update_phase4_step3

$scene.update_phase4_step4

$scene.update_phase4_step5

$scene.update_phase4_step6
Just set up the rest, and... ...success?

Known bug(s): The attack doesn't get the post-attack delay?

Edit: Spoiler'd the images so they're not all gaudy and gross right off of the bat. =P
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top