OpenXcom Forum

OpenXcom => Suggestions => Topic started by: g5-freemen on August 18, 2012, 03:04:24 am

Title: hand-to-hand fight
Post by: g5-freemen on August 18, 2012, 03:04:24 am
Sorry for my english.

Just one small suggestion - how about hand-to-hand fight? I mean if you soldier didn't have any weapon he(she) can make some damage to alien (at least 1 hp) by his hands (punch).
(https://4.bp.blogspot.com/_pGOnGM04xgk/SdRnHMcFOPI/AAAAAAAAGco/A0j318vjiik/s1600/insp_diplomacy.png)
Title: Re: hand-to-hand fight
Post by: pmprog on August 21, 2012, 01:49:34 pm
 ;D

Edit: I quite like this idea, though if you think most enemies can take laser blasts to the face, hand to hand combat isn't going to do all that much.
Title: Re: hand-to-hand fight
Post by: Volutar on August 21, 2012, 02:42:53 pm
Suggest "kick" as knocking-back action, with ability to throw off some bad guys from roof or whatever (even getting them unconscious for a short time - to free narrow corridor for example).
As for kicking - you may have all your hands occupied and still be able to kick some ass. With any weapon (and default - if there's no weapon - with bare hands) - there should be either punch or simple hit. For example you can hit some bad guy with mind probe, specially if it's heavy (and it looks like), or with buttstock of rifle, or with some dead alien.

As for melee with dead aliens. If you "hit" some of aliens with chrysallid (heh, even chrysallid), it may lay some eggs inside and turn this alien into anti-alien-zombie, which will be your ally. The thing is - we can add some "undocumented" features of non-usual use of different things, which still should stay logical :). Like putting grenade into alien's "depths" with guarantied messy explosion after.
I remember Laser Squad (predecessor of UFO) have had a feature of "throwing" things right into someone else, and he will auto-catch this (even with his butt).
Title: Re: hand-to-hand fight
Post by: moriarty on August 21, 2012, 11:26:37 pm
I think melee attacks would definitely make sense, but I guess it's hard to balance. If they are too weak, they are useless. If they do only stun damage, they make the stun rod obsolete. If they are too powerful, the game turns into a weird smoke grenade street fight.

maybe a successful melee attack could knock an enemy around (turn him by 45-90°) to allow you to run away without being immediately shot down by reaction fire? although I think there should definitely be melee weapons like the knife (https://openxcom.org/forum/index.php/topic,383.msg3000.html#msg3000) that do real damage, perhaps with a bonus when attacking from behind. that would make for a nice combination: knock the enemy around, then "slit his throat". wouldn't work on a Reaper, of course... can't reach his neck from behind. :P
Title: Re: hand-to-hand fight
Post by: g5-freemen on August 22, 2012, 01:55:50 am
Knife - it's a new item, think it is too much.
Just a little damage if your soldier has gone in panic or just left somewhere weapons.
Or just for fun - kill mind-controlled alien by own hands... maybe a little bit sadistic (but after the "Expendables 2" it looks very kindness :) )
Title: Re: hand-to-hand fight
Post by: Daiky on August 22, 2012, 12:19:55 pm
I like the idea of the punch if you have no weapons. But I guess you will be dead anyway, so I don't know if that 1 HP damage you mention will make difference :) It's a kind of a last hope when things look bad.

But it might be interesting in other ways, to damage certain low-armor terrain objects maybe. Damaging a hedge or wooden fence with a good kick or a little pushing so you can walk through it, makes sense. I wouldn't try it IRL just for fun, you might upset people (unless you own the hedge/fence), but I guess it works :)

I'm sure the amount of damage you do depends on your strength and in case of hand-to-hand on the strength of your opponent.
Title: Re: hand-to-hand fight
Post by: Volutar on August 22, 2012, 12:45:50 pm
I doubt amount of damage depends on strength of opponent... Otherwise it can be treatead as "autoblock everything" which is wrong, I presume. Breaking fences, without wasting precious ammo is nice thing. Though I dont think anyone could break any inner wall with bare hands. Well, we can change damage model and store each tile health, in order to have cumulative damage effect - to break wall with 10th kick for example. Buth with this damage model you could destroy even ufo hull with bare hands if you will be very patient :)

Daiky, what about throwing grenade into alien which stands right before you? He'll just find primed grenade in his inventory, but it will be too late :) And double unit damage if it will explode from inventory position.
And what about melee attack type for every object?
Title: Re: hand-to-hand fight
Post by: Amunak on August 22, 2012, 01:42:52 pm
But it might be interesting in other ways, to damage certain low-armor terrain objects maybe. Damaging a hedge or wooden fence with a good kick or a little pushing so you can walk through it, makes sense. I wouldn't try it IRL just for fun, you might upset people (unless you own the hedge/fence), but I guess it works :)
It depends on the fence quality. Though in 1999 we can assume cheap fences in most parts of the world (especially near barns and similar things) and those are usually very easy to destroy (kick or two and it's down).

You probably can't destroy ufo walls, brick wall or stone fence, but you can certainly destroy hedges, wooden fences and even wooden walls.
Title: Re: hand-to-hand fight
Post by: Daiky on August 22, 2012, 02:58:15 pm
Daiky, what about throwing grenade into alien which stands right before you? He'll just find primed grenade in his inventory, but it will be too late :) And double unit damage if it will explode from inventory position.
And what about melee attack type for every object?
You would need a high throwing accuracy to throw exactly in someones inventory. I can see it interesting to pass objects from one soldier to another.
Melee attack type for every object seems too much. I think the melee attack is an attack without objects as the opening post suggests.

edit: I need to add that the way it is programmed now, it will not work to have a melee attack on every object, because melee weapon is an object type, like firearm is an object type and ammo is an object type. Only if an object is defined as a melee weapon, it will have a melee attack menu.
Title: Re: hand-to-hand fight
Post by: moriarty on August 22, 2012, 05:05:46 pm
Adding a melee weapon capability for all weapons seems logical to me - simply make the "melee attack" option invisible unless melee damage is >0.

Throwing into someones inventory for passing stuff forward (grenade relay, anyone?) is kind of unrealistic, and not really necessary since picking up stuff into your hand is rather "cheap" in terms of TUs.

Stuffing grenades into Aliens and having them explode from the inside  ;D ;D ;D now that would be something... although you have an almost-like-that mechanic already, because grenade explosion damage originating in your own square is applied to your weak back armor anyway. If anybody wants to create squishy animations for exploding aliens, go ahead :) - perhaps triggered by an alien receiving damage points of more than half of its original health in the killing blow?  ;D
Title: Re: hand-to-hand fight
Post by: SupSuper on August 23, 2012, 01:11:08 am
Melee capability in every weapon is an interesting feature since it used to be in the original UFO but was dropped before release for whatever reason (too complex/useless?). You can still find it referenced in the game manual (Hit attack in p40, p86), OSG and data files (soldiers and weapons have melee stats although they're largely unused) though, might still exist in beta versions too.
Title: Re: hand-to-hand fight
Post by: moriarty on August 24, 2012, 03:09:05 pm
interesting. I don't know if every weapon should have a melee attack... although hitting somebody with a missile launcher will probably do a lot of damage, it might just be a little too large to use effectively. :D

but I think the easiest way to implement this would be to add the possibility of melee attacks as a stat for every weapon, and a value of "0" means it isn't even displayed in the game.

how is that done with auto-fire, anyway? does the game have a separate flag for auto-fire enabled/disabled or is that done by specifying a certain value for auto-fire TUs (like "0")?
Title: Re: hand-to-hand fight
Post by: Volutar on August 24, 2012, 04:10:30 pm
moriarty, the thing is... you can do melee attack with everything, not only weapon... even hit with motion detector can make more damage than simple fist punch. though i don't know how flare can affect on aliens. probably they got blind for number of moves if hit with it? It's possible to make not only HP damage..
Title: Re: hand-to-hand fight
Post by: SupSuper on August 25, 2012, 01:07:11 am
interesting. I don't know if every weapon should have a melee attack... although hitting somebody with a missile launcher will probably
how is that done with auto-fire, anyway? does the game have a separate flag for auto-fire enabled/disabled or is that done by specifying a certain value for auto-fire TUs (like "0")?
We just have separate values for snap/auto/aimed that automatically enable that mode when specified. I think melee also has separate stats, they might just not be fully implemented yet.
Title: Re: hand-to-hand fight
Post by: moriarty on August 25, 2012, 12:36:24 pm
as of now, you read the weapon stats from the original obdata.dat file, right?

looking at the UFOpaedia article on obdata.dat (https://www.ufopaedia.org/index.php?title=OBDATA.DAT), that file appears to have a lot of unused stuff... for example:
Code: [Select]
41[0x29]: TU% cost when attacking as a melee weapon
 50 Most objects
 30 Stun rod
 40 TFTD thermal tazer
 10 Vibroblade
 15 Thermal lance
 20 Heavy thermal Lance
  0 All Corpses
  0 Electroflare
  0 Plasma Weapon Clips

basically everything except corpses, electroflares and plasma weapon clips has a value for melee attack TU cost. at the same time, the ability to melee attack appears to be hardcoded in the original exe.

how does openxcom handle this? in battlescape.cpp I found this:

Code: [Select]
void ActionMenuItem::setAction(BattleActionType action, std::wstring description, std::wstring accuracy, std::wstring timeunits, int tu)
{
_action = action;
_txtDescription->setText(description);
if (accuracy.length())
_txtAcc->setText(accuracy);
else
_txtAcc->setVisible(false);
_txtTU->setText(timeunits);
_tu = tu;
draw();
}

if I read it correctly, openxcom checks whether an accuracy value for an action has been defined, and if yes, displays the appropriate button.

However, the UFOpaedia article mentioned above states that the accuracy for melee attack is defined as

Code: [Select]
40[0x28]: Melee Accuracy. Zombie found that changing this does not change the Stun Rod's 100% accuracy (nor does changing soldier Melee Accuracy). Thus the Stun Rod appears to be hard-wired to 100% for UFO, but in TFTD it is a valid and effective variable. (TFTD uses much more melee than UFO.)
  0 All Corpses
  0 Electroflare
  0 Plasma Weapon Clips
100 Everything else...

so why doesn't every weapon show the melee attack (except corpses, electroflares and plasma weapon clips) in openxcom?
Title: Re: hand-to-hand fight
Post by: Kyzrati 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).
Title: Re: hand-to-hand fight
Post by: luke83 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
Title: Re: hand-to-hand fight
Post by: Volutar 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).
Title: Re: hand-to-hand fight
Post by: SupSuper 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.
Title: Re: hand-to-hand fight
Post by: moriarty on August 27, 2012, 07:53:52 pm
oh, okay. so that's in bin/data/Xcom1Ruleset.rul - I see.
Title: Re: hand-to-hand fight
Post by: moriarty 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?  ???
Title: Re: hand-to-hand fight
Post by: Kyzrati 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.
Title: Re: hand-to-hand fight
Post by: moriarty 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?
Title: Re: hand-to-hand fight
Post by: Kyzrati 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.
Title: Re: hand-to-hand fight
Post by: Kyzrati 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.
Title: Re: hand-to-hand fight
Post by: moriarty 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
Title: Re: hand-to-hand fight
Post by: SupSuper 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
};
Title: Re: hand-to-hand fight
Post by: Daiky 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
Title: Re: hand-to-hand fight
Post by: moriarty 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)
Title: Re: hand-to-hand fight
Post by: Kyzrati 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?
Title: Re: hand-to-hand fight
Post by: Daiky on August 30, 2012, 10:24:58 am
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.
It's more a matter of screen space. The action menu is rather large and can only have 5 items in it. You have "throw" at the bottom, then room for "snapshot, autoshot, aimed shot". If you place "Hit" on top of that, the screen is full.

(https://www.ufopaedia.org/images/8/89/Burst1.png)

(and the coding style is actually SupSuper's, I only tried to follow his style in battlescape code)
Title: Re: hand-to-hand fight
Post by: Kyzrati on August 30, 2012, 10:46:29 am
Yeah, I was thinking of that as well, but UI isn't really a limiting factor since you wouldn't likely have weapons that are capable of every single possible type of attack--instead they have a smaller subset, but the range of the total set can be much larger. For example a sniper rifle that lacks other normal firing modes in favor of two kinds of aimed shots, one slightly quicker and one more careful. That would still only require maybe four actions: Throw, Aimed, Snipe, and Melee (assuming the addition of melee attacks for most weapons).
Title: Re: hand-to-hand fight
Post by: moriarty on August 30, 2012, 10:58:23 am
You don't use sniper rifles for melee attacks. You just don't.

Other than that, you're right, of course :)
Title: Re: hand-to-hand fight
Post by: Kyzrati on August 30, 2012, 11:01:27 am
You do if you're out of ammo and they've snuck up on your position!

It would be great to smash an alien in the face with the butt of your sniper rifle. Or better yet, jam it down his throat.
Title: Re: hand-to-hand fight
Post by: Daiky on August 30, 2012, 11:19:10 am
Quote
Items commonly carried by military or police snipers include: • Rifle Ammunition • Hand held Radio • Knife • Binoculars • Compass/GPS • Canteen or Water bladder • Whistle • Insect Repellent • Mini Thermometer • Food rations • First aid items • Ear Protection • Penlight w/ Filter • Chemical Mace • Camouflage Paste • Strobe Light • Pencil & Notebook • Laser Rangefinder
;D
Title: Re: hand-to-hand fight
Post by: Kyzrati on August 30, 2012, 11:25:32 am
Haha! Good one.

Well, we're talking about X-COM snipers, who would never be able to fit all that stuff because inventory items require a minimum of one "space" and 3 points of encumbrance each. (Now don't go overlaying all that stuff onto an X-COM inventory screen just to prove a point :P)
Title: Re: hand-to-hand fight
Post by: SupSuper on August 30, 2012, 06:34:05 pm
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 know how that feels, I tend to do a lot of find&replaces whenever I think of better names for stuff. It's my code dammit, nobody can stop me from ripping it apart just to make it slightly more readable! :P