Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Procedural weapon generation  (Read 3128 times)

Muz

  • Bay Watcher
    • View Profile
Procedural weapon generation
« on: November 09, 2008, 07:14:28 pm »

I've mentioned this on the IRC chan and a few other boards, but I *still* need some ideas. If DF fans can't figure the solution to this I don't know who could (cept maybe Will Wright and Chris Crawford) ;)

I'm making a game that's based purely on combat. It's going to let you play out combat realistically, like how it goes in the Conan stories. It'll probably be text-based, going for a literature sort of feel.

Because of this, weapons are very important to the game and my main motive is to make every weapon have it's own unique feel. Like a sword will be balanced overall. An axe will be clumsier and harder to wield, but do more damage. Spears let you attack further, daggers have a very short range but are quick to block, useful in tight situations, etc.

I could hard code all of this, but that will give me more trouble in the long run. So, I want the code to auto-generate the final stats of the weapon. So, I could just put in like, mass, length, etc of the weapon and I'll get damage, reach, balance, speed, that sort of thing.

Also it would be cool that players could design their own weapons. No worries about balance, I could handle that :p

Any ideas?


Anyway, here's a cool creature editor I've finished for the game to prove that this isn't entirely vaporware:
http://smuzani.googlepages.com/cbtcredit.zip
Logged
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Fenrir

  • Bay Watcher
  • The Monstrous Wolf
    • View Profile
Re: Procedural weapon generation
« Reply #1 on: November 09, 2008, 07:34:01 pm »

Wouldn't it be better to load text files with the weapon stats in them, like Toady's raws? I don't know much about this.
Logged

Keiseth

  • Bay Watcher
  • Better known as The Mimic.
    • View Profile
Re: Procedural weapon generation
« Reply #2 on: November 09, 2008, 08:03:28 pm »

Hmm. Try to figure out all of the important aspects of the weapon first, such as the pieces. A sword consists of the handle-part (the hilt, of course) and the weapon-part (the blade.) Each part deserves its own data on length, mass / weight...

Wikipedia suggests one long sword had a 6 inch hilt and a 35 inch blade. Reverse that; the hilt is now 35 inches long and the blade is a mere 6 inches long. It's more like a spear, now. The length of the handle-part of your weapon should determine how many hands *can* be used to wield it, and the weight of course, how many are absolutely needed.

This isn't to say a hilt can't double as a weapon part; but a weapon part shouldn't be usable as a hilt. Normally.

With the sword, the attack range would be 6 inches + 35 inches = 41 at the absolute longest. It's optimal area would probably be around the center of the blade, for the deepest cleave (I assume. I'm not a swordsmith.) That'd be about 16-18 inches closer. Too much closer and the weapon would be too awkward to use at all.

Now let's work with the slightly spear-like weapon with a hilt of 35 inches and a blade of merely 6. 41 inches is still its max range, and as a piercing weapon 41 is probably close to its optimal range too, since the idea is to stab into, rather than cut.

That means a spear would have a really pathetic area-of-attack: as far away as possible. But with that much hilt, you don't need to hold it at the very base (quite silly to imagine, anyway.) So the length of the hilt could affect the optimal range of the weapon. Perhaps the spear would have from 6-8 inches away (holding the weapon at the very end of the hilt) all the way to about 38-41?

Daggers would have a very short range of attack from their short hilts and blade, but the reduced mass or weight would make them much more deadly in that small range. The sword would be slower, but still not as slow as a spear. The spear would have the biggest drawback for a miss, and would take a longer inward motion to pull it back to you again. So it might be the slowest?

Hope I helped out in some way, by rambling on like this. :D

There are more important pieces to worry about (the guard: you could specify its location in a one dimensional line. Hilt of 6 inches + 2 inch guard + 35 inches of blade, for instance.) And this doesn't work very well with special weapons like flails...
Logged
Cronocke: Today's lesson, revised: Don't listen to Mimic. He will kill you, and it will be entirely by accident. Repeatedly. While he's on fire.

inaluct

  • Bay Watcher
    • View Profile
Re: Procedural weapon generation
« Reply #3 on: November 10, 2008, 12:00:56 am »

It's going to let you play out combat realistically, like how it goes in the Conan stories.

Wait, am I missing something?

Also, Fenrir, that would pretty much be hard coding them. Unless I'm assuming you're talking about something that you're not actually talking about at all.
« Last Edit: November 10, 2008, 12:03:10 am by inaluct »
Logged

Psyco Jelly

  • Bay Watcher
  • It begins!
    • View Profile
Re: Procedural weapon generation
« Reply #4 on: November 10, 2008, 01:18:28 pm »

To help me know what exactly would need to be done would require what combat system you are using. Is it d20, or something else?
Logged
Not only is it not actually advertising anything, it's just copy/pasting word salads about gold, runescape, oil, yuan, and handbags.  It's like a transporter accident combined all the spambots into one shambling mass of online sales.

Asheron

  • Bay Watcher
  • Look in to my eyesssss.
    • View Profile
    • http://www.ihavenoideathissiteexcisted.com
Re: Procedural weapon generation
« Reply #5 on: November 10, 2008, 01:31:49 pm »

This shouldn't be that hard.
Define the min/max length, weight,... of a hilt, blade,... first for every type of weapon.
Then, randomize a number between the minimal and maximal values of lengths, weights etc...
From these, you could, for example, calculate the balance in the sword:

weight_hilt*certain number - weight_blade*certain_number = blabla

Or reach...

length_hilt + length_blade = reach

« Last Edit: November 10, 2008, 01:33:23 pm by Asheron »
Logged


Quote from: Toady One
Did you just post a bunch of vegi-dicks on my board?  I've been trying to combat forum devolution a bit, and that involves fewer vegi-dicks!
Quote from: Yahtzee
Yes, random is funny, isn't it? Sometimes I set up a random number generator when I need a good laugh.

Sergius

  • Bay Watcher
    • View Profile
Re: Procedural weapon generation
« Reply #6 on: November 10, 2008, 01:51:23 pm »

I would give the weapon some dimensions, maybe make it a composite of many things (attack surface, size of sharp surface, etc). the longer a weapon, the more likely it is to hit when swinging, the bigger the "top" the easier it is to hit when thrusting (and how easy to parry would be directly proportional). For instance, you could swing a spear, and there's a chance you'll cut a nasty wound with the tip, but it's far more probably you'll hit someone with the side of the spear, effectively turning it into a staff strike.

Maybe you'd divide a weapon into a blunt part and a sharp part, or a handle part, a shaft part, and a head part. In the case of a mace, the handle is only the area reserved for the hands, the shaft defines the reach of the weapon, and the head would be the striking part, but the shaft can be used to parry too. A sword would have like, zero shaft, and a longer "head", with some sharpness value attached to it.

If you want to measure damage, for swinging for instance it would be a function of the length+weight of the shaft the head combined. A heavier handle could mean it's easier to... handle. More balanced, etc.
Logged

Muz

  • Bay Watcher
    • View Profile
Re: Procedural weapon generation
« Reply #7 on: November 10, 2008, 04:29:30 pm »

@Fenrir: As an analogy, think of it like the map generation in DF. It uses whatever to generate the map, puts it in a table, then takes it back out.

@inaluct: I meant, like without simple "you hit" or "you miss" like in most games. Conan has average linguistic qualities, but I loved the pace of the combat in it and want to do something like that. I like that my creature editor already lets players create all the weird stuff like in the stories, as well as the ones in H.P. Lovecraft's.

@Psyco Jelly: It's entirely unique. D20 is good for tabletop games, not so for comp games. I've been working on this new combat engine for the last 5 years, even wrote my MIT application essay on it, so it's pretty special, I guess :p

@others: Thanks. I'm calculating damage = momentum*sharpness . Momentum includes mass, strength, skill, etc. Sharpness is a good multiplier, much less efficient against armor and I have this cool armor calculation for it that involves a logarithm, despite how most game designers tell you to avoid them XD

Hmm.. I like the idea of separating it into blade, tip, and shaft. I suppose I should let the weapon creator determine how it's used.. swinging, hooking, etc. And Keiseroth's idea of doing a really tiny blade seems good too. I think doing something like shaft mass should actually help create a flail - a flail would be a mace with nearly 0 shaft mass.. letting you swing it easier, but the head will bounce off like it does in tests.

There's an obscenely easy solution to this. I just have yet to clear it before I slap myself in the head wondering why it took me so many years to figure out ;)
Logged
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Idiom

  • Bay Watcher
  • [NO_THOUGHT]
    • View Profile
Re: Procedural weapon generation
« Reply #8 on: November 10, 2008, 05:06:16 pm »

Procedurally generated weapons?
Allow the player to pick up and swing anything their strength allows. A weapon is made every time they pick up something new.  ;)
Logged

Duke 2.0

  • Bay Watcher
  • [CONQUISTADOR:BIRD]
    • View Profile
Re: Procedural weapon generation
« Reply #9 on: November 10, 2008, 05:16:24 pm »

Procedurally generated weapons?
Allow the player to pick up and swing anything their strength allows. A weapon is made every time they pick up something new.  ;)

 I actually remember some tests that were done for the next(Some stealth game) where they could get the player to pick up most anything and throw it. For example, the character would pick up a chair and heave it by the legs. I hoped that one could do such a thing with random objects.

 Smack around people with paint buckets! Jab at people with large splinters of wood! pick up an old hammer and throw it at people! Rip off a railing and smack things with it!

 If Df were to ever go 3D, that would be my dream system.
Logged
Buck up friendo, we're all on the level here.
I would bet money Andrew has edited things retroactively, except I can't prove anything because it was edited retroactively.
MIERDO MILLAS DE VIBORAS FURIOSAS PARA ESTRANGULARTE MUERTO

Muz

  • Bay Watcher
    • View Profile
Re: Procedural weapon generation
« Reply #10 on: November 12, 2008, 01:52:32 am »

Oh yeah, that's just the kind of thing I'd love to make. Heheh, last exam's tomorrow, then I could start coding again :D
Logged
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Procedural weapon generation
« Reply #11 on: November 18, 2008, 07:59:17 pm »

Well, if you let players define weapons as two-way "trees" of sections(0-2 parents, 0-2 children) each with specific properties, such as if it could be held, and you considered the direction of tree flow to be the direction each part comes from, you would measure the reach by the distance from the currently used "handle" to the farthest tip.
Logged
Eh?
Eh!

mendonca

  • Bay Watcher
  • [CLIVE]
    • View Profile
Re: Procedural weapon generation
« Reply #12 on: February 25, 2009, 08:27:26 am »


optimal area would probably be around the center of the blade, for the deepest cleave (I assume. I'm not a swordsmith.)

If it is anything like Cricket, the optimum point is a bit to do with the mass / moment, and also the 'fixed' point of the shape of the first natural frequency of deflection (if that makes sense).

IIRC its about 2/3rd the way down a cricket bat where you will hit the ball the furthest (and your hands wont hurt). I suppose its a mix of efficiently transferring the energy from the bat (sword) to the ball (lower body) and getting the full weight and swing in to it.

Suppose a perfect side on attack from a sword would not give you the same problems, as the rigidity in that plane would be very high. Off kilter though, and you would get quite a bit of flexing.
Logged

Shades

  • Bay Watcher
    • View Profile
Re: Procedural weapon generation
« Reply #13 on: February 26, 2009, 04:52:29 pm »

Assuming it's a computer game then just abuse the fact you have a ton of processing power (especially if your talking text-based, turn-based).

Link up to a physic library and generate the weapons as models, based on a random angle of attack (or maybe linked to any stats you have) using a player position as a vulrum you have all the data you need at the impact point.

In fact if your willing to do any inverse kinematics stuff you could even calculate the forces hitting any point of the target body, as well as any environmental impacts. As your not displaying this models they don't need to be super detailed, just enough to get the values for the physics libraries.

It will probably require you to have some base models to extrapolate from, and it's probably overly complex and your not going to notice the difference from that and a couple of well thought out formula, but it would be an interesting project :)
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd