OpenXcom Forum

Contributions => Programming => Topic started by: alienfood on December 23, 2012, 05:08:41 pm

Title: "Strafe" sideways move
Post by: alienfood on December 23, 2012, 05:08:41 pm
I pushed a fairly small change that implements a "strafing" or sideways movement, as follows:

- Requires option "strafe: true" in options.cfg
- Hold down Ctrl-key when clicking
- Only strafe to adjacent tiles, in front or beside but not behind
- Large units (tanks) cannot strafe
- Strafing during a change of z not allowed

Strafing increases TU cost by +1. This seems reasonable, as usually you will have already paid the TU cost of turning to face the wall before strafing sideways into a corridor.

Graphically, the units "moonwalk" while scooting sideways. It looks neat to me.

I spent a long time trying to get backwards-strafing to work, but the units would exit through the front of the tile, teleport backwards, and enter through the back of the tile behind. I turned off strafing backwards, but eventually I think it can be done by fudging the "frame" count passed to the draw routine.

I tried very hard to follow the instructions provided by radius75, but I still ended up with the change on "master" instead of on my branch. If you can't find the changes and want them, they are very minor and I can post them here. I also tried the changes integrated into the latest Cydonia changes from Warboy, and they work just fine. I don't know why (or rather, I do know why and don't know how) to post the changes pre-integrated with the latest Cydonia work.
Title: Re: "Strafe" sideways move
Post by: michal on December 24, 2012, 01:08:37 pm
Interesting idea :)
Title: Re: "Strafe" sideways move
Post by: Warboy1982 on December 24, 2012, 11:19:59 pm
we had a little discussion about this on IRC, i like the idea, and would like to expand on it a little, mostly regarding tanks.

so if ctrl+click moves a soldier without re-orienting him, how about using ctrl+rclick to re-orient the turrets on tanks and have their LOS be based on the turret rather than the chassis. that way tanks could "strafe" by turning their turrets 90 degrees perpendicular to their chassis prior to movement.
Title: Re: "Strafe" sideways move
Post by: alienfood on December 25, 2012, 02:00:51 am
I'm all for it and I think I can do it. Leave me with it for a couple of days. I will also post a fix for a bug that does not show up under the debugger, only when you start openxcom detached.
Title: Re: "Strafe" sideways move
Post by: Hythlodaeus on December 25, 2012, 03:06:45 am
we had a little discussion about this on IRC, i like the idea, and would like to expand on it a little, mostly regarding tanks.

so if ctrl+click moves a soldier without re-orienting him, how about using ctrl+rclick to re-orient the turrets on tanks and have their LOS be based on the turret rather than the chassis. that way tanks could "strafe" by turning their turrets 90 degrees perpendicular to their chassis prior to movement.

Regarding tanks/hwps, I believe this is a great idea, but wouldn't this imply a sprite redesign for the hwps, since their turret is not located in the middle? Also, I can sense cyberdiscs becoming a lot deadlier as a result of this, which is frankly quite an interesting perspective, in terms of challenge.
Title: Re: "Strafe" sideways move
Post by: Warboy1982 on December 25, 2012, 06:08:41 am
Quote
Regarding tanks/hwps, I believe this is a great idea, but wouldn't this imply a sprite redesign for the hwps, since their turret is not located in the middle?
not at all, we just take the "direction" the unit is facing from the turret for LOS calculations.

Quote
Also, I can sense cyberdiscs becoming a lot deadlier as a result of this
cyberdiscs don't have turrets.
Title: Re: "Strafe" sideways move
Post by: alienfood on December 25, 2012, 01:34:09 pm
If Hythlo was referring in general to aliens strafing, the AI was not modified to be able to perform that kind of move. So it is a small advantage for the xcom faction.
Title: Re: "Strafe" sideways move
Post by: Hythlodaeus on December 25, 2012, 01:53:52 pm
cyberdiscs don't have turrets.

I know (duh), but don't they have to face the target in a specific direction in order to fire?
Title: Re: "Strafe" sideways move
Post by: alienfood on December 25, 2012, 04:23:28 pm
My git skills having improved, I resubmitted the changes that support the strafe move, starting from a recent branch that includes all changes through today.

I also sent in a small change to LBM file loading so that people like me who deleted them back when 20kb was a big deal can still run openxcom. ;)
Title: Re: "Strafe" sideways move
Post by: Chiko on December 25, 2012, 07:02:56 pm
Strafing was pretty useful in X-Com Apocalypse. I'd love to see it in the good old X-Com.
Title: Re: "Strafe" sideways move
Post by: papamaanbeer on December 25, 2012, 11:51:13 pm
i like! the strafing idea!

Moonwaliknig will be cool to, anymore dance moves we can implement ;)
Title: Re: "Strafe" sideways move
Post by: Mr. Quiet on December 26, 2012, 05:25:31 pm
I like this idea too. I just don't like pressing the Ctrl button, my picky is too long. Shift would be perfect. We'll be able to change the buttons, right?

thanks :)
Title: Re: "Strafe" sideways move
Post by: alienfood on December 28, 2012, 02:41:36 pm
Progress report: I have it implemented pending an issue with vertical movement for hover tanks. I may push some of the ready changes.

Whoever suggested this for tanks, it plays very well. Here's how it works, and there may still be time for small changes (e.g. tu cost):

- strafe: true option set
- Turret becomes the FOV
- CTRL-key, LEFT click the point you want to look at
- Turret turns, tu cost is 1 for 45-90, 2 for 135-180 (cheaper than regular turning)
- Turret stays turned as the vehicle moves, FOV will now strafe whichever way the turret is pointing. Note that the turret stays turned relative to the tank, not the compass.

Title: Re: "Strafe" sideways move
Post by: Warboy1982 on December 28, 2012, 02:46:26 pm
nice.
Title: Re: "Strafe" sideways move
Post by: moriarty on December 28, 2012, 08:40:18 pm
is that turret direction also represented graphically?
Title: Re: "Strafe" sideways move
Post by: alienfood on December 29, 2012, 02:09:40 am
I pushed the changes, described above.

The request for shift-click as an option is reasonable, this will get done eventually. I used SDL to detect key states, so it ought to be cross-platform. It would be nice to hear from somebody that it works on a non-win platform. Turret state is rendered, this has been in there for a while I think.

I have not done much testing with path preview. If you have trouble, turn off path preview and I'll issue a patch.

I could have done a much better job with the soldier-strafe implementation, I will go back and code-clean that section using the learning I acquired during the last week. My thanks to Sup and Warb who waded through and cancelled some of my previous garbage.
Title: Re: "Strafe" sideways move
Post by: hsbckb on December 29, 2012, 11:58:53 am
To be fair, can aliens move in this way?
Title: Re: "Strafe" sideways move
Post by: Volutar on December 29, 2012, 12:08:15 pm
i can say - no
Title: Re: "Strafe" sideways move
Post by: Warboy1982 on January 06, 2013, 01:43:41 am
going to try to add this today, along with a "run" behaviour with shift+click that uses less TUs but more energy (and cannot be used in conjunction with strafe) as suggested by pmprog on IRC.
Title: Re: "Strafe" sideways move
Post by: alienfood on January 06, 2013, 01:52:59 am
btw I've merged this locally several times, and would be happy to reopen two or three small branches to incorporate the changes a piece at a time.
Title: Re: "Strafe" sideways move
Post by: Warboy1982 on January 06, 2013, 03:34:01 am
ok, this seems to be working just fine, as is running, my only issue is that the "path preview" is now inaccurate when running.
Title: Re: "Strafe" sideways move
Post by: Hythlodaeus on January 06, 2013, 02:15:58 pm
going to try to add this today, along with a "run" behaviour with shift+click that uses less TUs but more energy (and cannot be used in conjunction with strafe) as suggested by pmprog on IRC.

A little suggestion regarding this: running should temporarily reduce the soldier's FOV, so enemies are harder to spot mid-run (which makes sense since you're not exactly looking around when sprinting). On the other hand, perhaps enemies could suffer a little aim penalty when reaction firing against running soldiers.
Title: Re: "Strafe" sideways move
Post by: Volutar on January 06, 2013, 02:23:38 pm
Actually moving objects are more noticeable. Alot of animals sees moving objects alot better, and some of them sees ONLY moving objects.
Title: Re: "Strafe" sideways move
Post by: Hythlodaeus on January 06, 2013, 02:27:52 pm
I was talking about the opposite. When running you're less likely to spot something that's still.
Title: Re: "Strafe" sideways move
Post by: Volutar on January 06, 2013, 02:37:06 pm
Of course moving units have less chances to spot something, even not still.
Title: Re: "Strafe" sideways move
Post by: Volutar on January 10, 2013, 05:39:09 am
What about diagonal "strafe"? right/forward,left/forward, right/backward, left/backward?
Title: Re: "Strafe" sideways move
Post by: Warboy1982 on January 11, 2013, 02:42:11 am
whoops, i forgot to push this.  :-[

this has now been added :D

thank you alienfood for the contribution!
Title: Re: "Strafe" sideways move
Post by: kkmic on January 11, 2013, 01:54:30 pm
Of course moving units have less chances to spot something, even not still.
Are the running units harder to hit by reaction fire? Are they easier to react fire against?

EDIT: Typo