Jump to content
  • Advertisement
Sign in to follow this  
Mysterious Bakemono

RPG effect resolution flow.

This topic is 899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm about to begin implementing the effect resolution aspects for my RPG's ability system, and I was hoping to get a little feedback before I finalize the design.  I've never worked on the real meat of an RPG, and I've only ever worked with RPGs on a surface level where all of this is already handled, so I'm going into this with no guidance.

The premise is simple:  Various abilities, status effects, and gameplay mechanics will need to know what's going on through events, so they can respond appropriately.  As such, an attack sends an AttackData package through the target's damage function.  The function feeds the data through a few events, so that various game mechanics can respond and change the outcome of the AttackData.

 

Those events are as follows:  AttackIncoming > (if hit) AttackHit > AttackApply > (if damage) ApplyDamage > (if status effect) ApplyStatusEffect.

A few examples of things that could affect outcome are dodging, which would apply during the AttackIncoming event and negate the attack entirely.  A passive Block ability might trigger during the AttackHit event, and reduce damage taken.  A wizard might be able to restore some of his magic when the ApplyDamage event is triggered by a magic spell.

What do you think of this design, and how would you improve upon it?

Edited by Mysterious Bakemono

Share this post


Link to post
Share on other sites
Advertisement

Without knowing much about your game this sounds overly complex. Is it necessary to do this via events for your game rather than through a small system directly? For a direct hit (swinging a sword for example) you could manage that with a simple function that takes attacker info, defender info and attack info. The function would first check if it's a hit or a miss my comparing attacker accuracy and defender evasion, if no hit it returns. Next is could compare something like strength (damage) versus armour and so on.

 

Plenty of other direct ways to do this but personally I would favour the direct approach rather than indirect (events) methods but you know your game best and what would most suit your design. Consider a projectile, some games would fire the projectile and decide before hand if it will hit or not, others would let the arrow fly and then decide on impact. A game that uses more player skill than stats would benefit from the latter. I can see events being of some use there but I wouldn't have a chain of events as this implies:

Those events are as follows:  AttackIncoming > (if hit) AttackHit > AttackApply > (if damage) ApplyDamage > (if status effect) ApplyStatusEffect.

 

But instead just have one more general event that sets off the same logic as the sword swinging type but with this method you can delay when it gets applied.

 

It might be helpful to know a bit more about your game, what is the game going to be similar too? Is it more statistically driven or more player skill driven?

Share this post


Link to post
Share on other sites

Without knowing much about your game this sounds overly complex. Is it necessary to do this via events for your game rather than through a small system directly? For a direct hit (swinging a sword for example) you could manage that with a simple function that takes attacker info, defender info and attack info. The function would first check if it's a hit or a miss my comparing attacker accuracy and defender evasion, if no hit it returns. Next is could compare something like strength (damage) versus armour and so on.

 

Plenty of other direct ways to do this but personally I would favour the direct approach rather than indirect (events) methods but you know your game best and what would most suit your design. Consider a projectile, some games would fire the projectile and decide before hand if it will hit or not, others would let the arrow fly and then decide on impact. A game that uses more player skill than stats would benefit from the latter. I can see events being of some use there but I wouldn't have a chain of events as this implies:

 

 

Those events are as follows:  AttackIncoming > (if hit) AttackHit > AttackApply > (if damage) ApplyDamage > (if status effect) ApplyStatusEffect.

 

But instead just have one more general event that sets off the same logic as the sword swinging type but with this method you can delay when it gets applied.

 

It might be helpful to know a bit more about your game, what is the game going to be similar too? Is it more statistically driven or more player skill driven?

 

Thanks for the reply.  I'm actually making a kit for action-adventure RPGs, which would be very open-ended and allow for many types of abilities to exist.  New abilities ought to be in control of their own implementation, rather than being bound to a pre-defined set of effects.  If I want to add a barrier spell, I don't want to have to hard-code it in the character script.  It should be able to detect incoming blows and deflect them from within its own script.  This is why I thought an event-driven flow would be proper.  I want to avoid as much hard coding as possible to maximize flexibility.

I do see how this could get convoluted quickly, though, but a flexible, open-ended system is what I need.  I believe I could accomplish this with an event-driven system, but I figured I would double-check as to whether this is a good design for this particular goal before finalizing it.

Share this post


Link to post
Share on other sites

event driven doesn't seem to be pertinent to me. what you describe is like the sims, plug and play software.  the key to that is a core set of variables that all PnP components use, similar to basic needs in the sims. IE the PnP components only affect the game world via those six variables.

 

for a PnP combat system, you'd likewise want to identify the basic variables a PnP component might possibly affect. this is the downside of writing engines and libraries, you have to anticipate unknown future needs ahead of time. then you can just do a basic set of calls, if hit_target(), apply_damage() and the variables do the rest.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites
Using events for this kind of thing can work, you just need to be careful about going too deeply into it. Work from a few key events, and for the in-between stuff work locally.

For example, an object receives an Apply Damage event. This event may originate outside the entity (from another mob, from a trap, etc) or from within the entity (from a Damage over Time tick or other debuff, etc...) This event should hold all the information the entity needs to know: damage amount, damage type, etc. Once this event is received, the entity would put out a call (a broadcast event of some sort) letting anyone who is interested know that an Apply Damage event has been received by the entity and, if they are interested in responding, call back with their response. Then the entity sits and waits for all of the interested parties to register their interest in responding. The reactions need to be categorized according to specified rules, and applied according to the specified order. After all reactions are processed, the entity would then send an event, say Take Damage. This event would have the processed, modified and repackaged damage data, and would be sent to the entity itself. Any interested parties can respond to this event (floating combat text to show damage numbers above the head, combat log to show combat results as text, vital stats to reduce life and potentially trigger additional life-related events).

This event->broadcast for reactions->response event structure allows for decent flexibility. As an example:

An environment hazard generates a hit for 16 Fire damage against a player character. The hazard sends the Event "ApplyDamage -16 Fire Enviro" to the player.

The player's damage handling component receives this event, and sends out a call for responses, by passing on the event with additional tagging data if needed.

The entity receives the responses:

1) Fire Shield (local buff spell) wants to absorb 4 Fire damage.
2) Fire Resistance (local character stat) wants to mitigate 12% of Fire damage
3) Immolation Aura (area debuff) wants to increase Fire damage taken by 20%
4) Firewatcher (NPC AI mobile unit, faction-tied to player) wants to extinguish the source of the flames to protect its master

In this case, the responses that involve numerical adjustment of the incoming damage value are applied in an order proper to the game ruleset; ie, apply +/- X% adjustments first, then apply +/- hard value adjustments after. Additional responses don't necessarily need to be sent as reply events; ie, the Firewatcher can simply initiate its Extinguish Fires AI routine in response to the broadcast event.

After all of the numeric adjustments are applied, a TakeDamage event with the final adjusted total is packaged up and sent locally to the entity. At this point, any local components can listen for this event to respond appropriately. The CombatLogger component will write a message to the log ("Player takes X fire damage."), the FloatingCombatText component will read the event and respond by scrolling a number above the unit's head. The VitalStats component will reduce Life by the specified amount, and potentially trigger the sending of LifeLow or LifeDepleted events as needed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!