idea for combat ranges

I'm not a very great coder, but I had an idea I wish I could code. I would like to have my players have to actually enter combat and go through different ranges like missile, pole then finally get to melee range. .. of course only the certain types of weapons can be used to attack at those ranges. ...

I have already implemented a full events based combat system in a previous MUD I coded. I will be tweaking this system for use in my new project. The way it worked is that various weapons had speeds and ranges and there were no more set "combat rounds" as you attacked as needed based on the speed of the weapon. I implemented multi-room combat, but that became a bit cumbersome. I will still use some multi-room combat features here (grenades, sniper rifles, launchers, bows/crossbows), but whereas before range was defined by rooms away from target, I will base it off a virtual distance in each room.

This way as a battle ensues in a room certain mobs/players can move away from melee to ranged distance or move into melee distance, or spear distance, etc... it will flow a lot better than trying to deal with multi-room ranged combat and will add some new depth and strategy to what is otherwise mundane spamming of skills/spells to kill. Add this with my FF7 materia-like skill system with skill/spell cooldowns and delayed effects you will have a pretty unique and rewarding mud combat system.

Nothing like seeing that player/mob start to reload their weapon and you rush into melee range, kick the weapon out of their hand, get behind them, stab them in the back, kick them over, put a steak into them so they are held down while while they bleed out and you move on to the next mob/player.

I started putting the basics together for this system, today. At first I was just going to use a single integer to represent depth. I have since decided that a better way is to use a grid. Based on the sector type, rooms will have a certain depth and height. I will let 0,0 be the center of the room. A room with a depth of 50 will be x: -25,25 y: -25,25. I will include height as well, but not for every cell of the room grid. It will just be a height cap based on sector type with objects, skills, etc.. that can modify each individuals own height. It wouldn't be too hard to code randomized inclines / hills, etc.. as well. I will also code in direction characters/objects can be facing.

I will change code so that visibility/interaction with objects/mobiles/players takes their position and range into consideration. There will be many ways to move around in the room and the goal is to make them as player friendly as possible. There will also be passive and hostile ways of coming into range of mobiles.

Obviously doing such a thing is really changing the entire nature of how the mud works/plays. Given this and how customized my code already is, I will not be releasing any type of patch for this system. I will, however, help any proficient coder implement such a system into their game.

There is a circleMUD snippet for linear distance, I would just advise against it. I thought about it and it is not much more work to just go ahead and add a full grid based system. Since this isn't graphical you shouldn't have to write any A* algorithm, but I guess you still could and I might still do that. I have one I wrote in C# that I might port to C.

I am not going to fully organize it, but i'll post up what I am writing when I am done.

For linear distance its pretty straight forward. Add a new variable to the room structs for int depth. Add one to objects and one to char_data. When a mob loads put them at a random distance and change wander to allow them to also move around distances in a room and set the distance when they enter a new room, summon, goto, transfer, etc.. . The issue I have with linear is what happens if someone comes in from the east or west are you just going to have them land at the center between the two end points? If you do a grid system you can actually have them land where appropriate based on the direction they came from. (e.g. given 0,0 as center in a size 50 room traveling east puts you at -25,0 (far west side center of the next room). If you just go with a linear distance there is no real way to account for true depth and being able to move around inside a room.

I think there was a snippet that was the start of a grid system in combat. I think it's called form fighting on the old circlemud ftp sight. I haven't really looked at it in depth, but it could point your compass, so to speak.

I looked at that code. It is certainly a solid start. If you add <math.h> to sysdep.h and add -lm in Makefile flags you can replace his distance function with the actual real way to find the distance between two points. Not really a problem with his grid being 7x7 but if you went larger his method of figuring it out would not be very accurate.

Also expanding his set_range_enter function here is one that accounts for all directions and allows for dynamic sizing of the room based on adding size to the room struct in structs.h. I also added facing so I could keep track of what direction a player is facing.. but that is easy enough to remove.

You can use the below to find the direction of something relative to the player's location on the grid. I am going to be using it simply to alter the look_at_char so you might see something "far off to the northeast"
where this would be used an probably passed to dirs[].