Using attack chains as nested if-then statements

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Using attack chains as nested if-then statements

Post by Foxley »

Hey, I have something that I just realized I haven't really tested out in OHRRPGCE's battle engine: using attack chain logic to do flowcharty things like:

"If your character's STR is a high enough number, and also if your DEX is a high enough number, you have % chance to use a new stronger attack instead of one you already have, and learn it permanently after battle" (set 'learn X attack' tag to ON, do after-battle tag check script)

This SaGa-esque type of ability discovery mechanic is a really big part of what I want to do in my main RPG project, the one I started around mid 2014. I was thinking that if the initial attack got its chain requirements met, then it could then chain to something else that also has chain-to-something-else requirements that could also be checked for. And then ultimately it'll lead to some sort of attack, based on requirements and also % chance.

Something sort of like this:

* Starting attack is 'Punch'
- If STR is >= 30, Punch chains to 'Punch2'; else do 'Punch'
- If DEX is >= 25, Punch2 chains to 'Punch3'; else do 'Punch'
- 40% chance for Punch3 to chain to 'SuplexLightbulb' (self-targeted lightbulb animation); else do 'Punch'
- SuplexLightbulb chains to 'Suplex', sets "suplex learned" tag to ON

Does anyone have any insights on if this sort of thing is possible or not? I took a sick day today so I might get around to setting up some test scenarios. I think this is also going to be a determining factor on if I want to keep making this game in the OHRRPGCE or move the assets I've done over to Game Maker. I'll definitely still finish Hollowkeep in OHRRPGCE though (eventually!)
User avatar
Mogri
Super Slime
Posts: 4668
Joined: Mon Oct 15, 2007 6:38 pm
Location: Austin, TX
Contact:

Post by Mogri »

Yes, you can do this. You'll want something more like this:

The base attack is 'BasePunch' - this attack has no animation and does no damage. The attack used if the stats are insufficient is 'BadPunch,' and if the stats are good, 'GoodPunch' is used.

BasePunch:
If STR > 29, use GoodPunch instead.
Chain to BadPunch normally.

GoodPunch:
If DEX < 25, use BadPunch instead.

BadPunch:
No chaining.


So BasePunch is used to detect one of the stats, and GoodPunch filters for the other. BasePunch is a dummy attack, and if you wanted to filter for more than two stats, you could add extra dummy attacks in the chain.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Very good! It does work. Thanks for the advice on a more simple chaining process too, mine was really convoluted. Then again, I sort of made it convoluted on purpose to stress test its ability to do multiple attacks' Instead-Chain checks instantly.

This is exciting, can't wait to put this sort of thing to use in the real game project.

Now I just wish that having attacks/abilities could be tag-based instead of just either level-based or learned from item... That would be really cool to have dynamic skill sets affected by tags mid-battle. For instance, having certain battle conditions give a character a plot-related skill - e.g. seeing an enemy crying inspires sympathy in your hero and they can then use Hug from a skill menu to comfort the crying enemy. Incredibly lame example, but yeah.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Tag based tag learning would definitely be a great feature, one worth prioritising. I see James actually documented it in the file format, but hasn't implemented it yet.
Post Reply