Combat
March 10, 2008 on 12:26 pm | In Combat, Game System | No CommentsI’ve tried this, and it works reasonably OK. Basically combat works on a combat queue & ‘tick’ system. A player stacks up the actions they wish to take in their combat queue. The queue has a number of available ’slots’ in it.
Each action takes a pre-defined length of time in ticks and some have a ‘reuse time’ before they can be reused (again in ticks). The player clicks on any action they have available and it gets added to the combat queue. Once there it can’t be removed (tough).
Now there are a couple of different flavours of this system. The first and easiest to code, is that you only have a few slots of queue available, but a slot can take *any* action, and time. So you could have 3 slots and have one action that takes 3 ticks, one that takes 2 and one that takes 4, so a total of 9 ticks worth of combat. The other flavour and slightly more difficult to do, is that the combat queue is larger, but each slot is a single tick. So if you had 8 slots, the sequence of events above wouldn’t fit in until 1 tick had passed. The second method is actually easier to understand, although we could remedy that by adding the information about times to the first method (could be that the bar fills up left to right based on the total time). Thinking about it, I think that the first option is probably the better. Its less demanding on the client’s computer for a start, but also having the slot fill up will actually be more visually informative than lots of slots.
An action has a number of elements: onset time, total time and reuse time. The onset time represents the amount of time before an action happens (think charging up a fireball). The total time is the number of ticks that this skill requires (think charging up a fireball, shooting it and then waiting a bit until your vision clears). Finally the reuse time, is the amount of time you have to wait until you can use that skill again. Overall it sounds really complex, but in reality its pretty straight forward. Additionally by seeing information in hard numbers the human brain can comprehend them more easily.
Now each tick is roughly 2 seconds. More if there is lag, as the system waits until it receives a response from the server before counting down those 2 seconds (there is a timeout option as well to prevent people trying to hack). Now 2 seconds is actually quite a long time, so weapon attacks and actions may make multiple ’strikes’ within each attack. Take a sword for example. I would say that you can swing an averge blade once every second, more if its lighter. So a regular attack from a sword would have a time per action (1), damage per strike (3-4) and a strikes per action (2), so you ought to have 6~8 damage from that one attack (obviously each has a chance to miss/crit etc). Now a ‘gigantic’ attack might go time per action(2), damage per strike (+400%), strikes per action (1). So this ought to cause the same damage as 2 regular attacks, but as its a special attack will likely have an increased chance to cause a special effect (like a stun). Its going to be one of those things that will need lots of testing, but probably the best way of tackling it.
As with all of W2, all actions are passed to the server to complete, the fancy javascript UI is purely client side and every action is validated by the server. Amusingly what this means is that somebody could technically unlock a skill before its reuse time, and thus add it to the queue before they should be able to. In reality this actually just delay’s the next action in the queue
Well thats the basics of the combat system in a very small nutshell. Hopefully keeping everything simple and the interface straightforward will ensure that the game runs smoothly. Although 2 seconds is a long time, especially when waiting for an ability that takes a while to use, it is quite fast when you’re using 1 tick actions. I may also put in a control that compensates to a lesser extent on if you get big lag spikes. Its not uncommon to see lag of 250ms when on the internet (time it takes to send and receive a reponse from the server), which makes a tick 2.25 seconds. If I were to time this, then I could make the tick delay 1.75 seconds to compensate for the 250ms lag. If I were able to get the server to decide on the amount of time to pause, this would make life easier, as its going to be fairly difficult to intercept for hackers.
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Entries and comments feeds. Valid XHTML and CSS. ^Top^ Powered by WordPress with jd-nebula-3c theme design by John Doe.