Airfix DogFighter Programmer's Manual


<< Page 3  Tutorial   Page 5 >>

This is the format of the MODL-block for the FW190:

MODL 63 00 00 00 Header and Descriptor Length (RHN)
0B 39 17 42    49 2E 7F 40    86 BB 43 40 X- Z- and Y parameters (RHN)
00 00 00 00    0C 5F 01 BD    00 00 00 80 Pitch, Rotate and Bank parameters (RHN)
dining_room 00 Location + End Byte
Game\Objects\Aircrafts\AcFw190.object 00 Object Descriptor Ref. + End Byte
model1 00 Object Label + End Byte
00 00 00 00 Set Team
00 Set Squad End Byte
01 00 Set AI = true
00 00 ??
00 End Byte for SetPickUpType 
01 00 00 00 AISetStayRoom (RHN) = true
32 00 00 00 AISetAggression (RHN) = 50

We need to realise that, if we insert these two strings at the places indicated below, we add 11 characters to the MODL-Descriptor string. We therefore have to adjust the String Length Descriptor for this MODL Block. The MODL-block length was Hex 63. We should add Decimal 11, i.e. Hex B, so that will give Hex 6E.

If you have trouble with Hex calculations, let the Windows Calculator do it for you. Simply change the View from “Standard” to “Scientific”, and you have a very handy Hex Converter!

MODL 6E 00 00 00 Header and Descriptor Length (RHN)
8A 2D 58 42    0D 2D 50 40    CD F9 5E 40 X- Z- and Y parameters (RHN)
00 00 00 00    D8 0F C9 3F    00 00 00 80 Pitch, Rotate and Bank parameters (RHN)
dining_room 00 Location + End Byte
Game\Objects\Aircrafts\AcFw190.object 00 Object Descriptor Ref. + End Byte
Fw_190 00 Object Label + End Byte
03 00 00 00 Set Team to Axis
32 31 00 Set Squad = 21
01 00 Set AI = true
00 00 ??
puRepairs 00 SetPickUpType + End Byte
01 00 00 00 AISetStayRoom (RHN) = true
32 00 00 00 AISetAggression (RHN) = 50


Change the 63 after MODL to 6E, change the Object Label from model1 to Fw_190, change the first pair of Zeroes for the SetTeam-parameter to 03 and then insert the strings for the SetSquad- and SetPickupType-properties:

000000A0    00 32 00 00 00 4D 4F 44 4C 6E 00 00 00 0B 39 17    .2...MODLn....9.
000000B0    42 49 2E 7F 40 86 BB 43 40 00 00 00 00 0C 5F 01    BI..@†»C@....._.
000000C0    BD 00 00 00 80 64 69 6E 69 6E 67 5F 72 6F 6F 6D    ˝...€dining_room
000000D0    00 47 61 6D 65 5C 4F 62 6A 65 63 74 73 5C 41 69    .Game\Objects\Ai
000000E0    72 63 72 61 66 74 73 5C 41 63 46 77 31 39 30 2E    rcrafts\AcFw190.
000000F0    6F 62 6A 65 63 74 00 46 77 5F 31 39 30 00 03 00    object.Fw_190...
00000100    00 00 32 31 00 01 00 00 00 70 75 52 65 70 61 69    ..21.....puRepai
00000110    72 73 00 01 00 00 00 32 00 00 00 4D 4F 44 4C 63    rs.....2...MODLc

If you save this and try to run it, the program will crash. Why? What we haven't discussed yet is the first Block in the file: the FHOU-Block....
It is a very short one, only 8 bytes in length. The first four positions contain the string FHOU, the next four bytes contain the length of the COMPLETE file in RHN. That is, without the birst 8 bytes, i.e. the FHOU-Block.

If you look at the listing of the .level-file in 3.2 (page 3), you see that the first line contains: FHOU 8A 03 00 00, where  bold is once again Hexadecimal values. Since by now we know about RHN, we can see that the actual value here is 00 00 03 8A, or in short Hex(38A).  If we look at the end of the complete file we notice that it is actually Hex(39D) long, which is a difference of Hex(13), or Decimal 19. We added 11 characters/bytes in our update, the other 8 in the extra length are the 8 bytes of the FHOU-block itself. 

So, we need to include the 11 bytes we added in our update into the file-length, but not the 8 bytes of the FHOU-Block, as its file length descriptor excludes its own length. We therefore need to adjust the FHOU-Block to mention a length of Hex(38A) + Dec(11). This is equivalent to Hex(38A) + Hex(B), which makes it Hex(395), or in full: 00 00 03 95. In the RHN-notation that would be: 95 03 00 00

So before we can run the updated game, we need to adjust 8A 03 00 00 in the first line to 95 03 00 00.

When we run the updated level straight away, we will be a bit disappointed as no changes seem to have been made. Why not? You might recall that the Game Engine takes its info about models from the .asf-file, not the .level-file. The .asf-file is created automatically when the level is saved in the House Editor....

Start the House Editor, open sample1, have a look at the Focke Wulf to see that it now displays the Object Label  "Fw_190" (by hovering the mouse over the model), SAVE the Level again and exit the House Editor. If you haven't touched anything this will leave the .level-file unchanged, but will regenerate the .asf-file.
Go back to Multiplayer, start a server, select the sample1-level and check that each time when you shoot down the FW190 it will yield a Repair-kit...

You might have noticed that we haven't taken off from an airfield but from the carpet: an airfield isn't really necessary as it is the PSP that determines where you take off from. But we will include some airfields later because they can play a vital role in Missions...


<< Page 3  Tutorial   Page 5 >>