|
|
(30 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | I'm also known as "Tycho" on StrategyCore forums. I've been learning about disassembly and C++ coding since December of 2011 because I wanted to mod the tank/cannon of Enemy Unknown into a tank/chaingun for my own games. I started playing with DOSbox but switched to the CE version and began focusing on its sound problems. I have tinkered with Seb76's UFOloader, added those fixes of my own, and rearranged Seb's INI file to make it less overwhelming to new users. I started helping Kyrub in his quest to convert UFOextender into one for Terror From the Deep but eventually became the main person doing it. | + | I'm also known as "Tycho" on StrategyCore forums. I've been studying disassembly and C++ coding since December of 2011. This all started because I wanted to mod the tank/cannon of '94 Enemy Unknown into a tank/chaingun for my own games. I started playing the DOS version but eventually switched to the CE version. At first, I focused on the sound problems which is when I started to experiment with Seb76's UFOloader. |
| | | |
| ==[[UFOextender|UFO Extender]]== | | ==[[UFOextender|UFO Extender]]== |
− | This is the original program created by [[user:seb76|Seb76]] for use with ''Enemy Unknown''. Check out the [[UFOextender|UFO Extender's Information Page]]. You can download the latest version and patches here: [[:file:UFOLoader.zip|UFOextender]]. | + | This is the original program created by [[user:seb76|Seb76]] for use with ''Enemy Unknown''. Check out the [[UFOextender|UFO Extender's Information Page]]. You can download the latest version and patches here: [[:file:UFOLoader.zip|UFO Extender]]. |
| | | |
− | Ideas for upcoming release:
| + | If you're interested in the source code, it is available. Be warned you'll need to decompile the executable and be familiar with disassembly terminology to understand a lot of what the Extender does, since it inserts new lines into preexisting code. The source files for the Extender are here: [[Image:UFOExtender-src.zip]]. |
− | | |
− | *Armor counts for more against damage but it is ablative: keep getting shot and eventually there will be no armor. This means that any weapon is still effective.
| |
− | *Reconcept on damage and autopsies: Damage is calculated as normal and applied fully against armor but any damage that penetrates the armor will be reduced if the autopsy for that species has not been done, unless the shot was to the head.
| |
− | *The chance to get alien weapons is reduced depending on the attack type. Hi-Ex will most likely destroy any weapon the alien is using if it is killed by the attack. In other cases, there is a 50-100% chance, depending on the weapon, that the weapon self-destructs when its owner is killed by usual means.
| |
| | | |
| ==[[TFTDextender|TFTD Extender]]== | | ==[[TFTDextender|TFTD Extender]]== |
− | This is the conversion from UFOloader. It adds a lot of functionality and fixes to the Collector's Edition (MS Windows version) of ''Terror from the Deep''. Click on the title to get to the information page.
| + | It adds a lot of functionality and fixes to the Collector's Edition (MS Windows version) of ''Terror from the Deep''. Click on the title to get to the information page. |
− | | |
− | Do not hesitate to report any problem you encounter with it, I'll try to help you fix it.
| |
| | | |
| For those interested, here is the [[:File:TFTDextender-src.zip| source code]] for the Extender. | | For those interested, here is the [[:File:TFTDextender-src.zip| source code]] for the Extender. |
| | | |
− | ==Modding the Tank/Cannon into a Tank/Chaingun==
| + | ==Other information== |
− | | |
− | Many people have questions about this. It's fairly easy to change the ammo type of the Tank/Cannon turrent and damage into a AP/rifle and then giving the turret autofire. The real problem is changing the amount of ammo in the tank and not cause problems with the amount of ammo in your base stores. In the executable there are various places that handle updating the amount of ammo for the various events: adding a tank onto a craft(checking if the base has the proper amount of ammo for the tank and removing that amount from base stores, if so), removing the tank from a craft (adding the ammo back to base stores), post-tactical (adding the remaining ammo from the tank into base stores and attempting to add the tank back onto the craft), and post base-defense (adding the remaining ammo to base stores.) In addition, there is the line that sets the amount of ammo for the tank in unitref.dat. If you miss any of these areas, your ammo supply quickly spirals out of control or you get no benefit for the changes you have made.
| |
− | | |
− | This was my initial experiment with Assembly before I learned about Seb's Extender. All of this was done by modifying the bytes of code directly and rearranging them to get my changes to fit.
| |
− | | |
− | The DOS version of the game makes it much simpler to adjust the stats, but I have lost the notes on the offsets. The problem with the CE version is the way the compiler wrote the calculations. In the code, the value was calculated by using multiples of five with bit-shifts to get to 30. This means you can't choose any amount for your ammo. I rewrote these lines to make it simpler to understand and give more freedom to choose the value(Feel free to use these changes. I gave my tank 60 rounds {3Ch}. However, unless you want to deduce for yourself how to modify the proper locations, don't increase the amount of ammo over 63. [This has to do with how the game uses bit-shifts to calculate remaining ammo during the post-tatical phase]):
| |
− |
| |
− | <nowiki>TANK/CANNON AMMO ALTERATION
| |
− | POST-TACTICAL PHASE BASE/CRAFT INVENTORY UPDATE
| |
− | 0x449C53: B8 3C 00 00 00 0F AF C2 90 90 3B F0 7D 2C 66 0F B6 D2 66 01 17 B8 89 88 88 88 F7 EE 03 D6 C7 44 24 10 01 00 00 00 C1 FA 05 8B C2 C1 E8 1F 03 D0 88 55 2C 66 0F B6
| |
− | D2 66 29 17 66 0F B6 45 00 8B D0 C1 E2 0B 2B D0 C1 E2 04 03 D0 C1 E2 02 66 02 91 1A 01 00 00 90 90
| |
− | | |
− | .text:00449C53 mov eax, 3Ch
| |
− | .text:00449C58 imul eax, edx
| |
− | .text:00449C5B nop
| |
− | .text:00449C5C nop
| |
− | .text:00449C5D cmp esi, eax
| |
− | .text:00449C5F jge short loc_449C8D
| |
− | .text:00449C61 movzx dx, dl
| |
− | .text:00449C65 add [edi], dx
| |
− | .text:00449C68 mov eax, 88888889h
| |
− | .text:00449C6D imul esi
| |
− | .text:00449C6F add edx, esi
| |
− | .text:00449C71 mov [esp+30h+var_20], 1
| |
− | .text:00449C79 sar edx, 5
| |
− | .text:00449C7C mov eax, edx
| |
− | .text:00449C7E shr eax, 1Fh
| |
− | .text:00449C81 add edx, eax
| |
− | .text:00449C83 mov [ebp+2Ch], dl
| |
− | .text:00449C86 movzx dx, dl
| |
− | .text:00449C8A sub [edi], dx
| |
− | .text:00449C8D movzx ax, byte ptr [ebp+0]
| |
− | .text:00449C92 mov edx, eax
| |
− | .text:00449C94 shl edx, 0Bh
| |
− | .text:00449C97 sub edx, eax
| |
− | .text:00449C99 shl edx, 4
| |
− | .text:00449C9C add edx, eax
| |
− | .text:00449C9E shl edx, 2
| |
− | .text:00449CA1 db 66h
| |
− | .text:00449CA1 add dl, [ecx+11Ah]
| |
− | .text:00449CA8 nop
| |
− | .text:00449CA9 nop
| |
− | | |
− | 0x449DFA: B8 3C 00 00 00 0F AF C2 3B F0 7D 2E 90 90 66 0F B6 D2 66 01 17 B8 89 88 88 88 F7 EE 03 D6 C7 44 24 10 01 00 00 00 C1 FA 05 8B C2 C1 E8 1F 03 D0 88 55 00 66 0F B6
| |
− | D2 66 29 17 66 0F B6 45 00 8B D0 C1 E2 0B 2B D0 C1 E2 04 03 D0 C1 E2 02 66 01 91 1A 01 00 00 90 90
| |
− | | |
− | .text:00449DFA mov eax, 3Ch
| |
− | .text:00449DFF imul eax, edx
| |
− | .text:00449E02 cmp esi, eax
| |
− | .text:00449E04 jge short loc_449E34
| |
− | .text:00449E06 nop
| |
− | .text:00449E07 nop
| |
− | .text:00449E08 movzx dx, dl
| |
− | .text:00449E0C add [edi], dx
| |
− | .text:00449E0F mov eax, 88888889h
| |
− | .text:00449E14 imul esi
| |
− | .text:00449E16 add edx, esi
| |
− | .text:00449E18 mov [esp+30h+var_20], 1
| |
− | .text:00449E20 sar edx, 5
| |
− | .text:00449E23 mov eax, edx
| |
− | .text:00449E25 shr eax, 1Fh
| |
− | .text:00449E28 add edx, eax
| |
− | .text:00449E2A mov [ebp+0], dl
| |
− | .text:00449E2D movzx dx, dl
| |
− | .text:00449E31 sub [edi], dx
| |
− | .text:00449E34 movzx ax, byte ptr [ebp+0]
| |
− | .text:00449E39 mov edx, eax
| |
− | .text:00449E3B shl edx, 0Bh
| |
− | .text:00449E3E sub edx, eax
| |
− | .text:00449E40 shl edx, 4
| |
− | .text:00449E43 add edx, eax
| |
− | .text:00449E45 shl edx, 2
| |
− | .text:00449E48 add [ecx+11Ah], dx
| |
− | .text:00449E4F nop
| |
− | .text:00449E50 nop
| |
− | | |
− | [TANK/CHAINGUN AMMO AMOUNT SET WHEN GEOSCAPE UPDATES UNITREF.DAT FOR NEXT BATTLE]
| |
− | 0x44ED27: C6 45 76 3C
| |
− | | |
− | .text:0044ED27 mov byte ptr [ebp+76h], 3Ch
| |
− | | |
− | [TANK/CHAINGUN AMMO CHECK IN BASE INVENTORY AND ALTERATION OF AMOUNT]
| |
− | 0x456410: 66 83 84 90 1A 01 00 00 3C
| |
− | | |
− | .text:00456410 add word ptr [eax+edx*4+11Ah], 3Ch
| |
− | 0x4564F1: 66 83 F9 3C
| |
− | .text:004564F1 cmp cx, 3Ch
| |
− | 0x456512: 83 C1 C4
| |
− | .text:00456512 add ecx, 0FFFFFFC4h (add ecx, -3Ch)
| |
− | | |
− | [Alternate option]
| |
− | 0x456512: 83 E9 3C
| |
− | .text:00456512 sub ecx, 3Ch
| |
− | | |
− | | |
− | TANK STATS start at offset 47573B
| |
− | | |
− | TANK UFOpaedia info 4752B0~4752CF
| |
− | </nowiki>
| |
− | | |
− | ==Comparison of Damage routines==
| |
− | [[File:xcraft-dam-routine.GIF]]
| |
− | | |
− | | |
− | To explain, first the memory address of the Xcraft weapon is loaded to eax. Then the damage value is read from (eax+6) and loaded into bx. This value is sent to the random function where the value generated is returned through eax. Thereafter, the base value (ebx) is added to the random value (eax) for a range of 100-200%. The value of eax has edx subtracted from it (after extensive testing of several encounters and having edx displayed for each attack, edx always seems to be 0). eax is bit-shifted 1 space to the right {divided by two} and the final amount added to the amount of damage the craft has sustained (edi+0Ah). The result is that Xcraft weapons do 50-100% damage.
| |
− | | |
− | [[File:UFO-dam-routine.GIF]]
| |
− | | |
− | In the UFO case: the memory location for the UFO stats are set in ecx. Then the UFO weapon power is read (ecx+16h) and put into dx. Then this value is sent to the random funtion and again returned through eax (or ax as is the case here). ecx is set to zero and the random value is checked to see if zero was generated [cmp(compare) ax, cx]. If this is true, the program jumps past the section to assign damage to the Xcraft.
| |
− | | |
− | | |
− | | |
− | | |
− | *The main routine for interdiction in DOS1.4 version is from 330B0~336A8.
| |
− | | |
− | | |
− | ==Table of Battlescape sound calls==
| |
− | The following is a list of how most events in TACTICAL generate sounds. This data is scattered throughout the executable in various data arrays. First an event number is passed to the sound subroutine. The program then compares the event with its corresponding entry in another section to determine how to play that sound. 06 is the standard method. 01 plays the sound uninterrupted by other sounds.
| |
− | Here is the link for [[SOUND|SAMPLE2.CAT]] references.
| |
− | <nowiki>
| |
− | Play CAT
| |
− | Evt# Setting reference Description
| |
− | 00 00 -- Normal bipedal movement. Routine refers to tileset and alternates between 1 and 2.
| |
− | 01 01 0E normal tank move
| |
− | 02 01 00 snakeman move
| |
− | 03 02 --
| |
− | 04 01 0F Flying unit move
| |
− | 05 01 10 Celatid move
| |
− | 06 01 2F Silacoid move
| |
− | 07 02 --
| |
− | 08 02 --
| |
− | 09 02 --
| |
− | 0A 01 28 hovertank/cyberdisk move
| |
− | 0B 06 04 rifle/pistol shoot
| |
− | 0C 06 16 bullet hit
| |
− | 0D 03 14 sliding door opens. Routine randomly plays 1 of the 2 entries in SAMPLE2.
| |
− | 0E 06 03 normal door opens
| |
− | 0F 02 --
| |
− | 10 06 0C big gun shoots
| |
− | 11 06 0D big gun hits
| |
− | 12 06 0B laser gun shoots
| |
− | 13 06 13 laser shot hits
| |
− | 14 06 12 plasma gun shoots
| |
− | 15 06 13 plasma shot hits
| |
− | 16 06 34 rocket launches
| |
− | 17 06 35 blaster bomb/stun launcher shoots
| |
− | 18 06 0C small explosion (problem: zombie move)
| |
− | 19 06 05 big explosion
| |
− | 1A 02 -- stun rod (*problem*)
| |
− | 1B 06 24 psi attack
| |
− | 1C 06 06 mind probe use*
| |
− | 1D 06 11 reload weapon
| |
− | 1E 06 26 place an item
| |
− | 1F 02 --
| |
− | 20 04 -- death of a male. Routine randomly plays 1 of the 3 sounds in SAMPLE2.
| |
− | 21 06 17 tank destroyed
| |
− | 22 06 0A sectoid death
| |
− | 23 06 08 snakeman death
| |
− | 24 06 09 etheral death
| |
− | 25 06 06 muton death
| |
− | 26 06 0A floater death
| |
− | 27 06 07 celatid death
| |
− | 28 06 08 silacoid death
| |
− | 29 06 09 chryssalid death
| |
− | 2A 06 0A reaper death
| |
− | 2B 06 17 sectopod death
| |
− | 2C 06 17 cyberdisk death
| |
− | 2D 06 30 zombie & reaper attack
| |
− | 2E 06 31 chryssalid attack
| |
− | 2F 06 32 silacoid attack
| |
− | 30 06 30 celatid attack
| |
− | 31 06 27 throw an item
| |
− | 32 05 -- death of a female. Routine randomly plays 1 of the 3 sounds in SAMPLE2.
| |
− | 33 02 --
| |
− | 34 02
| |
− | 35 02
| |
− | 36 02
| |
− | 37 02
| |
− | </nowiki>
| |
− | | |
− | ==Other Random Sound Information== | |
− | <nowiki>
| |
− | | |
− | 406100-subroutine for melee attacks
| |
− | 406110- set default melee sound event to 1A
| |
− | (4067C8)data base of melee attacks
| |
− | value offset sound event #
| |
− | 00 461B2 2F
| |
− | 01 461BC 2E
| |
− | 02 461C6 2D
| |
− | 03 461E7 skip
| |
− | 04 461E7 skip
| |
− | 05 461E7 skip
| |
− | 06 461E7 skip
| |
− | 07 461C6 2D
| |
− | | |
− | Reference points for unit movement sound event IDs. [this word referenced]
| |
− | .data:0046D1A0 00 00 00 00 01 00 01 00 00 00 00 00 [00 00] 00 00
| |
− | .data:0046D1B0 [00 00] 00 00 [00 00] 00 00 [01 00] 01 00 [00 00] 00 00
| |
− | .data:0046D1C0 [02 00] 01 00 [00 00] 00 00 [00 00] 00 00 [04 00] 01 00
| |
− | .data:0046D1D0 [05 00] 01 00 [06 00] 01 00 [00 00] 00 00 [00 00] 00 00
| |
− | .data:0046D1E0 [00 00] 00 00 [0A 00] 01 00 [00 00] 00 00 [00 00] 00 00
| |
− | .data:0046D1F0 [18 00] 01 00 01 00 00 00 01 00 0B 00 0C 00 01 00
| |
− |
| |
− | data set for death scream per unit.
| |
− | 0.data:0046B644 word_46B644 dw 20h ; DATA XREF: sub_40E450+55�r
| |
− | 1.data:0046B646 db 20h
| |
− | 2.data:0046B648 db 20h
| |
− | 3.data:0046B64A db 21h
| |
− | 4.data:0046B64C db 22h
| |
− | 5.data:0046B64E db 23h
| |
− | 6.data:0046B650 db 24h
| |
− | 7.data:0046B652 db 25h
| |
− | 8.data:0046B654 db 26h
| |
− | 9.data:0046B656 db 27h
| |
− | A.data:0046B658 db 28h
| |
− | B.data:0046B65A db 29h
| |
− | C.data:0046B65C db 2Ah
| |
− | D.data:0046B65E db 2Bh
| |
− | E.data:0046B660 db 2Ch
| |
− | F.data:0046B662 db 20h
| |
− | 10.data:0046B664 db 32h
| |
− | 11.data:0046B666 db 20h
| |
− | | |
− | | |
− | SUBROUTINE USED FOR
| |
− | | |
− | 404650+1AE PSI ATTACK EFX
| |
− | 406100+4F9 TERRORIST MELEE ATTACK EFX
| |
− | 40B420+111 EXPLOSION EFX
| |
− | 40B420+24F EXPLOSION EFX?
| |
− | 40E450+73 DEATH SCREAM EFX
| |
− | 40F2C0+285 PLACE ITEM EFX
| |
− | 4110E0+E0 ITEM USE EFX
| |
− | 4110E0+901 SHOT HIT EFX
| |
− | 419660+1A5 PLACE ITEM (INVENTORY) EFX
| |
− | 419660+346 RELOAD EFX
| |
− | 41DCC0+D1 STUN ROD ATTACK EFX
| |
− | 41EE10+8C PSI ATTACK EFX
| |
− | 41F0F0+8C PSI ATTACK EFX
| |
− | 41FD10+8B MIND PROBE EFX
| |
− | 421140+13 DOORS EFX
| |
− | 4247D0+27A NON-WALK MOVE EFX
| |
− | 4247D0+4D4 WALK MOVE EFX
| |
− | 42A630+B7 GMTATICS.MID
| |
− | 42A6F0+18 GMLOSE.MID
| |
− | 42B6F0+E9 GMWIN.MID
| |
− | 43D8C0+E GEOSCAPE OPEN WINDOW EFX
| |
− | 4407D0+2E ?
| |
− | 4407D0+9C GMGEOx.MID
| |
− | 445B00+BC GMINTER.MID
| |
− | 4467C0+1C1 X-COM CRAFT LEFT WEAPON EFX
| |
− | 4467C0+233 X-COM CRAFT RIGHT WEAPON EFX
| |
− | 446DA0+267 UFO HIT EFX
| |
− | 4470B0+F2 UNKNOWN INTERCEPTION EVENT (CRAFT CRASH EFX?)
| |
− | 447EE0+32 GMSTORY.MID
| |
− | 448390+28F ??
| |
− | 448390+2DD BASE DEFENSE (EVENT 9)
| |
− | 448390+3DC ?0A (BASE DEFENSE?)
| |
− | 448390+3F1 ?0A
| |
− | 448390+406 ?0A
| |
− | 44A220+15 GMSTORY.MID
| |
− | 44C940+10 GMDEFEND.MID
| |
− | 44CD40+26 GMBASE.MID
| |
− | 44D030+D GMDEFEND.MID
| |
− | 44D3C0+E GMMARS.MID
| |
− | 44D690+10 GMMARS.MID
| |
− | 44DACO+10 GMBASE.MID
| |
− | 450F10+91 BLEEP (1)
| |
− | 45DCA0+17 ??
| |
− | </nowiki>
| |
− | | |
− | ==Functions used in UFOextender's new interception routines==
| |
− | For those that might want to know how accuracy is calculated with the new options for interception turned on:
| |
− | | |
− | X-Craft Accuracy
| |
− | | |
− | [(1+((3-(.5*(difficulty level-1)))/UFOsize)/2 ] * Weapon Accuracy ....... [beginner=1..superhuman=5]
| |
− | <nowiki>Diff Ship Sizes
| |
− | VS S M L VL
| |
− | begin 0.8 0.875 1 1.25 2
| |
− | exp 0.75 0.8125 0.91667 1.125 1.75
| |
− | vet 0.7 0.75 0.83333 1 1.5
| |
− | Genius 0.65 0.6875 0.75 0.875 1.25
| |
− | Super 0.6 0.625 0.66667 0.75 1</nowiki>
| |
− |
| |
− | | |
− | UFO Accuracy
| |
− | | |
− | 60 + ((difficulty level-1)*3) - [Cautious Mode bonus (10)]
| |
− | | |
− | ==Other Information==
| |