OpenXcom Forum

Contributions => Programming => Topic started by: d2uriel on March 08, 2012, 11:05:55 am

Title: DogfightState development
Post by: d2uriel on March 08, 2012, 11:05:55 am
Last update: 2012-10-26
Below a list of bugs that are still present within (multi)interceptions:
---------------------------------------------------------------------

Update: 2012-10-12
---------------------------------------------------------------------

Update: 2012-03-26
UFO's are now proper blobs (like in the original game) and they "bling" when radar wave comes across them.

---------------------------------------------------------------------

Update: 2012-03-08
I will update this post with what's going on with the dogfights development.

So first of all, things to be done (it will be updated often):

What I've done so far to the existing code (v0.3):


Below is the original message:
---
Quote
Hey guys,

I've been on the IRC channel and I was told that one of the things that require attention is the DogfightState class. I've decided I can help out with that. I just have a few questions:
  • Is there a list of resources (sounds) from the original game? I don't know which should should be played when the interceptor gets hit, which sound to use for UFO fire, etc.
  • How often should the UFO fire? Right now I've added another rule for UFO's named Reload (as for craft weapons). But as far as I remember UFO's don't fire very often. I've set it to 12 (*75) and there's also a 10% chance that the UFO will actually fire on when the timer gets triggered. Is that okay?

Thank you in advance for your reply.

Ooh, BTW:
Since I'm new to this project I should introduce myself. I'm Daniel, 28 years old, a service engineer, IT graduate and an IT geek since 20 years ;-). I've done a couple of projects during my studies and some more at work. Nothing special. But since I'm a very big fan of X-Com series I'd like to help out with this project. My first contact with UFO - Enemy Unknown was back in 1995-6 (can't remember exactly) on my Amiga 600HD. Game was extremely entertaining (and still is!). Couple of years later I wrote a save game editor for the PC version - never released it though (no internet connection back then ;-) ). Now, thanks to this project, I actually bought the original version on Steam (never thought it's gonna be possible) and I'm really eager to help! Already done some coding within the above class and couple of related ones.
Title: Re: DogfightState development
Post by: kkmic on March 08, 2012, 02:38:59 pm
There are some pretty good resource-related articles on Ufopaedia (https://www.ufopaedia.org/index.php?title=Main_Page). Maybe this (https://www.ufopaedia.org/index.php?title=SOUND) will help.

You may also want to take a look at this page (https://www.ufopaedia.org/index.php?title=Saved_Game_Files).
Title: Re: DogfightState development
Post by: Daiky on March 08, 2012, 05:37:21 pm
Welcome.

I bet Volutar probably has figured out the exact values of each UFO's rate of fire and has put this on ufopaedia somewhere.
Sounds are there for sure. hmm battlescape sounds are (I'd beter keep my mouth shut on geoscape stuff)

Oh and certainly check with SupSuper before throwing one whole big chunck of selfmade code at him out of nowhere, better start with small things (small pull requests I mean) ;)
Title: Re: DogfightState development
Post by: SupSuper on March 08, 2012, 07:30:05 pm
Welcome.

I bet Volutar probably has figured out the exact values of each UFO's rate of fire and has put this on ufopaedia somewhere.
Sounds are there for sure.

Oh and certainly check with SupSuper before throwing one whole big chunck of selfmade code at him out of nowhere, better start with small things (small pull requests I mean) ;)
It's cool, he checked with me on IRC. :P

Hey guys,

I've been on the IRC channel and I was told that one of the things that require attention is the DogfightState class. I've decided I can help out with that. I just have a few questions:
  • Is there a list of resources (sounds) from the original game? I don't know which should should be played when the interceptor gets hit, which sound to use for UFO fire, etc.
  • How often should the UFO fire? Right now I've added another rule for UFO's named Reload (as for craft weapons). But as far as I remember UFO's don't fire very often. I've set it to 12 (*75) and there's also a 10% chance that the UFO will actually fire on when the timer gets triggered. Is that okay?

Thank you in advance for your reply.
1. You pretty much have to guess which sound corresponds to which event. There are only 14 sounds (0-13), here's a log from the last time they were discussed:
Quote
[22:19]   bramcor: think 10 is crash & 11 is destroy
[22:19]   bramcor: 5 is laser, 8 is missiles
[22:19]   bramcor: 8 is stingray & avalanche
[22:20]   bramcor: 4 is cannon fire (you got that already ?)
[22:20]   bramcor: 5 is laser beam
[22:20]   bramcor: 9 is plasma beam
[22:20]   bramcor: 12 is weapon hit
[22:21]   bramcor: 7 is probably fusion missile launch (havent tried it yet)
[23:18]   bramcor: 13 is x-com craft destroyed
[23:18]   bramcor: there simply has to be an extra sound for the xcom-craft-hit event
[23:18]   bramcor: no10 has no resemblence to what I get ingame
If you wanna guess them yourself, I've attached a ZIP.

2. Again, without reversing the EXE or tons of testing, there's no exact details on how the UFOs operate (part of the reason I didn't get far in implementing dogfights :P). Each UFO type has different parameters so you will probably have to add some stuff to RuleUfo (beware that the rulesets are being externalized so you might have to revise your changes later). These pages might help:
https://www.ufopaedia.org/index.php?title=Craft_Combat_Mechanics
https://www.ufopaedia.org/index.php?title=UFO_Interception
Title: Re: DogfightState development
Post by: d2uriel on March 08, 2012, 10:15:23 pm
Thank you for your replies guys! I'll try to post updates in this thread regarding the development of DogfightState and all related stuff. I'll update the first post.

Update:
Regarding 0x12 field in GEOSCAPE.EXE - in UFOPaedia it's stated that:
Code: [Select]
00000012 ufoEscapeTime dw ? 
         This value x100%-200% = time before UFO attempts escape (on Beginner) - Volutar. Values: SS=200 MS=250 LS=300 A=500 H=500 TS=2000 BS=4000 SS=3000 -spike
And a little lower:
Quote from: Volutar 02:45, 14 April 2011 (EDT)
Builtin craft field 0x12 (ufoUnknown) actually works as craft parameter of how much time before alien craft tries to escape from pursue. The formula of this time is
Code: [Select]
UfoCraft->EscapeTimer_Field_28 = craftbuiltin->ufoManeuverability_Field_12
    + RAND(0,craftbuiltin->ufoManeuverability_Field_12) - 30*difficulty_level;
Are these values game seconds? If not, then it needs to be multiplied by 75, right? If so, the calculated values are extremely high, i.e. Large Scout on Beginner level will have break off time from 22500 up to 45000 which makes it nearly impossible to actually start to break off. On the other hand, if they are game seconds, then UFO would break off almost immediately after interception starts :P. Hmm... any suggestions?
Title: Re: DogfightState development
Post by: d2uriel on March 26, 2012, 07:39:04 pm
In this (https://openxcom.org/forum/index.php/topic,104.msg941.html#msg941) post Volutar posted blobs of UFO's and projectiles that were hard coded into the game. How do you think we should proceed with using those in OpenXcom? Right now I've created a Gfx directory inside the main game app and I've put all blobs inside (each UFO and projectile blob is one file). Do you think we can leave it like that or should this be changed somehow?
Title: Re: DogfightState development
Post by: kkmic on March 26, 2012, 08:21:07 pm
Don't hardcode the paths, so they can be changed in the future easily, should the need arise.
Title: Re: DogfightState development
Post by: SupSuper on March 27, 2012, 11:56:08 am
In this (https://openxcom.org/forum/index.php/topic,104.msg941.html#msg941) post Volutar posted blobs of UFO's and projectiles that were hard coded into the game. How do you think we should proceed with using those in OpenXcom? Right now I've created a Gfx directory inside the main game app and I've put all blobs inside (each UFO and projectile blob is one file). Do you think we can leave it like that or should this be changed somehow?
Hardcoded executable graphics are a sick nasty grey area of doom. :P Technically hardcoded executable graphics are still copyrighted content so we can't just directly include them but ripping them off the original is a royal pain in the ass. So our only options are:
- Load the graphics directly off the original executable (really ugly)
- Copy the graphics into our own external files (really risky)
- Hardcode the graphics into our code (kinda risly but only kinda ugly)

So... don't worry about it and pick whichever you prefer, we'll sort it out later. Personally we've been using the last option (see for eg. Battlescape\Projectile.cpp).
Title: Re: DogfightState development
Post by: d2uriel on March 27, 2012, 01:39:20 pm
Alright then, they will be hardcoded ;).

Edit: Alright, it's hardcoded as static const int array. Same will be done for projectiles tomorrow ;-).
Title: Re: DogfightState development
Post by: d2uriel on March 28, 2012, 05:25:30 pm
Never mind. Volutar found lot's of bugs... need to fix em first.

Sorry for double posting but I wanted to bump this thread.

@SupSuper: do you think we could merge what I've done until now with the main source?

A small list of changes is below:

To be done:
Title: Re: DogfightState development
Post by: SupSuper on March 29, 2012, 01:13:06 am
Personally I'm holding off merging any major stuff until 0.4 is out, if that's ok with you, I just really wanna get it done. :P Plus you haven't actually posted where your code is.

Btw I remember reading somewhere in Ufopaedia.org that UFOs can only break off if their current speed is faster than the X-Com craft, though dunno how accurate this is.
Title: Re: DogfightState development
Post by: michal on July 25, 2012, 01:53:31 pm
PR

https://github.com/SupSuper/OpenXcom/pull/102

Probably it could be nice features to include in 0.4, but maybe it would be better to wait.
Title: Re: DogfightState development
Post by: nullzero on July 28, 2012, 03:39:51 pm
As of July 25 I can't seem to compile from source with cmake (using debian linux) and the error given has something to do with a missing CraftWeaponProjectile.h in DogfightState.cpp. Tough upon inspection there is such a file in the folder, and it also appears in the included part of the DogfightState.cpp. So I really don't know what happened, but my c++ skill are kind of lame.

 
Code: [Select]
/home/hobbit/Downloads/SupSuper-OpenXcom-78cf109/src/Geoscape/DogfightState.cpp:45:47: fatal error: ../SaveGame/CraftWeaponProjectile.h: No such file or directory
compilation terminated.
make[2]: *** [src/CMakeFiles/openxcom.dir/Geoscape/DogfightState.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/openxcom.dir/all] Error 2
make: *** [all] Error 2
 
Title: Re: DogfightState development
Post by: d2uriel on July 28, 2012, 03:59:37 pm
Oops, sorry for that. I didn't add the new files into CMakeList file. A new PR has been sent by Shugyousha with updated file. As soon as it get's merged everything should be okay!

Once again, I apologize. My first PR and already messed up :-|.

Edit: Okay, as far as I've seen, SupSuper merged the PR. You should be able to compile the game now.

Edit2: I hope I won't get thrown outta here for such a crappy buggy PR... FFS. I'll make it better next time.
Title: Re: DogfightState development
Post by: nullzero on July 29, 2012, 12:05:58 am
Oops, sorry for that. I didn't add the new files into CMakeList file. A new PR has been sent by Shugyousha with updated file. As soon as it get's merged everything should be okay!

Once again, I apologize. My first PR and already messed up :-|.


Thanks and no problem, ' cause you know, practice makes it perfect!
Title: Re: DogfightState development
Post by: michal on July 29, 2012, 11:32:08 am
Once again, I apologize. My first PR and already messed up :-|.

Don't worry, it's easy to broke linux when you're working on Visual - it happened a lot before ;) Daiky had such problems too - AFAIK he started using some linux under virtualization to check if it still works.

Bright side is that such issues are quickly discovered and can be fixed.
Title: Re: DogfightState development
Post by: d2uriel on July 29, 2012, 11:42:58 am
Yeah, that's a good idea. I'll install a Linux distro under a VM and I'll check my changes there as well before making a PR ;-).
Title: Re: DogfightState development
Post by: SupSuper on August 11, 2012, 04:27:17 am
PR

https://github.com/SupSuper/OpenXcom/pull/102

Probably it could be nice features to include in 0.4, but maybe it would be better to wait.
I ended up changing my mind and adding this to 0.4, as it's a nice addition and doesn't make much sense to have Very Large UFOs that can't kick your ass. :P

Btw a bug I noticed is that shots fired from the Cannon always seem to go through the UFO and out of the screen. In the original game any shot would always stop at the UFO, even if it missed.
Title: Re: DogfightState development
Post by: moriarty on August 11, 2012, 09:55:52 am
actually, I'd keep the "missed shots going through past the UFO" as a feature :)

although, perhaps, it would make sense to have them "fade out" after reaching their maximum (read: maximum effective) range?
Title: Re: DogfightState development
Post by: d2uriel on August 11, 2012, 01:23:31 pm
I'm gonna fix that today in the evening. Been busy lately but this is going to take less than 5 minutes ;-).
Title: Re: DogfightState development
Post by: SupSuper on August 11, 2012, 05:01:55 pm
actually, I'd keep the "missed shots going through past the UFO" as a feature :)

although, perhaps, it would make sense to have them "fade out" after reaching their maximum (read: maximum effective) range?
I think the only problem with that is with such a fast-firing gun like the Cannon, it makes your pilot look like it has really lousy aim (or really wasteful with ammo). :P
Title: Re: DogfightState development
Post by: Volutar on August 11, 2012, 10:46:13 pm
and how do we suppose to determine if missile hit target if it's at exact missile range? when missile either way disappears at max distance.. only by ufo flash? okay
Title: Re: DogfightState development
Post by: SupSuper on August 12, 2012, 02:15:05 am
and how do we suppose to determine if missile hit target if it's at exact missile range? when missile either way disappears at max distance.. only by ufo flash? okay
Well in the original X-Com the sprite, sound and messages at the bottom were enough to indicate whether the shot hit or miss.

Don't get me wrong, I think having missed shots bypass the UFO makes sense, but it just doesn't work right with the original dogfight design, you'd need a new design like Xenonauts (https://www.xenonauts.com/wp-content/uploads/2011/11/aircombat_current.jpg) or XCOM Enemy Unknown (https://www.strategycore.co.uk/site/assets/files/5158/xcom_eu_intrcpt_bnr.jpg). If you try it out yourself, all the shots going up to the top of the screen look really out of place.
Title: Re: DogfightState development
Post by: Volutar on August 12, 2012, 08:13:03 am
i'm not saying about going to the top of radar screen, just little bit farther than ufo - for example 2 pixels out.
Title: Re: DogfightState development
Post by: moriarty on August 12, 2012, 10:34:57 am
I think the only problem with that is with such a fast-firing gun like the Cannon, it makes your pilot look like it has really lousy aim (or really wasteful with ammo). :P

which is not far from the truth. the cannon has a terrible hit-to-miss-ratio, after all :)

I'd opt for having the "projectile" pixels fade out after reaching maximum range. to me it makes no sense to have them always continue to the top of the screen, but neither does it make sense to have them disappear immediately when reaching the maximum range.

if we want to add a little more eye candy, we could even make the "projectile" pixels go off-course after reaching the "maximum range", in a random direction (maximum 15°), although it would probably only really be visible when using the cannon (but who uses the cannon anyway...?)
Title: Re: DogfightState development
Post by: moriarty on August 27, 2012, 01:34:45 pm
noticed another thing that's not right, although rather rare: I was chasing a small scout, and it had just gotten into the range of my Stingray Launcher. The moment the missile was fired, the UFO started outrunning my interceptor, and was almost getting away (and therefore way beyond the range of the sidewinder) when the missile caught up with it and destroyed it.

I'm okay with missiles catching "outrunning" UFOs, but only inside their operational range. so either the missile has to disappear completely at the range limit, or at least it needs to be "disabled" in some way, which should then be marked by some visual change, in order to avoid confusion.

I guess the easiest way is to have it disappear at the range limit.

(My preferred way would be to have it fade and deviate from the original course, though :) )
Title: Re: DogfightState development
Post by: Volutar on August 27, 2012, 02:44:55 pm
missile/ufo hit condition doesn't include distance check. that's the reason.
Title: Re: DogfightState development
Post by: d2uriel on October 11, 2012, 07:38:05 pm
The above issue has been fixed (not submitted yet).

I have a free evening/night today so I'd like to fix all issues found in dogfights. Volutar, some time ago when we were talking on IRC you mentioned 8 points that need to be fixed:
Quote from: Volutar IRC
1. crash animation  2x slower
2. hit animation 2x brighter for 3 frames
3. hit animation starts with size+3 and ends with size+0 and lasts for 3 frames
4. crash animation 2x brighter for 8 frames (all the time until blob disappears)
5. crash animation starts with size+3 and ends with disappearing (shrinked under size 0)
6. radar animation must not include palette manipulation
7. blaster ray drawn without paying attention on radar wave. ie instead of +16/+8/+4/+2/+1 of intensivity, it replaces radar colors with one value
8. missile projectiles drawn as ordinary sprites replacing radar colors too

Since I wanna do some stuff today here's my comments:

Apart from that, any other issues found?
Title: Re: DogfightState development
Post by: Volutar on October 11, 2012, 09:02:00 pm
2. it means direct blob values should be multiplied by 2, before adding to wave (background) color (with saturation cap).
4. see 2
6. actually it doesn't matter. it shouldn't affect final picture.
7. sure. see for yourself (attached).
8. see 7.

Title: Re: DogfightState development
Post by: d2uriel on October 11, 2012, 10:38:05 pm
2. Done.
4. Done.
6. You asked for it ;-).
7. Done. Actually I haven't noticed that until your screen shot. Hehe ;-).
8. Done.

I should start coding "minimizing" the interception window and doing synchronous interceptions. Don't think I'll finish today, though.

I'll send another PR with the current changes so everyone can check if they are good or not.

Edit: Actually I should create Interceptor damage visible. This is what I'll do!
Title: Re: DogfightState development
Post by: d2uriel on October 12, 2012, 10:42:36 am
Sorry for double posting but I need some info regarding craft damage animation. What's the interval between color changes from light red to dark red and the opposite?
Title: Re: DogfightState development
Post by: SupSuper on October 12, 2012, 03:08:25 pm
2. Done.
4. Done.
6. You asked for it ;-).
7. Done. Actually I haven't noticed that until your screen shot. Hehe ;-).
8. Done.

I should start coding "minimizing" the interception window and doing synchronous interceptions. Don't think I'll finish today, though.

I'll send another PR with the current changes so everyone can check if they are good or not.

Edit: Actually I should create Interceptor damage visible. This is what I'll do!
Make sure to send me a PR just with the fixes since I wanna put them in 0.4.5. Stuff like minimizing can come after.

And visible damage is specially important since you made UFOs fight back! :P

Sorry for double posting but I need some info regarding craft damage animation. What's the interval between color changes from light red to dark red and the opposite?
From obversation (hard to tell since game speed varies with CPU), the red damage flashes at regular intervals of around 1/4 second (250ms), just try whatever looks good.
Title: Re: DogfightState development
Post by: moriarty on October 12, 2012, 03:21:28 pm
btw, I'm not sure if I remember correctly, but I think I had a dogfight in which my interceptor got shot several times, and when it was back at the base, it did not have any damage. can anybody confirm this? I have had several interceptors destroyed, so the basic damage system with "dogfight ended because interceptor is destroyed -> interceptor is removed from game" appears to be working, but maybe partial damage isn't transferred to the global setting correctly?
Title: Re: DogfightState development
Post by: d2uriel on October 13, 2012, 01:45:09 am
Make sure to send me a PR just with the fixes since I wanna put them in 0.4.5. Stuff like minimizing can come after.

And visible damage is specially important since you made UFOs fight back! :P
From obversation (hard to tell since game speed varies with CPU), the red damage flashes at regular intervals of around 1/4 second (250ms), just try whatever looks good.
Yeah, I've sent a PR which you already pulled ;-). I hope everything's gonna be alright with that one.
Title: Re: DogfightState development
Post by: d2uriel on October 14, 2012, 10:34:49 pm
btw, I'm not sure if I remember correctly, but I think I had a dogfight in which my interceptor got shot several times, and when it was back at the base, it did not have any damage. can anybody confirm this? I have had several interceptors destroyed, so the basic damage system with "dogfight ended because interceptor is destroyed -> interceptor is removed from game" appears to be working, but maybe partial damage isn't transferred to the global setting correctly?
I'll check that. Dunno what happens after the dogfight ends - didn't look at it yet ;-).
Title: Re: DogfightState development
Post by: d2uriel on October 15, 2012, 01:58:02 pm
BTW: when you minimize the interception window there's an icon being show over the Geoscape. Do you know where's this one taken from?
Title: Re: DogfightState development
Post by: SupSuper on October 15, 2012, 03:02:44 pm
BTW: when you minimize the interception window there's an icon being show over the Geoscape. Do you know where's this one taken from?
It's in INTICON.PCK (https://www.ufopaedia.org/index.php?title=INTICON.PCK).
Title: Re: DogfightState development
Post by: d2uriel on October 15, 2012, 06:21:13 pm
Aaah, perfect. Thank you SupSuper.

I was looking for some details regarding multi-interceptions but I haven't found anything relevant. Therefore they may not work the exact same way as in the original. As soon as I'll finish those (should be tonight) I'd like everyone to look for bugs and issues as well as behaviors different than in the original.
Title: Re: DogfightState development
Post by: pmprog on October 15, 2012, 06:26:32 pm
Can you add a evasive button that says "Do a barrel roll"?  :D
Title: Re: DogfightState development
Post by: SupSuper on October 15, 2012, 10:12:51 pm
Aaah, perfect. Thank you SupSuper.

I was looking for some details regarding multi-interceptions but I haven't found anything relevant. Therefore they may not work the exact same way as in the original. As soon as I'll finish those (should be tonight) I'd like everyone to look for bugs and issues as well as behaviors different than in the original.
Multi-interceptions are extremely simple (in fact I'm pretty sure they were an afterthought by the developers :P). As far as interaction goes, they just work as multiple "parallel" interceptions referring to the same UFO with absolutely no interaction between one another, so you could just create a "parent state" that can run up to 4 DogfightStates inside it and rearrange the windows appropriately.

The minimizing is probably the trickier part, as you will need to change more behavior and keep track of more stuff in the saved game:
- You can only minimize interceptions at "standoff range", so you don't have to worry about running combat logic in the background.
- The Geoscape time is "paused" as long as at least one interception is up. If all interceptions are minimized, the game resumes.
- While an interception is minimized, the craft will continue chasing the UFO around the globe without engaging.
- A UFO can still outrun a craft while the interception is minimized (eg. changes speed during flight), in which case the interception is automatically removed.
- This all has to be preserved in case the game is saved with minimized interceptions.

You might find more details here: https://www.ufopaedia.org/index.php?title=UFO_Interception
Title: Re: DogfightState development
Post by: d2uriel on October 15, 2012, 10:57:27 pm
Multi-interceptions are extremely simple (in fact I'm pretty sure they were an afterthought by the developers :P). As far as interaction goes, they just work as multiple "parallel" interceptions referring to the same UFO with absolutely no interaction between one another, so you could just create a "parent state" that can run up to 4 DogfightStates inside it and rearrange the windows appropriately.

The minimizing is probably the trickier part, as you will need to change more behavior and keep track of more stuff in the saved game:
- You can only minimize interceptions at "standoff range", so you don't have to worry about running combat logic in the background.
- The Geoscape time is "paused" as long as at least one interception is up. If all interceptions are minimized, the game resumes.
- While an interception is minimized, the craft will continue chasing the UFO around the globe without engaging.
- A UFO can still outrun a craft while the interception is minimized (eg. changes speed during flight), in which case the interception is automatically removed.
- This all has to be preserved in case the game is saved with minimized interceptions.

You might find more details here: https://www.ufopaedia.org/index.php?title=UFO_Interception

What I've done until now is I transferred dogfights into GeoscapeState class. Meaning it's not being pushed to _states stack of Game class but to a vector inside Geoscape. During every think() of Geoscape all dogfights are thinking as well. Depending on their state (minimized/maximized) different things happen. Can I leave it this way?

Regarding your points:
- done,
- done,
- done (nothing had to be done as it actually worked without any modifications ;-) ),
- gotta test that,
- this is gonna be done at the very end ;-).

I have some questions though:
I could really use a saved game for the original game where 4 crafts are chasing a UFO ;-).
Title: Re: DogfightState development
Post by: pmprog on October 16, 2012, 09:21:25 am
1. Yes- You can have two interception windows open at the same time (at least on the original). I'm not sure about what Sup saying they are independent, I thought the UFO would only shoot one of the craft's attacking it. I could be wrong though, I can't find any information on that.

2. Don't let them minimise? or maybe this is where OpenXCOM expands on the original and let's you have more?

3. I'm pretty sure they remain in their "slot" when minimised. I think it works like this:

Window A is minimised - called #1
Window B is minimised - called #2
Window A is restored - B is still #2
Window B is restored - No minimised windows
Window B is minimise - called #1
Window A is minimised - called #2


Edit:
Do you think it might be possible to "drag" the window when clicking on the border? I'm not sure if this might get complicated with Z-ordering, and maybe you'd need an "Alt+Tab" to cycle through.
Title: Re: DogfightState development
Post by: d2uriel on October 16, 2012, 09:53:13 am
Can you add a evasive button that says "Do a barrel roll"?  :D
LOL! Yes, that can be done but it won't be visualized in any way ;-).

Regarding them points:

Yes, it would be possible to drag the windows (everything's possible to be exact :P).
Title: Re: DogfightState development
Post by: pmprog on October 16, 2012, 12:33:49 pm
1. I didn't even know you were allowed 4 (I thought it was limited to 2), but yes, I'm pretty sure you can intercept multiple UFOs
2. I've never had more than 2 in battle (I don't think, can't remember now), so I don't really know the original behaviour, I would expect crafts to follow until able to intercept. Set it up as a Ruleset option as Max Interceptions or something
3. Yes, it should go in the first "available" slot, numerically ordered. Take this example:
# You send 5 craft to attack a UFO
# You minimise 1, 2, and 3 until the 4th arrives, the 5th just follows without engaging
# Craft 2 takes heavy damage, so you minimise return that to base
# You'll want Craft 5 to enter "Slot 2", so you can continue with a 4 craft assault
Title: Re: DogfightState development
Post by: SupSuper on October 19, 2012, 08:31:37 pm
I could really use a saved game for the original game where 4 crafts are chasing a UFO ;-).
You could try the saves from xcomufo.com (https://www.xcomufo.com/x1save.html), they have a ton of stuff set up and everything unlocked so they're very handy for testing stuff out.
Title: Re: DogfightState development
Post by: d2uriel on October 19, 2012, 09:44:08 pm
Believe it or not, but I've been playing the original for the past few days just to have a saved game to work with ;-). I've made some progress with multi-interceptions but there's still some things to fix. As soon as it will be playable and bug free I'll send a PR.
Title: Re: DogfightState development
Post by: sklll on October 20, 2012, 12:05:46 am
Can't wait for minimization to be implemented  :'(

I can play DOS version, to provide save with 5 aircrafts chasing an ufo (or maybe another situation). If this still can help - just let me know  ;)
Title: Re: DogfightState development
Post by: d2uriel on October 24, 2012, 01:56:08 pm
Okay. The beta version of multi-interceptions is implemented. I've sent a PR but it will be merged after release of v0.4.5. As soon as it is, please test this new feature. It's probably buggy because a lot of things had to be added/re-written/changed. I've done a couple of tests and it seems to work but you know how it goes. If you are really eager to test it now, you can pull the source from here (https://github.com/d2uriel/OpenXcom) and compile it yourself. I've merged the current build into mine so everything should be the same (except for dogfights of course).

Awaiting feedback.
Title: Re: DogfightState development
Post by: pmprog on October 24, 2012, 02:20:42 pm
I've pulled your changes into my repo, will hopefully have a play with it tonight  :)

Edit: SupSuper - I sent you a PM - This now shows in my PR as well as d2uriel's. I'll try and fix it when I get home
Title: Re: DogfightState development
Post by: d2uriel on October 24, 2012, 03:09:56 pm
One more thing that came into my mind a while ago which I always forget to ask.

In DogfightState class there's a lot of surfaces being instantiated with the new operator but they are not deleted within the destructor (only the timers are deleted there). Since I'm not really experienced with SDL - is this being taken care of by SDL itself or was it forgotten straight from the beginning and needs to be fixed?
Title: Re: DogfightState development
Post by: SupSuper on October 24, 2012, 06:47:41 pm
One more thing that came into my mind a while ago which I always forget to ask.

In DogfightState class there's a lot of surfaces being instantiated with the new operator but they are not deleted within the destructor (only the timers are deleted there). Since I'm not really experienced with SDL - is this being taken care of by SDL itself or was it forgotten straight from the beginning and needs to be fixed?
Any surfaces that are rendered on-screen by the State (through the add() function) are automatically cleaned up by the base State destructor. The idea is that once you connect a Surface to a State, the State takes over so you don't have to worry about it (I'm hoping to expand this to timers and such too eventually). This is all part of the OpenXcom engine. ;)

However if you crate any surfaces with new that are not added to the State (eg. temp surfaces), you'll have to clean those up yourself.
Title: Re: DogfightState development
Post by: d2uriel on October 24, 2012, 06:51:04 pm
Alright, good to know that. I didn't really want to dig into the code too much cause this could as well be hidden somewhere in the SDL libs ;-). I really thought it's gonna be faster to ask this question. Hope you don't mind ;-).
Title: Re: DogfightState development
Post by: SupSuper on October 24, 2012, 06:55:18 pm
Alright, good to know that. I didn't really want to dig into the code too much cause this could as well be hidden somewhere in the SDL libs ;-). I really thought it's gonna be faster to ask this question. Hope you don't mind ;-).
That's fine, I imagine OpenXcom engine is quite the mystery for most people and they just roll with. ;) I might eventually give an overview of the inner engine functionality for the more curious programmers.
Title: Re: DogfightState development
Post by: pmprog on October 24, 2012, 08:20:07 pm
Some notes:

Title: Re: DogfightState development
Post by: d2uriel on October 24, 2012, 08:57:00 pm
Umm, how are you able to launch two interceptors at the same time?

Also
  • Select an interceptor to attack a UFO
  • Miminise, then restore the window and disengage
  • Set the interceptor to reengage and minimise
  • Craft is now showing as "2" despite being the only craft in combat
Okay, that should be fixed now. Pushed to my repo.
Title: Re: DogfightState development
Post by: pmprog on October 24, 2012, 09:32:11 pm
When I UFO appears, you click "Intercept" in geoscape, select the first interceptor, click on the UFO, then click Intercept again, pick the 2nd interceptor and click the same UFO :)
Title: Re: DogfightState development
Post by: d2uriel on October 24, 2012, 09:36:32 pm
Right after targeting the UFO for the first interceptor, the Intercept window disappears. Umm... maybe my sources aren't that up to date at all. Lemme check that.

Edit: Well, it says my sources are already up to date when I'm trying to pull from SupSuper/OpenXcom... hmmmm....

Edit2: Till I figure out what's wrong... test it with sending interceptors within a short interval of time of each other ;-).

Edit3: I found a simple way of dealing with this issue. Committed and pushed to my repo.

Edit4: I read your post carefully again. You're not sending them at the exact same time. Unless you're that fast and the time is not able to advance between you targeting the UFO for the first interceptor and clicking Intercept again ;-).

Edit5: I closed my PR. Please comment within my repo only now.
Title: Re: DogfightState development
Post by: pmprog on October 25, 2012, 10:07:13 pm
Still having problems, thought it'd be easier to record what I'm doing...

https://youtu.be/IRYHufVLsPE
https://youtu.be/asjyNwlzjcE
Title: Re: DogfightState development
Post by: d2uriel on October 25, 2012, 10:47:15 pm
This is weird. Are you using the latest sources of mine? Does it happen every time you do it?
Title: Re: DogfightState development
Post by: pmprog on October 25, 2012, 11:15:22 pm
I did a pull request about 10 minutes before that post, and yes. I take it that it doesn't happen to you then?
Title: Re: DogfightState development
Post by: d2uriel on October 25, 2012, 11:19:53 pm
No, it doesn't. Can you try to fork my code to a seperate repo instead of pulling it to yours? Maybe there's a different issue here.

There are other bugs found but it does work for me pretty well.

Edit: Have a look: https://www.youtube.com/watch?v=-rI6VkDLzo8&feature=youtu.be
Title: Re: DogfightState development
Post by: pmprog on October 25, 2012, 11:47:11 pm
I downloaded your Git, compiled it, and it did exactly the same as what it did from my repo!? I have no idea why it works different for you than me.

I'm compiling with VS2008 BTW, not that that should make any difference...
Title: Re: DogfightState development
Post by: d2uriel on October 25, 2012, 11:52:38 pm
I'm using 2010 but it shouldn't make any difference IMO. So it does happen every time you start a new game and launch two interceptions?

I know radius75 also tried it - you haven't had this kind of issues, right? You had others, though :P.

What the heck? Every time I try it - it works without any problems. Umm... weird.

Edit: can you set a breakpoint at line 385 in GeoscapeState.cpp file and run the game again in debug mode? Ooh... are you running debug or release version?
Title: Re: DogfightState development
Post by: radius75 on October 26, 2012, 12:04:07 am
Still having problems, thought it'd be easier to record what I'm doing...

https://youtu.be/IRYHufVLsPE
https://youtu.be/asjyNwlzjcE
Confirm this, on vc2010. tested on commit [ec7e92412e13959f84287bab702b7ccc626cc45d]
Title: Re: DogfightState development
Post by: pmprog on October 26, 2012, 12:15:07 am
Yes, does it every time

Release. The game won't start if I run the Debug mode (not figured out why).

Anyhoo... I found this little gem:

_dogfights[0]._x = 80
_dogfights[0]._y = 304

_dogfights[1]._x = 80
_dogfights[1]._y = 0

Edit:
Could this be a scaling issue?

Edit 2:
Call me n00b, but where the frigg does _y get set? there's a _y(0) suffixed on the constructor, but I don't understand where it gets set?!
Title: Re: DogfightState development
Post by: d2uriel on October 26, 2012, 10:10:38 am
Yes, does it every time

Release. The game won't start if I run the Debug mode (not figured out why).

Anyhoo... I found this little gem:

_dogfights[0]._x = 80
_dogfights[0]._y = 304

_dogfights[1]._x = 80
_dogfights[1]._y = 0

Edit:
Could this be a scaling issue?

Edit 2:
Call me n00b, but where the frigg does _y get set? there's a _y(0) suffixed on the constructor, but I don't understand where it gets set?!
Aah, I know what's wrong! Thanks for this piece of information. Try the newest build.

AFAIR, when I used screen resolution for calculating window positions it wasn't working. I guess we still work with 320 x 200 and then the image is up-scaled to whatever resolution you have chosen in the settings, right?
Title: Re: DogfightState development
Post by: pmprog on October 26, 2012, 10:29:09 am
Yep, works fine now! Good job!
Title: Re: DogfightState development
Post by: d2uriel on October 26, 2012, 10:31:41 am
Not really fine, but it works ;-).

I'll update the first post with bugs that are still present. Check it please before posting a bug you find ;-).
Title: Re: DogfightState development
Post by: radius75 on October 26, 2012, 01:14:51 pm
Does someone have save with four interceptors in Base? He necessary is to tests  :-[

Edit
OK, I already have him :)

https://www.speedshare.org/download.php?id=4086F13A1
(https://img411.imageshack.us/img411/4382/screen007g.png)
Title: Re: DogfightState development
Post by: d2uriel on October 26, 2012, 01:29:07 pm
I'm experiencing a different issue now. Creating a new DogfightState object takes about 200ms in debug mode (a little less in release). Because of that you can see a small slowdown when a dogfight is about to be started (just before the zoom in effect).

Does someone have save with four interceptors in Base? He necessary is to tests  :-[

Edit
OK, I already have him :)

https://www.speedshare.org/download.php?id=4086F13A1
Haha, good one ;-). Fixed.

Edit: Don't use that saved game for testing now though. It has the wrong values saved. Well, you can do it but you need to return all crafts to the base and make them intercept again.

Edit2: New build available. Cosmetic changes to code... which may break stuff ;-).

Edit3: Regarding the creation time issue - I'm wondering if the dogfight handling shouldn't be a bit different. Maybe I should create 4 instances of DogfightState class when the game starts and then just use them when necessary without deleting them? That would make this issue disappear. What do you think? Is the slowdown really frustrating?
Title: Re: DogfightState development
Post by: radius75 on October 26, 2012, 02:09:49 pm
Geoscape buttons are enable if the dogfight window  is open ;)
[661cec6f3e395601...]
(https://img443.imageshack.us/img443/48/screen008x.png)
Title: Re: DogfightState development
Post by: d2uriel on October 26, 2012, 02:28:46 pm
Geoscape buttons are enable if the dogfight window  is open ;)
[661cec6f3e395601...]
Fixed.

The other one with changing interceptors target while it's interception window is minimized is also fixed.
Title: Re: DogfightState development
Post by: radius75 on October 26, 2012, 03:24:12 pm
Save 5vs1 for testing;)
https://www.speedshare.org/download.php?id=F7B0EA6F1
Title: Re: DogfightState development
Post by: SupSuper on October 26, 2012, 04:56:05 pm
Aah, I know what's wrong! Thanks for this piece of information. Try the newest build.

AFAIR, when I used screen resolution for calculating window positions it wasn't working. I guess we still work with 320 x 200 and then the image is up-scaled to whatever resolution you have chosen in the settings, right?
Yes, internally the game is all 320x200 and scaled in post, makes it a lot easier to manage. :P The only time you need to account for the real screen resolution is when doing advanced stuff like handling the mouse cursor position.
Title: Re: DogfightState development
Post by: d2uriel on October 26, 2012, 09:41:57 pm
Yes, internally the game is all 320x200 and scaled in post, makes it a lot easier to manage. :P The only time you need to account for the real screen resolution is when doing advanced stuff like handling the mouse cursor position.

That explains a lot. Well, next time I'm not gonna make the same mistake again (hopefully) ;).

Anyway... how's the testing going?
Title: Re: DogfightState development
Post by: radius75 on October 26, 2012, 09:53:00 pm
Anyway... how's the testing going?

Testing in progress...
(https://t3.gstatic.com/images?q=tbn:ANd9GcROc1FYcXIjaayi7TokrnR8jCa4axTXP8K1B0Xh_CovudzZjvNg)
Title: Re: DogfightState development
Post by: d2uriel on October 26, 2012, 10:00:12 pm
LOL!  ;D
Title: Re: DogfightState development
Post by: pmprog on October 27, 2012, 01:50:05 am
I just realised that I started making all the Snakeman changes in my master branch - which also has your dogfighting code merged. Guess I won't be pull requesting the snakemen any time soon!
Title: Re: DogfightState development
Post by: d2uriel on October 27, 2012, 09:44:05 am
Well, dogfights should be finished soon. I mean everything that I could think of and what was found should've been fixed by now. If anything gets found I'll try to fix it ASAP. They're playable now and as soon as I won't have any bug reports for a week or two I will fill in a PR for this.
Title: Re: DogfightState development
Post by: radius75 on October 27, 2012, 03:51:07 pm
[a40d891...]
Geoscape Buttons not work  (or Crash) - after intercept and shutdown UFO
(https://img23.imageshack.us/img23/6053/beztytuuuwa.png)

-load sav.
-attack by first interceptor

Sav. 6vsX
https://www.speedshare.org/download.php?id=8FA6FFC41

Title: Re: DogfightState development
Post by: d2uriel on October 27, 2012, 10:59:16 pm
Should be fixed in new build. I also fixed the bug where the music did not go back to the Geoscape music after interception is finished. Not committed yet, though.

radius75 noticed some problems while he was trying to pull my latest build (some conflicts). I tried fixing those and it seems to be okay. Any testers willing to try out the dogfights?
Title: Re: DogfightState development
Post by: d2uriel on November 05, 2012, 03:50:06 pm
Thanks to radius75 I was able to fix everything.

@SupSuper: can I send a Pull Request now?
Title: Re: DogfightState development
Post by: Warboy1982 on November 16, 2012, 09:50:31 am
i've been testing out your dogfight code for some time now in my mod, and for the most part it's pretty solid.
the only problem i've encountered is when you have a dogfight minimized, select the craft in question and send it back to base (ie: don't maximize the window and click disengage, select the craft in flight and give it orders from the menu popup) the cursor gets locked out because the dogfight doesn't get cleared from the queue properly. not sure if you fixed this or not yet.

also, good work on this.
Title: Re: DogfightState development
Post by: moriarty on November 16, 2012, 01:05:43 pm
I'm not sure how this is handled in the original game, but I think the most logical solution for this would be to catch the geoscape clicks for "craft engaged in a dogfight" and have them re-open the appropriate dogfight window instead of the "new orders for craft" window.
Title: Re: DogfightState development
Post by: Warboy1982 on November 16, 2012, 06:06:50 pm
it's an easy fix, all you have to do is put something like "if(inDogfight) cancelDogfight" (only with actual code and real function calls) in the "return to base" and "select new waypoint" buttons
Title: Re: DogfightState development
Post by: Warboy1982 on November 19, 2012, 08:35:28 am
i would like to merge this branch, it works exactly how it should.
i've made a small alteration/fix for the bug i described above, if this meets with your approval (LINK HERE (https://github.com/Warboy1982/OpenXcom/commit/e436493d7228c16b4c0494ed91baa4656fdca979)) please let me know and i'll see about merging it.
Title: Re: DogfightState development
Post by: Warboy1982 on November 20, 2012, 09:50:37 pm
unless anyone objects, i think we should merge this now.

i've tested the hell out of it and can't break it.
Title: Re: DogfightState development
Post by: kkmic on November 21, 2012, 10:21:55 am
Quote
Trust your feelings, Luke
Title: Re: DogfightState development
Post by: Warboy1982 on November 22, 2012, 03:55:55 am
the handful of remaining bugs (thanks radius) have been addressed and this contribution has been added to the master.

thank you d2uriel for your work, we are now that much closer to 1.0