It's been a few months, but I finally figured out how I've been misusing node and the mongodb JS plugin.
Essentially it's my PHP background to blame, where every new request to the server is exactly that - a new request - and everything has to be reinitialized anew.
Instead, node is a true server - it runs, maintains state, and waits for new input, be it a page request or ... something else. As such, it is not necessary to reinitialize the database, the connections, and most importantly the data collection that mongo maintains. Instead you run new finds/saves against a collection that's already loaded - much faster, seems to me.
Initially the mongo allowed these repeated loads and I'm sure the performance suffered; but at some point, the plugin author decided to stop the madness and simply started throwing errors when repeated (and redundant) connections to an already open DB were requested. I didn't really have the headspace to grok this until now, and I freely admit it's much more elegant to well, behave as node expects. Hopefully that means more updates, on the bloggy at least. DCSB will still have to wait. :)
A bit of utility work this weekend.
First, made sure ranged combat no longer ignored walls. In addition, I started a bit of work to eliminate the test code that simply threw new weapons all the time - I might reuse this as a spell at some point "Throw Illusionary Weapon", ha! but for now I want to stay firmly within the physical. So, creatures will only throw something if they actually have it in the inventory. AMAZING!
Next, I noticed I wasn't getting the info on mouse click anymore. I fairly quickly realized that the scrolling camera was at fault - I was getting absolute screen X,Y position, not world X,Y position. I added the current camera offset - seems to be working. I also added creature behavioral info to status clicks for debug purposes.
Finally, I started working on implementing some skills now that the skill overhaul is complete. Something is certainly happening, but ... I don't think it's what I want. For example, I have yet to see the goblin throw anything (maybe he's not picking it up fast enough and other critters beat him to it?), and the bat rather than move twice as fast moves ... HALF as fast. It will be interesting to discover why that is, but at least the skills seem to be processing properly using the new action counter (game doesn't hang like it did prior).
So, some progress. A bit of it backwards, but the problems are actually quite revelatory to me, so I'm pretty happy. I think I need more vacations. :)
I realized I haven't put up ... well, anything lately so here's a small dev update and a couple of screens.
First, my ghetto starting screen. It works - and yes, the player class loads from XML with its own stats and graphic - but that's about all I can say for it. :)
Second, range-finding. The goblin started out far to the left, and the bat started out below. The goblin searches for things nearby to hurl things at, and then doesn't because there are walls in the way. :)
I also revamped skills to allow them to be more atomic. A skill can now modify the amount of times skills are processed without breaking itself, for example. This is useful for creatures with special abilities such as double move, double throw, double spell, or potions of speed that allow any move or skill to be performed an additional time. So yes, stacking items of speed is now effectively in the game ... for NPCs at least. Player skills are another story.
Kinda fell by the wayside. I'll attempt to remedy the remaining 23 days (HAHA) into some sort of cohesive entry here. Of most interest to me are Trades (Day 11), for the simplified dungeonkeepering that you'll eventually do, Weapons (14) because well, you know, Politics/Officials (16) to shed a bit of light on why you'll find certain features in the world, Legends (26) for some sort of persistence layer, and that's probably it. I am torn between wanting to spend more time on the creative aspect of the thing and time constraints that say I better focus on the immediately game-affecting components first.
This world is relatively high in magic and low in mechanical invention. As such, you are far more likely to encounter alchemists' workshops and supplies, rune tables and crystal cutters, imbued scrolls and dimensional portals than hacksaws, chisels and anvils. It is rumoured some far off cultures have mastered metals to rival the best enchanted steel, but since the latter is far easier to get a hold of, these weapons are mostly curios. You will find basic weapons and armor - hardly more than slabs of raw metal or strips of leather - easy to come by; from there, you'll apply magical and alchemical processes to them to make them into something more to your liking. Everyone (dungeon inhabitants and questers alike) picks up a bit of this, and you'll be able to improve your skills along the way.
Because of this magic-inclined world, weapons don't really tend to have a lot of variety. Everyone starts off with a set of simple items and then uses this common, easily findable (well, relatively speaking) magic to make something they like. The downside is that you won't be able to use too many more fancy items that you'll find, as they will be tailored to the user and thus unsuitable for you. Again, there will be exceptions to this rule but they will be more curious and oddities - you'll also find lots more raw blanks/crude forms in various shapes and sizes early on that you'll be able to use and commit to for evolution throughout the game.
I wrote a bit about this in the overview, but the world's high magic field means that exerting control over any larger area is nearly impossible. Large amounts of warlords of various alignments and agendas eke out carefully balanced existences in areas close to their powerbases; the wilderness teems with powerful monsters of all sorts that only grudgingly give way to mighty heroes; the balance of power is maintained by the need to defend from all sides and threats. This is also why your adventure changes halfway through, as nature abhors a vacuum and once you get rid of your boss you need to assume new management immediately or face your own crushing. :) Organized warfare as such is nonexistent, as every warlord spends a significant portion of their day just dealing with whatever crisis is on their doorstep and has barely enough left for their own agenda.
Some heroes or warlords (or their minions, natch) grow in stature with time. Their deeds are recorded where they fell (tombstones), where they rose to power (items in their keeps/lairs), or verbally (still working on this one. Random barks here and there? I'm not sure yet). I will definitely try to incorporate larger victories or simply longer-than-standard lives of players into the game in some way. I should create a legends.xml right away, now that I think about it. TODO!
Had a brainstorm on the bike ride home yesterday about the actual implementation of skills. When the pool of skills is small I was thinking small, and each skill was a one-off, called during update as needed.
Thing is, that's not very manageable, not very intuitive. I'd end up with a bunch of these individual calls (one per skill) scattered all over the place, with implementations who knows where. There are already quite a few things going on in a creature's (or player's) turn, and every new added skill would just compound the problem.
So instead I made everything a skill (well, except movement although now that I think about it ... why not?); they're more like "actions" at this point, except some are passive, some active, and some reactive - this part will still take some thought. A creature (and the player) will get those skills loaded up through their XML (now in easy-to-parse, easy-to-tweak comma separated format) on creature generation, and then simply iterate through all of their skills, whatever they may be.
Currently, everyone has the ability 'regen' which is a passive and always happens (unless suppressed somehow), a few creatures have the ability 'throwWeapon', and some have 'summonSelf' which summons another creature of the same type to help. Some of these actions take a turn, some don't, so some will be "blockers" for other actions. What I'm still working on is a sort of weight as to which action a creature should take, for which I think the creature STATUS and STATS will be responsible for.
For example, let's say a creature has 'teleportSelf' and 'castFireball'. If I just give it a percentage chance to occur, the creature will always end up doing one more often than other. However, whether I want the critter to do one or the other depends on what state it's in! If it's wounded, it should probably teleport away; if it's close by it might want to attack in melee instead; and when it's far away, it should throw that fireball. I already have some rudimentary statuses in like ENGAGED, SEEKING_TARGET, SEEKING_ITEM but I suspect these will have to become more verbose. Still, by solidifying the skills into an actual system all of this will be much easier to do.
Oh yes, if anyone else searches for "using a string as function call in as3", this is the way to do it:
var myFunction:String = "castFireball";
I had no idea that was possible. It's tremendously useful for things like this, when you need to call functions that you don't necessarily know the names of.
Fixed lack of movement after level 1. Fixed wrong-way throwing. Fixed inability to select 1st class on start screen.
Hopefully the next update will not be so long in coming. Also, I do plan to finish the worldbuilding, but probably in one long entry. I think I have the basics, and the rest is frankly a bit beyond my creative abilities at the moment. Maybe once I have the rest of the basic mechanics in place I can start thinking about what it is evil orcs actually DO eat. :)
Next up, wrapping up ranged combat.
That's kind of the big one, isn't it. Without some serious imagination engine to engage, I'm afraid I'm stuck with the oldies but goodies. In short, I don't think I can pull off originality well enough and in a captivating enough manner (diggles?) to even attempt it - so the fallback is to maximize player recognition and familiarity with the setting.
Fortunately however, I'm approaching this from the other side of the alignment scale, so there is SOME room for creativity - but it won't be because of the world's inhabitants, just the side that you're on. So:
Militarized, tribal orcs and goblins. Chaotic demons and abyssals. Pack-oriented werewolves and other weres. Mindless skeletons and other mostly subservient undead. Close-knit and xenophobic deep dwarves. On the other side the ever favorite versatile humans, lofty elves, nosy and surefooted halflings and hulking, half-magic eloi. Finally, elusive dragons still haunt some deep places.
A player's corner of the world will be populated by whatever type of overlord settles there. Not only their chosen profession (archmage, warlord, dragon or alchemist) will determine the populace, but also their race.
As to invaders, they will be totally random. There is no restriction on where a quester may hail from in their attempt to overthrow your boss, as mentioned before - despite travel being limited and settlements isolated, questers do get some serious help from Above, so distance is not a problem for them.
IN A WORLD ... where magic runs rampant but people still need to eat, expect the mundane and the fantastic. As mentioned in the previous post, the more wizardly of overlords will probably experiment with plant/animal hybrids, and some experiments will go awry. The more military focused overlords ... well, I hear mutton travels well: expect sheep.
Other than that, you'll see typical forest biodome animals such as wolves, deer, foxes, squirrels and rabbits. Some of these may be NPCs, some of them will just scamper across the floor and vanish into the undergrowth, and some of them you might be able to catch for food. Others will be trying to catch you for food, instead. Closer in to the overlord's lair most of these will probably vanish and kept/cultivated animals will appear more and more.
The dungeons will be home to spiders (of course!), rats (natch) and other assorted creepie crawlies. However, most of the caves within a warlord's domain will be taken over, militarized and defended, so stray fauna will be kept to a minimum. Expect to find your food (if you are a carnivore anyway) some other way - by raiding storage rooms, kitchens and mess halls, which will in turn be much more numerous than in the early parts of the world that you explore.
Tying in to the concept of relatively small zones and warlord types from the previous types, you will find fairly typical flora for any given regions. Forests will yield mushrooms and nuts, camps and towns will be growing efficient crops such as corn, wheat or barley and maintain fruit orchards such as apples, pears and plums. Handily, you can make booze out of most of those, so that will tie in as well.
Magical/alchemist lairs will have less in the way of crops but ample fruit, and there may be some magically enhanced orchards where you will find exotic plants, spell ingredients, and even common use items. There might even be trees growing simple weapons and potions.
In the future when I introduce different zones such as mountains, deserts and swamps I will need to add appropriate crops for those as well. I suppose that means another set of XML files and more art (hello palette swap), which in turn means that the temperate foresty zone will be the only zone for quite some time.
I think I'd rather focus on a single kickass zone than attempt to make palette swaps and spread myself thin. Well, this has been a useful worldbuilding day, apparently! I just eliminated a ton of work for myself! :)
So: DCSB takes place in a temperate zone and a moderately forested area with a possible single mountain (or ubercave) for the head villain's lair. You heard it here first (well yes, where else?).
I have not given this one much thought at all! Really glad to be doing this so I can make a more coherent set of maps (eventually).
Saruman had his Isengard (at least until he tore it down to switch to raid/war footing) to provide him with vittles; Sauron was always raiding or cannibalising (seriously, would anything grow in Mordor? I think not), but it seems like typically your warlords rely on oppressing any local villages for resources; wizards set up on powernodes and just have cadres of peons working on earthly things such as food, drink and sanitation, and mad scientists probably grow their own powershrooms and such. Oh yes, there should be an undead lich type with a mostly undead army that doesn't need any of that at all. And a dragon, while I'm at it; a cross between a wizard (magic users) and warlord (villages to maintain the meat stock).
So! This means that we will need at least one resource use type per archlord type, which actually sounds rather entertaining. You're such a low ranking guy that you don't even know who the head guy is, but it will be revealed in no time by the type of terrain you traverse - I think that sounds rather neat. In practice, this will translate to more villages/outposts for the warlord, more aggressive flora and fauna for the mad alchemist, and more lowbie magic users for the wizard type (they also flock to the node of power). The lich will mostly be dead things (both mobile and not) with some magic users (also undead), and the dragon is part wizardly and part warlord with outposts and such to keep a stock of fat juicy cows. And peasants. Yum.
5 overall archetypes is a good start, and plenty ambitious already (none of this exists, of course!) :)