Author Topic: hand-to-hand fight  (Read 23530 times)

Offline Kyzrati

  • Captain
  • ***
  • Posts: 56
    • View Profile
    • X@COM - The X-COM RL
Re: hand-to-hand fight
« Reply #15 on: August 26, 2012, 04:31:46 am »
I noticed the original melee stat dropped from the original game, and added it back in for X@COM, so pretty much *any* item can be used for a melee attack.

The default data I'm using right now (not necessarily balanced properly) has most items with 100% base accuracy (note that by X-COM rules that doesn't mean you always hit) and take 30 TU (unique melee items and terror unit melee attacks are different, of course). It only works if you are adjacent to the enemy, duh. (Unless you're using a throwing weapon like the throwing knives, but those are really designed using projectile weapon properties.)

The damage done by the default melee attacks depends on the attacker's strength, though again this can be overridden for special items. I also added some standard damage types (bludgeoning/slashing/piercing) that can be used for melee attacks.

Not as deadly as actually shooting a weapon (makes sense), of course, but it allows for lots of fun new mechanics, like dedicated melee weapons (e.g. knives, light sabres, etc.) and bashing down weak terrain (or even sturdy terrain like walls using a sledge hammer!). Melee attacks also cause knockback on the target if your strength is greater than theirs, and if your strength is also great enough to smash through whatever is behind the defender, then you'll smash them right through it. So you can, for example, whack an alien with a baseball bat and send him flying out a third-story window so he hopefully falls to his death from impact damage :) In fact, if you had superhuman strength, you could theoretically smash aliens right through walls, and if it collapsed part of the structure the debris would even fall on them, which would be pretty funny... Of course, you have to watch out for powerful aliens doing the same things to you ;)

There are other fun melee mechanics, but they go a bit further from X-COM territory (ex: volatile items that explode on contact, including melee impact).

Offline luke83

  • Commander
  • *****
  • Posts: 1559
    • View Profile
    • openxcommods
Re: hand-to-hand fight
« Reply #16 on: August 26, 2012, 07:02:13 am »
So you can, for example, whack an alien with a baseball bat and send him flying out a third-story window so he hopefully falls to his death from impact damage :) In fact, if you had superhuman strength, you could theoretically smash aliens right through walls, and if it collapsed part of the structure the debris would even fall on them, which would be pretty funny... Of course, you have to watch out for powerful aliens doing the same things to you ;)

WOW that sounds like fun , we should do that ;D

Volutar

  • Guest
Re: hand-to-hand fight
« Reply #17 on: August 26, 2012, 07:27:44 am »
Well I see my ideas became implemented: almost everything as melee weapon, knockbacking, special effects of particular items, melee damage types, even collapse of constructions (interconnected tiles with connections being broken because of too much of weight).

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: hand-to-hand fight
« Reply #18 on: August 27, 2012, 07:29:58 pm »
as of now, you read the weapon stats from the original obdata.dat file, right?
OpenXcom does not use obdata.dat, since our item data structure is different from the original, we just copied over the values we needed into the ruleset. I'll leave it up to Daiky if he wants to add and implement melee stats for any item.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: hand-to-hand fight
« Reply #19 on: August 27, 2012, 07:53:52 pm »
oh, okay. so that's in bin/data/Xcom1Ruleset.rul - I see.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: hand-to-hand fight
« Reply #20 on: August 29, 2012, 03:28:03 pm »
I just saw that in the openxcom ruleset, the Stun Rod does "damageType:6" - the original game used this table:
Code: [Select]
  0 AP
  1 IN
  2 HE
  3 Laser or Gauss
  4 Plasma or Sonic
  5 Stun
  6 TFTD vibroblade damage (does not appear to be used in UFO)
  7 TFTD Electric damage (Bio Drone?)

so I guess something changed, right? did you use the same order, but starting with "1" instead of "0"?

also, if I were to simply add the following to the Rifle ruleset entry:
Code: [Select]
    damageType: 6
    accuracyMelee: 100
    tuMelee: 30
would it add a melee stun attack to the Rifle, or do I need something more?

EDIT: oh, btw, the "accuracyMelee"... on the one hand I know that even 100% accuracy doesn't mean a guaranteed hit in xcom, but on the other hand I have never seen a Stun Rod miss, either... how is accuracy handled for melee attacks?  ???
« Last Edit: August 29, 2012, 03:46:35 pm by moriarty »

Offline Kyzrati

  • Captain
  • ***
  • Posts: 56
    • View Profile
    • X@COM - The X-COM RL
Re: hand-to-hand fight
« Reply #21 on: August 29, 2012, 04:34:24 pm »
EDIT: oh, btw, the "accuracyMelee"... on the one hand I know that even 100% accuracy doesn't mean a guaranteed hit in xcom, but on the other hand I have never seen a Stun Rod miss, either... how is accuracy handled for melee attacks?  ???
Since stun rods actually don't miss in X-COM, you could always just set the accuracy to 200 or so, which is enough to ensure it will always hit assuming the same rules as projectile fire. Or you can make it at least somewhat interesting/realistic by setting it at 140-150 or so, so that if a soldier is *really* unskilled, they could still miss occasionally.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: hand-to-hand fight
« Reply #22 on: August 29, 2012, 04:37:56 pm »
Since stun rods actually don't miss in X-COM, you could always just set the accuracy to 200 or so, which is enough to ensure it will always hit assuming the same rules as projectile fire. Or you can make it at least somewhat interesting/realistic by setting it at 140-150 or so, so that if a soldier is *really* unskilled, they could still miss occasionally.

well, the interesting part is that the accuracy right now reads "100" (in the ruleset), but unlike the other weapons, they never miss. so I guess the mechanics are different here?

Offline Kyzrati

  • Captain
  • ***
  • Posts: 56
    • View Profile
    • X@COM - The X-COM RL
Re: hand-to-hand fight
« Reply #23 on: August 29, 2012, 04:55:27 pm »
Hm, not familiar with the OpenXCom source, so I downloaded it and did a [real] quick search, but didn't see exactly where the stun rod attack might be carried out. If I remember correctly, this was actually hard coded in the original since its behavior is quite different from most weapons. I'm sure OpenXCom will change that at some point, if that's how it is currently.

Offline Kyzrati

  • Captain
  • ***
  • Posts: 56
    • View Profile
    • X@COM - The X-COM RL
Re: hand-to-hand fight
« Reply #24 on: August 29, 2012, 05:06:23 pm »
OK, I looked a little longer b/c otherwise that was kind of a lame response ;)

I found that as long as a weapon's type is set to melee, OpenXCom uses its melee accuracy to determine the hit chance, but it actually does calculate it normally, no differently from projectile weapons, so I would think a value of "100" should miss sometimes (esp. since it's using a soldier's firing accuracy skill as a base).

By the way, nice code SupSuper! Looks like it'll definitely stand the test of time and be a great base for modders etc to build on.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: hand-to-hand fight
« Reply #25 on: August 29, 2012, 05:51:51 pm »
interesting. is there a special accuracy bonus for "shooting" at targets in adjacent squares? not the optional range-based accuracy, but always? because I have never seen a Stun Rod miss in openxcom.

if you miss with it, could you accidentally stun someone else who happens to be standing next to you? we all know those rookies who shoot comrades in the back, missing by 90° or more, but is that possible with stun rods, too? :D

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: hand-to-hand fight
« Reply #26 on: August 29, 2012, 06:05:10 pm »
I just saw that in the openxcom ruleset, the Stun Rod does "damageType:6" - the original game used this table:
Code: [Select]
  0 AP
  1 IN
  2 HE
  3 Laser or Gauss
  4 Plasma or Sonic
  5 Stun
  6 TFTD vibroblade damage (does not appear to be used in UFO)
  7 TFTD Electric damage (Bio Drone?)

so I guess something changed, right? did you use the same order, but starting with "1" instead of "0"?
Yeah, here is ours so far:
Code: [Select]
enum ItemDamageType {
 DT_NONE = 0,
 DT_AP = 1,
 DT_IN = 2,
 DT_HE = 3,
 DT_LASER = 4,
 DT_PLASMA = 5,
 DT_STUN = 6,
 DT_MELEE = 7,
 DT_ACID = 8,
 DT_SMOKE = 9
};

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: hand-to-hand fight
« Reply #27 on: August 29, 2012, 08:10:41 pm »
I found that as long as a weapon's type is set to melee, OpenXCom uses its melee accuracy to determine the hit chance, but it actually does calculate it normally, no differently from projectile weapons, so I would think a value of "100" should miss sometimes (esp. since it's using a soldier's firing accuracy skill as a base).
Yeah, it's basically what I meant with
Quote
Only if an object is defined as a melee weapon, it will have a melee attack menu.
At the time of implementing it, I didn't realize that firearms or any other object for that matter could be used as a melee weapon next to it's default function. So an item only has 1 "battleType". A second(ary) battletype needs to be added if this is needed.

"battleType", which is different from damageType by the way !
It is possible to have battleType "melee", but damageType "stun". Which makes a stun rod. You could make battleType "melee" with damageType "incendiary", which makes a cigarette lighter :p

PS. I'm not good at inventing variable (and class) names, I always think of better ones, later on when I'm actually using them. But I hope they are clear enough :p
« Last Edit: August 29, 2012, 08:15:09 pm by Daiky »

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: hand-to-hand fight
« Reply #28 on: August 29, 2012, 08:50:41 pm »
...You could make battleType "melee" with damageType "incendiary", which makes a cigarette lighter :p

that screams "easter egg", doesn't it? :D I can see 10 rookies rushing a Reaper with cigarette lighters...  8)

Offline Kyzrati

  • Captain
  • ***
  • Posts: 56
    • View Profile
    • X@COM - The X-COM RL
Re: hand-to-hand fight
« Reply #29 on: August 30, 2012, 03:23:28 am »
Yeah, it's basically what I meant with At the time of implementing it, I didn't realize that firearms or any other object for that matter could be used as a melee weapon next to it's default function. So an item only has 1 "battleType". A second(ary) battletype needs to be added if this is needed.

"battleType", which is different from damageType by the way !
It is possible to have battleType "melee", but damageType "stun". Which makes a stun rod. You could make battleType "melee" with damageType "incendiary", which makes a cigarette lighter :p

PS. I'm not good at inventing variable (and class) names, I always think of better ones, later on when I'm actually using them. But I hope they are clear enough :p

I should've said nice code SupSuper AND DAIKY, sorry :-[

Although yeah, "battleType" could've perhaps been called something more intuitive like "attackType"--that's what I called it, anyway, but of course then I ended up adding throwing to the mix, since its another combat action, even though it's technically not an "attack"... meh. "combatActionType"?

In any case, in the interest of making things as expandable as possible, Daiky, you should simply allow almost any number of usage methods instead of just one or two (as you've suggested). May as well have a vector of battleTypes for a given item and check them all. (That's what I've done--allowed any item in the game to theoretically be used in any manner. Now I'm not saying we should turn OpenXCom into a roguelike  ;), but it would make it much easier to add unique features in the future.)

Edit: But no one's answered moriarty's question: Why would the stun rod always be hitting if its accuracyMelee is only set to 100 in the ruleset? Or do even the most unskilled rookies still have sufficient firing accuracy skill to always hit their target if weapon accuracy is 100? Or are point blank attacks always hitting? Or has simply no one tested it enough?
« Last Edit: August 30, 2012, 03:29:09 am by Kyzrati »