I'm working on the server side of a turn-based strategy game. The game has a really complex combat system, like:
When you are hit, you summon a phoenix to attack the enemy that deals X damage, and the phoenix fly back to heal Y of your health.
Well, such skill does sounds interesting, but requires a great amount of work on the skill and combat system.
We did not use script on the server. We just split one skill into several skill effects. For instance, we have DamageEffect
, AddBuffEffect
and so on. However, we have a lot of skills like the phoenix stuff above, they can be triggered at a specific moment. And some of them even replace the main attack skill. So we designed several SkillCondition
s for that. It worked, although not very well.
However, the question is: For such a complex combat system, how to define the protocol between client and server?
For example:
A attacks B using skill X for 30 damage points. B uses the phoenix skill Y when he is hit that damage A for 20 points, and heals himself 10 points.
How can we express this to the client? We currently use a structure like this:
useSkillAction:
skill: id_of_X
source: id_of_A
target: id_of_B
subActions:
damageAction:
timing: onHit // Timing means the the damageAction will trigger when the skill animation triggers a 'hit' event.
character: id_of_B
damage: 30
subActions:
propertyChangedAction:
timing: onFinished
character: id_of_B
property: health
value: health_of_B
useSkillAction:
timing: onFinished
skill: id_of_Y
source: id_of_B
target: id_of_A
subActions:
damageAction:
timing: onHit
character: id_of_A
damage: 20
subActions:
propertyChangedAction:
timing: onFinished
character: id_of_A
property: health
value: health_of_A
healAction:
timing: onFlyBack??
character: id_of_B
damage: 10
subActions:
propertyChangedAction:
timing: onFinished
character: id_of_B
property: health
value: health_of_B
Well, I think you got the idea. For now, this structure can handle only simple skills. The solution currently have three problems:
- For complex skills, like above, it's hard to describe the timing of phoenix fly back.
- For the
onHit
timing indamageAction
, that means the server even knows that there's an animation trigger called 'hit'. - It's hard to maintain.
Is there a better way to do this? Thanks anyway, for my broken English...