Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 SkillConditions 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:

  1. For complex skills, like above, it's hard to describe the timing of phoenix fly back.
  2. For the onHit timing in damageAction, that means the server even knows that there's an animation trigger called 'hit'.
  3. It's hard to maintain.

Is there a better way to do this? Thanks anyway, for my broken English...

EDIT: As Petr suggested, I reduced the question to a simpler one:

Is there a way to define the protocol so that server does not care about animation trigger stuffs like 'onHit'? Because, generally speaking, server should only care about the logic.

share|improve this question
    
Why do you have to store all actions in one message? I mean why it can't be splitted to: 1. A attacks B using skill X for 30 damage points. 2. B uses the phoenix skill Y when he is hit that damage A for 20 points, and heals himself 10 points. ? –  Petr Abdulin Jan 25 '13 at 10:11
    
@PetrAbdulin For some of the skills like counter-attack, We have to play the 'counter-attack' animation as soon as the character is hit, not after the attacker completely finishes his attack. So we glue the messages and specify the 'timing' it occurs. Another reason is, our game has a lot of characters fight in one turn, we have to play them fluently from the beginning to the end. I mean one turn maybe actually made up from 10+ individual character turns, that have to be played one by one, fluently. –  Peter Ren Jan 25 '13 at 10:23
add comment

1 Answer 1

It's hard to answer because the questions are pretty vague, since all the problems are not clearly specified. Basically you use the word 'hard', but not all things should be easy right? If the battle system is complex, then it's expected that it can be hard to maintain. Also 'hard' sometimes meas it's not wrong, just hard. If you feel it's wrong you should specifically show places which you think are.

As a pattern rule for similar complex sequences, you should try to minimize specifics and unify all actions as much as possible. I.e. you should eliminate A_Something, B_Something, C_Something and try to reduce it so some generic Something thus eliminating switch-like strictures for processing data. You can then define infinite sequences with simple structure like:

public class Action {
    // ...

    List<Action> subactions; 
}

or even with a simple sequence List<Action>.

But again, this advice can be totally wrong, without more details. As suggest you to reduce this question to one, which troubles you most, and describe it carefully. Then you can create new questions if necessary.

As for updated question, it's still not very clear what is done on a server and what is on client. If client is a mere visualisation of a logic, it's necessary for a server to know such things as animation sequences, so it can tell a client how to animate battle. Can you clarify that aspect also? Also consider adding some client/server message processing code.

share|improve this answer
    
I've edited the question to make it one, that is simpler. –  Peter Ren Jan 26 '13 at 4:35
    
See updated answer. –  Petr Abdulin Jan 28 '13 at 5:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.