Author Topic: DogfightState development  (Read 45460 times)

Offline d2uriel

  • Sergeant
  • **
  • Posts: 49
    • View Profile
DogfightState development
« on: March 08, 2012, 11:05:55 am »
Last update: 2012-10-26
  • Added multi-interceptions and fixed some bugs found during their tests.
Below a list of bugs that are still present within (multi)interceptions:
  • Dogfights will not close when minimized and craft is low on fuel and returning to base - fixed.
  • Same as above but with UFO tracking lost - fixed.
  • There's a glitch with starting a dogfight: if there's a zoom in effect running the time is stopped, but as soon as it ends and the dogfight is about to start the time will be advanced by whatever was chosen before. That means if you have set it to 1 day it will go one day forward. Very nasty bug. - this one should be fixed though a small slowdown can be experienced.
  • Geoscape buttons are clickable during dogfights - fixed.
---------------------------------------------------------------------

Update: 2012-10-12
  • Rewritten drawing mechanism for radar waves, UFO hit, UFO crash landing, projectiles and beams
  • Projectiles will not go over their maximum range anymore,
  • Added interceptor damage animation.
---------------------------------------------------------------------

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):
  • Adjust score after UFO's been shot down/destroyed or X-Com craft is lost (destroyed as well).
  • Find out what weapon UFO's are using (in UFOPaedia).

What I've done so far to the existing code (v0.3):
  • UFO's are retaliating. They're using Plasma Beams sound and reload time with a 10% chance of actually firing and 50% of chance of hitting the target.
  • Since they're doing the above X-Com crafts can be destroyed.
  • Projectile weapons and beam weapons look different when they shoot - no more plasma missiles ;-).
  • UFO's have simple AI - there's a timer running as soon as an attack is launched (on of three buttons pressed - Standard, Cautious, Aggressive). As soon as it reaches 0 UFO will try to break off.
  • UFO's look "almost" (according to Volutar) the same way as in the original. They're not circles anymore.
  • Make UFO's shoot in proper intervals with proper chance of hitting.
  • Make the UFO "bling" with light green color when the animated radar waves (or however you may call them) reach it.
  • Multi-interceptions - I have no idea if they work or not, need to be tested.
  • Take care of damaged interceptor graphic - make it red when it's damaged, etc.


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.
« Last Edit: October 26, 2012, 02:29:46 pm by d2uriel »

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: DogfightState development
« Reply #1 on: March 08, 2012, 02:38:59 pm »
There are some pretty good resource-related articles on Ufopaedia. Maybe this will help.

You may also want to take a look at this page.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: DogfightState development
« Reply #2 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) ;)
« Last Edit: March 08, 2012, 11:00:22 pm by Daiky »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: DogfightState development
« Reply #3 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

Offline d2uriel

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: DogfightState development
« Reply #4 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?
« Last Edit: March 09, 2012, 10:00:40 am by d2uriel »

Offline d2uriel

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: DogfightState development
« Reply #5 on: March 26, 2012, 07:39:04 pm »
In this 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?

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: DogfightState development
« Reply #6 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.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: DogfightState development
« Reply #7 on: March 27, 2012, 11:56:08 am »
In this 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).

Offline d2uriel

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: DogfightState development
« Reply #8 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 ;-).
« Last Edit: March 28, 2012, 12:01:09 am by d2uriel »

Offline d2uriel

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: DogfightState development
« Reply #9 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:
  • UFO's drawing on radar screen fixed.
  • Projectiles drawing on radar screen fixed.
  • UFO hit animation added.
  • UFO crash land animation added.
  • UFO's are retaliating so interceptors can get destroyed.
  • UFO's can break off the interception.

To be done:
  • Make interceptor red in the interception window if it's damaged.
  • Multi-interceptions.
  • Minimizing interceptions.
  • Fix bugs that show up in the current code :P
« Last Edit: March 28, 2012, 11:08:28 pm by d2uriel »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: DogfightState development
« Reply #10 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.

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: DogfightState development
« Reply #11 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.
« Last Edit: July 25, 2012, 07:31:55 pm by michal »

Offline nullzero

  • Sergeant
  • **
  • Posts: 32
  • Linux gamer
    • View Profile
    • Social links
Re: DogfightState development
« Reply #12 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
 

Offline d2uriel

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: DogfightState development
« Reply #13 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.
« Last Edit: July 28, 2012, 09:53:53 pm by d2uriel »

Offline nullzero

  • Sergeant
  • **
  • Posts: 32
  • Linux gamer
    • View Profile
    • Social links
Re: DogfightState development
« Reply #14 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!