Wednesday, May 27, 2009

floor(exp(2.84))

Fixed some problems with the last release.  Item drops now work properly, and order of equipped items doesn't affect their chance to drop (so you can't protect items by equipping them last, for example).  Also fixed going evil too rapidly--if you took 6 hits to kill someone, it would count you as 6 pks instead of 1.

Alignment now regenerates more quickly.  +1 unit per day seemed very slow--it's upped to 4/24 hours.  However, the first 20 hours after your last pk counts as a day so players who log in often regenerate a bit faster.  Also, after 48 hours the rate drops to 2/day and is capped at 30 so that inactive characters don't gain a huge amount of alignment.


Two
tweak tweak tweak!

Three
The living room has been reorganized.  I've got my double-strength green tea with honey.  Time to pwn some code.

Seven
Lots of code done.  Working on quest system since I got bored of messing with walls.  Nobody has any good articles, looks like I'm on my own again.

Eleven
Skype rocks my socks.

Tuesday, May 26, 2009

Sixteen Candles

After our group meeting yesterday, I worked hard on the alignment & PK system for Evidyon and churned out a bunch of new code.  The only things left to do before I can release this update are (1) implement the "Evil Town" where players who go evil and are killed spawn, and (2) do a bunch of testing to make sure everything works.

Eleven
Evil spawn point is implemented.  Rebuilding the editor and going to get started testing.

Whoops, forgot that actor templates need to have an alignment parameter.

Noon
After much testing, the system works great!  The hour counter was more difficult than I anticipated but using GetSystemTime, SystemTimeToFileTime and some hints from RtlTimeToSecondsSince1970, I managed to make it work.  I can use this same system for handling account time, too!

One more thing to do before I release:  put alignment on the player's stats screen.

Four
Back from a long lunch.  Alignment is on the stats screen.  I'd like to add race/class display to the screen also (temporary hack for now, this screen is going to be redone anyway).  Fixed a small bug I found in the server code that caused evil players to register as PKs.

Another cool idea for PKers I wanted to write down:  after a PK, you get a glowing red effect around you for a few minutes (so you're easily identified as a killer!)

Monday, May 25, 2009

I'd have 15 cents...

If I had a nickel for each time I've written a Direct3D rendering state manager.  See how I worked today's number in there?  Pretty slick.

Anyway, the new terrain renderer is SO COOL I don't know what I can say about it.  It's coming soon and supports a ton of features, and I've finally solved some problems that I had been ignoring (point-light effects being one of them).  I'm integrating it with the other components and I'm unifying all my D3D rendering code in the process.  New (very simple) component I'm just about to write handles lights on the map.  This will essentially "allocate" lights for effects.  Since D3D can only handle 8 enabled lights at a time and the lights have to be repositioned based on the camera's location (the world moves around the camera, not the camera through the world...weird, yes), this manager will let other classes allocate and free lighting structures so that magic effects can illuminate the world.  Groovy.

Also, found a memory leak bug in the client's actor effect binding allocator.  Uploading quick update to fix that.  That reminds me, I should mention that I'm adding another new effect binding type:  scenery binding.  This will let scenery have special effects attached, so swords can have sparkles and glow.  To create the special effects for weapon attacks might be a bit difficult. Right now when an actor gets hit, it just sets a "blood" flag in the update packet.  It doesn't specify the actor that hit it, since it's obvious to a player watching and was (up till now) immaterial to the game client.  However, if a fire-sword bursts into flame when it hits a monster...that means the sword needs to register a hit or the monster needs to say who hit it. AH!  The former is much more simple to do, since landing a hit is always recorded on the server.  I can add a "special hit effect" to weapons and pass the sfx id into the attack structure, then just generate the sfx if valid when registering damage.  Piece of cake.

Ok, finished compiling back to code!

Sunday, May 24, 2009

All Fourteen Ducks in a Row

Apparently the value of  (-5)%3 is not well defined, and is inconsistent between platforms.  Well, nuts to whoever decided that one.  I need negative % for the map code, so here's a fun hack:  to make a%b work over a exists in (-c,+c), instead use (a + d)%b where d is some multiple of b that is larger than c.  In other words, just make it positive in a way that doesn't affect the result.

The map editor is going well.  I've finished the framework for the renderer, and not only is it a bazillion times more efficient than the old one, it looks better and is more simple!

1. Map renderer
2. Bugs
3. Map Tool

One
Map still coming along.  Occluded areas are colored slightly darker to make it more obvious one cannot see them.  Going to have to use fog for pits instead of coloring the vertices, but that's not a big deal and it should be that way anyway.  A cool effect though is that I can fog an area and you can't see the pits in it, then if you fall in one you'll go "beneath" the fog and you'll be able to see them.

Two
Took a walk in the gorge, it's a beautiful day.  Also, occlusion works great!

Eight
I'm making a render-state manager that's essentially a mixed speical FX and texture manager.   This'll make it simple to integrate the same effects into the editor and client--right now they were developed separately so even though they do the same thing, they aren't a shared structure.

Saturday, May 23, 2009

Lucky 13 and I Heart DBs

"CREATE INDEX IF NOT EXISTS ..."

I did a lot of optimization on sqlite iteslf using various pragmas, securing it only for single-threaded access and using only pre-prepared statements with bound parameters.  Next, I changed the queries to build the hierarchy using unique keys instead of path strings.  Finally, I created an index for the owner keys that build the hierarchy and the loading time went from 15-20 minutes down to 6-10 seconds.  YEAH!!!!!

I have learned a lot about databases while doing this fix.  Namely, if you're looking for something frequently it should be an integer key and should be indexed.  Also, databases are great but their flexibility and power has to be well managed.


High Noon
Fixed a small problem with dcReference.  Noticed that the swarm spawning density, which implements dcGenericResource directly, didn't implement toString correctly so it wasn't being saved (0 densities everywhere) and compiling caused an infinite loop.  Fixed, and editor works great now.  Going to start on the next list items.   Let's take a look at our beta document.   Says BSOD bug & map tool.  Well, rewriting the map engine is a prereq for the BSOD bug fixes (*crosses fingers*)

1. New Map Renderer, carefully programmed to fix BSOD
2. Get people with BSOD problem to play, if not fixed add testing code for that
3. Vista file-permissions bug, fix installer crappyness, freezing at log-in bug (hopefully fixed by map also)


Thinking on Paper
The map needs to support several distinct features:
  1. Terrain composed of square tiles with different textures in 4 rotated versions
  2. Walls
  3. The ability to black-out sections of the map based on what the user can see (to hide the contents of rooms beyond a wall)
  4. Pits
  5. Second terrain layer for overlays like water, lava, acid and whatnot.
  6. Special effects attached to map
  7. Map triggers.  This is already implemented somewhat, but we need triggers for scripts.
  8. The ability for the server to change elements of the map (?)  Could be useful for switches and such.  This seems like it would be a set of "region flags" that are sent when a new region is entered to describe the state of that region.
  9. Lighting settings so that dungeons are dark, inside it's bright.  Probably a float-variable where -1.0 is always night, 0.0 follows day/night cycle and +1.0 is always day.
Let's see...
region_flag = flag_index > 8 ? 1 : ((flags >> flag_index)&1);
if (region_flag) {
flag_parameters = getParams(region_flag);
switch (flag_parameters.type) {
case SPECIALFX:   specialfx_manager_.createSpecialFX(flag_parameters.specialfx); break;
case SCENERY: scenery_manager_.createScenery(flag_parameters.scenery); break;
case WALL_DOWN: map_manager_.wallDown(flag_parameters.wall_down); break;
case WALL_UP: map_manager_.wallUp(flag_parameters.wall_up); break;
}
}

Yeah that could work!  Up to 8 different triggered effects per 16x16 region, but any number of allowable effect types.

Walls first.  I don't like how a lot of games use a straight LOS algorithm that produces crazy shadows on the map everywhere (ala Diablo).  It's too dark and makes you feel like the game's artificially restricting you.  However, I can't just have monsters waiting in a room while you're standing there on the other side of a partially-open wall looking at them.

I think the solution here is to show all areas of the map that are connected by non-occluding tiles to the one you're occupying, but compute an LOS between actors and only display those that are directly visible to one another.  I can even do a quick/cool "fade in" of the mesh for characters that just came out of a shadow.  This does mean, however, that all solid walls shouldn't be occluding.  This would make characters pop in and out of existence randomly and that doesn't seem reasonable.

So the map needs a new layer for occlusion is the upshot of this.  Layers for now include:
  1. Texture / rotation
  2. Terrain Height (lower than some threshold will color terrain black to indicate a pit)
  3. Fluid Texture (flat plane at -1/4*tile_size depth)
  4. Wall flag, wall height
  5. Occluder (boolean)
  6. Scenery (objects), Animated Meshes (swaying grass?)
  7. Navigability (walk/swim/impassable/prevent teleport/no spells/reduced speed)
And per-region:
  1. Monster swarm spawner
  2. NPCs
  3. Triggers (map teleport, regen HP, scripted event)
  4. Flagged Actions (controllable wall up/down, scenery action ex. open door, special effect)

Ok, let's get started!  This is going to be fun :D

Friday, May 22, 2009

12 Times the Lines

The damn SQLite database just won't load!  It saves the file fine and I can look at it in a standalone editor...but can the program open the file?  No way. RAWR.

1 hour later...
CRAP.  I had already fopen'ed the file and was trying to re-open it with SQLite.  That was pretty dumb.  Still, if it isn't one thing its another--now the loader is very slow.  *fixing*

1 pm
Almost fixed!  :D  Also, here's a good article I read on the Netflix movie-prediction competition while my code was compiling.  Five minutes later, still compiling.  Read an article on how silicon chips are made.

Ah!  I forgot I had not updated the 3-things-I'm-doing post.  Well, I guess it didn't change much:

1.  (Still) changing editor save format
2. Bugs
3. Map tool

3 pm
The performance of the loader is still sucking pretty bad.  The problem is that since the file isn't linear anymore, all of the resources must be looked up by name when they are loaded.  That's a TON of string comparisons.  I think I've found a way around the problem by saving an "index hint" in the record that should allow correctly-saved resources to completely shortcut the comparison, but we'll see what happens...

4pm
I've downloaded the Visual Studio standalone command-line profiler and found this awesome walkthrough because this is just getting silly.  I have to say that the profiler works GREAT.  Unfortunately it told me what I suspected, that the SQLite database is being dumb.  Trying some optimizations.

If only I still had milk so I could drink coffee...and sleep more.  My brain's a bit fuzzy today and I feel like I've been hammering at a problem for a second day that should have taken me only a few hours.

Thursday, May 21, 2009

Eleventh Heaven

Finished the core spreadsheet, for now.  Only design points left untouched: regeneration rates and regeneration spells (healing).  Player HP may need to take a hit, or possibly monster dps increased,  when these are introduced.  ...Actually, everything's calibrated for players being completely killed by a single monster in 4-5 seconds right now anyway so maybe not.  We'll see.

1. Changing editor save format
2. Minor Bug Fixing
3. Map Tool

12:30 pm
Modifiying the save format is going very well.  I should have it done this afternoon.

6:00 pm
I've integrated the new saving method into the editor.  There are some residual problems with how reference links are saved.