Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Yandex, DotBot

Members: 0
Guests: 7
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Poor quality of SMAUG combat ...
Forum Rules | Mark all | Recent Posts

Poor quality of SMAUG combat code, and dealing with it
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Aug 28, 2008, 4:08 pm
Go to the top of the page
Go to the bottom of the page

Kylotan
Fledgling
GroupMembers
Posts37
JoinedNov 28, 2007

Hi all,

Today I took a long overdue look at our combat system in the hope of refactoring it a bit and changing a few things before adding some features.

And OH MY GOD... I had forgotten just how awful the combat code is. There's a hell of a lot of logic in multi_hit, one_hit, and damage, with little thought given to placing it in the correct place (eg. removing people from groups as part of the damage function!), and several aspects split up across more than one of those functions when they should be constrained to just one. (eg. skill use, or damage resistance.)

I'm hoping to factor bits and pieces out into separate functions - calculating AC/THAC0, working out resistances, awarding xp for hits and kills, ungrouping people as needed, starting hating/hunting, etc - and hoping that I can get the original 3 functions down to the basics - multi_hit decides what kinds of hit to do and how many, one_hit executes one such attack, and damage injures a victim.

Has anybody else had similar thoughts about the combat? Perhaps somebody has had experience in refactoring it and could share their experience or advice?
       
Post is unread #2 Aug 28, 2008, 6:39 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I haven't actually started revising combat in my copy yet, but it's a big beast to tackle. So I'll welcome any pointer you have while you're doing it. :P
       
Post is unread #3 Aug 28, 2008, 8:24 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

Nothing smaug specific... you're welcome to look at the horror that is WileyMUD, in fight.c, for ideas... if you're desperate. :)
       
Post is unread #4 Aug 29, 2008, 7:11 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Isn't refactoring into separate functions almost antithetical to the SMAUG design? :wink:

I've done some minor things in there but haven't taken the time to fix it properly as you've described. It sounds like you're on the right track though. I mean, even just splitting into several functions would be helpful, never mind properly refactoring into general-purpose interfaces.
       
Post is unread #5 Aug 29, 2008, 7:41 am
Go to the top of the page
Go to the bottom of the page

Kylotan
Fledgling
GroupMembers
Posts37
JoinedNov 28, 2007

Yeah, as I mentioned in the first post, the starting point will just be to split out lots of mini-functions from within those big three, so that individual lumps of functionality each have their own function. Then I'll look into moving these function calls around so that they make more logical sense.

Unfortunately I expect there are other parts of the code which rely on damage() having lots of side-effects, eg. spells which use it. So I may need to add another wrapper function to handle those, which handles aggression shown by one character towards another.

I'd also like to simplify the way attacks are chosen. In my code, it seems like players get 1 attack, then 1 more attack if you are dual wielding, then N attacks if you have Nth Attack skill, plus another attack at the end. I've no idea how much that differs from stock though. (We're running 1.02, with a lot of 1.4 patches installed.) And there are special case hacks to short circuit if it's not a multi-hit situation, such as circle, backstab, etc. (Seems like they should have called one_hit directly, really...)

NPCs seem to have N 'attacks', but they can be replaced by skill commands if they have the relevant attack flag, and it doesn't take their class into account so an NPC mage would have as many attacks as an NPC warrior. Seems unfortunate! Perhaps their skill-style attacks should be done in addition to the normal attacks, but less frequently, as a PC would do.
       
Post is unread #6 Aug 29, 2008, 9:36 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Yes, there are several hidden dependencies of that sort -- there are also things like traps.

Attack choosing is a mess. It looks like people started with one attack, and then the ability to do several was kind of hacked in. *grumble*

Re: NPCs, I've been a big fan of treating PCs and NPCs identically. As far as I'm concerned, PC == NPC except that the PC has a person giving commands and an NPC has AI.
       
Post is unread #7 Aug 29, 2008, 12:13 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Overall, the smaug combat system is one poorly designed mess of code. If my revision wasn't going to be so heavily stacked with MW specific details, I'd probably release it, but as is currently planned, once it's revised, stripping out MW specific stuff would leave it a little less functional then the current setup.
       
Post is unread #8 Aug 31, 2008, 4:27 am
Go to the top of the page
Go to the bottom of the page

Llarn
Apprentice
GroupMembers
Posts63
JoinedNov 25, 2007

I have thought about trying Midboss's turn based style or a version of it. However, I dont know if I would like it.
I agree that spamming enter key with same attack in mindless combat sucks though.
       
Post is unread #9 Aug 31, 2008, 9:51 am   Last edited Aug 31, 2008, 9:51 am by Quixadhal
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

It might be helpful to consider how Diku combat evolved.

The concept of an attack in DikuMUD was based on the old D&D model, simplified. The coders didn't think in terms of players vs. a DM, and so every attack was designed to happen instantly, and then a certain amount of cooldown time got applied to prevent attacks from happening as fast the user could type.

By default, each round of combat, everyone involved in the fight got one auto-attack. Every other action takes place outside the normal combat rounds! If you want to see that, just change the combat tick from 20 to 200 (or whatever it is for smaug). Every round, you will take a swing, and the mob you're fighting will take a swing.

If you cast a spell or use an ability, you incur a WAIT_STATE that tells the interpreter to skip your command buffer and decrement your wait timer by one. When enough ticks go by, the next command is processed.

Some command have no wait state.... flee, for example, is applied immediately.

However, the point I'm making here is that EVERY attack happens instantly, and then you have X number of ticks where you do nothing.

If you contrast that with, for example, combat in an LPMUD, you'll see things like "Bozo begins muttering under his breath", and "Bozo waves his arms and trails of fire begin forming in the air around him", and "Bozo throws his arms forward and a ball of fire sails through the air at you!". In that system, the actual attack happens at the END of the delay sequence, not at the beginning.

That, in turn, means the potential victim has the chance to see what's happening and counter it. Perhaps they'll dodge, perhaps they can cast a sheild spell that takes less time to cast than the fireball spell does. Perhaps they can do a shield bash and interrupt the spell before it hits.

THAT is the key to making combat interesting. It doesn't need to be turn based, but it does need to be reactive. You have to have a chance to see what's about to happen and counter it.

In order to change the way combat works though, you'd have to first unthread how it CURRENTLY works. That's the hornet nest Kylotan is currently poking with a stick. *grin*
       
Post is unread #10 Aug 31, 2008, 12:06 pm
Go to the top of the page
Go to the bottom of the page

Llarn
Apprentice
GroupMembers
Posts63
JoinedNov 25, 2007

Thats a pretty cool idea actually.

Raesta enters from the north.

Raesta pulls his long sword from his sheath, and runs at you!

Things like that might be in order if it was done that way.
       
Post is unread #11 Aug 31, 2008, 5:35 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

I like that one too, Quixadhal. Good post, and I agree, it is a heckuva hornet nest but prolly well worth disturbing if you can make it to the other side with it.
       
Post is unread #12 Aug 31, 2008, 9:24 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Combat was one of the first things I reworked on my mud.

Calculation changes:

1. Armor went to a 0-100 scale. The number is simply the amount of damage that is resisted. -30 armor = 30% damage resistance, etc.
2. Whether an attack hits or misses is based on the attacker's skill and not armor; if the attack would hit, the defender has a chance to dodge/parry/intuition (int based dodge)
3. Multiple attacks take a reduction in accuracy. First attack is calculated at normal value, each subsequent attack that round has a roughly 15% less chance of hitting.
4. Each weapons has a set maximum attacks per round. I don't care if your char is 100% at fifth attack, there is no way you are going to get 5 attacks in with a big slow weapon. A lot of opportunities for choices of speed vs. power.

Tactical considerations:

1. I wanted spells to have tactical purposes instead of people simply casting ALL their spells. We use a max of 100 mana for all characters, more powerful spells take up more mana. That max-level damage spell may hit hard, but it also takes up 80 mana. If you're fighting something smaller, it makes more sense to use a weaker spell. Buffs/debuffs are the same story, they cost enough that it would be near impossible to keep a char with all buffs active and still get anything done. It makes players consider what buffs/debuffs to use based on who or what they are fighting, and what equipment is involved.

2. Damage skills (punch, kick, etc.) rapidly become obsolete in stock smaug. Why use the weaker version when you can use the stronger? We replaced most of them with a couple damage skills that scale with level/stats, up to a certain point. Additionally, we made strategic skills such as trip, blind, stun, etc. more important. Is it better to use your damage skill and hope to kill them faster, or use blind and increase your advantages in terms of combat control?

I'm okay with autocombat because it is both familiar to experienced players and has a short learning curve for new players. Where I want to separate the newbies from the experts is in skill/spell usage.
       
Post is unread #13 Aug 31, 2008, 9:49 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Well, Since we're all talking about how our respective combat systems will work.

Here's the wiki entry MW Combat Explanation for MW. None of this has been implemented yet, it's all still getting fleshed out but that's the plain english explanation of what we're planning to have. I'll note of course that due to the Wiki engine being way to bulky and slow in places it's probably going to be replaced eventually, so if you ever revisit this thread and the link doesn't work, just PM me and I'll update it. :P (Way to think ahead!)

The one thing not mentioned on the wikipage is that I'm not at all pleased with the redundancy of the stock messages for hits and misses, and I'll be replacing them with more robust RP-esque decriptions such as the following for a Bladesinger type class:

Slipping into coloratura, you dart around a hill giant sentry and pierce his back.
Daintily whistling, you make several quick jabs at a hill giant sentry with your blade.
Singing scales, you lash out with your blade and riposte a hill giant sentry!
Chanting in an allegro style, you make several quick jabs at a hill giant sentry.
Shifting your legs and the pitch of your song ever higher, you thrust your blade into a hill giant sentry!
Moving to the rhythm of your soul, you open a gash across a hill giant sentry's abdomen.
Your blade whistles through the air and opens a gash in a hill giant sentry.
Casting aside logical thought and moving with your music, you lurch forward and charge a hill giant sentry.
Letting the fury of your music take over, you somersault around a hill giant sentry, hacking at him violently!


Those aren't exactly the messages I'll be using, but they do illustrate my idea. (Those are actually from one of the muds I play. :P)
       
Post is unread #14 Sep 1, 2008, 6:12 am
Go to the top of the page
Go to the bottom of the page

Kylotan
Fledgling
GroupMembers
Posts37
JoinedNov 28, 2007

Thanks everybody for your insights and opinions.

I too will be keeping the auto-combat and probably keeping the wait-states after a skill use rather than before. My personal codebase (not available online anywhere) implements it the other way around, which is better for many things, but I don't want to open up the can of worms that changing this on Smaug would entail.

Generally speaking, my approach to improving combat will be strategic rather than tactical. By that, I mean that instead of having players attempt to act and react in a way that wins individual fights, I'll be looking for them to equip and train themselves in a way that lets them do well on a given mission or zone. It'll be more of a long term thing... can they bring the right equipment and skills to exploit the weaknesses of a given type of mob? To do this I'm going to need to provide both carrot and stick: 'carrot' in that they should be able to see clear benefits to their choices when done correctly, and 'stick' in that going ill-prepared will have consequences that are not easy to instantly reverse. The magnitude of these effects will increase with an NPC's level, so newbies have plenty of time to get used to the system without having to worry about min/maxing their equipment and skills.

I will keep the THAC0/AC system, but may change the resolution somewhat since on our game, probably 90% of players were finding they always had the maximum chance to hit. I'll probably change the chance-to-hit graph from the current linear model with thresholds at either end, to more of a sigmoid function shape, so that extra points of AC and THAC0/Hitroll always have a benefit, though there are diminishing returns.
       
Pages:<< prev 1 next >>