Skrilax_CZ Posted November 3, 2009 Share Posted November 3, 2009 ... And here is your problem: the palace has 1000hp. 2hp are repaired every tick. 2 / 1000 * 256 = 0. So, 0% of the cost has to be paid (values are round down). So, repairing palace is for free :) ...And a typo came :P I guess you meant (2 * 256) / 1000 (otherwise repair for buildings with HP more than 2 would be free). Quote Link to comment Share on other sites More sharing options...
TrueBrain Posted November 3, 2009 Share Posted November 3, 2009 Whooops..... typo there. Thanks TrueBrain for pointing that out. I modified the post :P(..)Can't resist: still a typo. Range is from 0 to 255, not 256 ;) Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 3, 2009 Author Share Posted November 3, 2009 TrueBrain, thanks a lot for clearing this for us ;D Once again, this is something people could only be guessing about until recently :)From campaign 4 and on you don't repair per 3 hitpoints, but per 5 hitpoints. For the same cost ;)In both cases, you only pay for repairing 2 hitpoints. So an almost destroyed structure cost only 2/3th or 2/5th of the cost to repair.Do you mean that after mission 3, repair is faster (restoring each 5 hitpoints instead of 3)? Interesting.The palace shows in a nice way the problem of avoiding floats. It is very common for any (sane) application to avoid floats, but for Dune2 it is more fundamental: it doesn't use any FPU command (old computers didn't have a FPU :P). To still do floating calculations, a simple trick is used: multiple every float by value N. In this case: 256. And here is your problem: the palace has 1000hp. 2hp are repaired every tick. 2 / 1000 * 256 = 0. So, 0% of the cost has to be paid (values are round down). So, repairing palace is for free :) Every structure with the hp of over 512hp has this 'problem'.I wonder how this all was avoided in v1.0, where the Palace is repaired normally. Quote Link to comment Share on other sites More sharing options...
TrueBrain Posted November 3, 2009 Share Posted November 3, 2009 TrueBrain, thanks a lot for clearing this for us ;D Once again, this is something people could only be guessing about until recently :)It helps a lot to get to know the code by looking for such specific things ;) So if you have any other things you wonder about, just ask :)Do you mean that after mission 3, repair is faster (restoring each 5 hitpoints instead of 3)? Interesting.Yup. And I thought so too ;)I wonder how this all was avoided in v1.0, where the Palace is repaired normally.I don't know (and I guess only segra (via IDA) can give more insight in that). But if I had to guess, I think one of the following:1) a higher float-resolution (unlikely)2) Palace has lower hp (easy to check)3) using 3 or 5 instead of 2 (so you pay more). I guess this is what 1.0 does, and that for 1.07 they 'tuned' it a bit and made repairs cheaper. Quote Link to comment Share on other sites More sharing options...
Skrilax_CZ Posted November 3, 2009 Share Posted November 3, 2009 ad0 That would have to be the 5 (or 4 least), 3 would be maximum of 768. Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 4, 2009 Author Share Posted November 4, 2009 It helps a lot to get to know the code by looking for such specific things ;) So if you have any other things you wonder about, just ask :)Ooh, thanks :)2) Palace has lower hp (easy to check)3) using 3 or 5 instead of 2 (so you pay more). I guess this is what 1.0 does, and that for 1.07 they 'tuned' it a bit and made repairs cheaper.The Palace has the same amount of hp in v1.0, so I guess you're right about the repairs being cheaper in v1.07 :)EDIT: You were right, the repair cost is reduced by a lot in v1.07. For example, to repair a half-damaged Windtrap (placed on bare rock) costs 294 credits in v1.0, and only 42 in v1.07. Quote Link to comment Share on other sites More sharing options...
TrueBrain Posted November 4, 2009 Share Posted November 4, 2009 (..)EDIT: You were right, the repair cost is reduced by a lot in v1.07. For example, to repair a half-damaged Windtrap (placed on bare rock) costs 294 credits in v1.0, and only 42 in v1.07.I love to be right :) Quote Link to comment Share on other sites More sharing options...
Nyerguds Posted November 5, 2009 Share Posted November 5, 2009 Hm, I should really play Dune 1.07... I indeed remember the repairs costing tons of money in my old 1.0... I wonder how much different it'd be to play it through again now.Though tbh I prefer playing the Sega Megadrive version. It has cooler graphics, different missions and better controls :P Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 6, 2009 Author Share Posted November 6, 2009 I have moved our discussion of Dune: The Battle for Arrakis to Gaming:http://forum.dune2k.com/index.php?topic=22142.0 Quote Link to comment Share on other sites More sharing options...
jordos Posted November 7, 2009 Share Posted November 7, 2009 Segra, where in your Dune2 IDA database are those house specific techtree exceptions? I think I've found a few in the structurebuildlistcreate function but I don't really understand how they work.Also, you posted some information on the worms disappearing after three swallows but would you mind telling me what to change exactly to disable it?Many thanks! Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 8, 2009 Author Share Posted November 8, 2009 The techtree code exceptions are scattered around various threads. I've linked to most of them here.As for the worms, the solution is here:you can change it, but you hav eto change it via the exe not the script.at a guess its because the weapons are their own "units" and it takes the kills instead of the worm itself, altho im not 100% sure of this.. id say thats what it isyou just need to find this locationseg015:053B 26 C6 47 58 03          mov  es:[bx+_unitGame.HarvesterSpiceCapacity], 3and u can specify how many units u want the worm tobe able to eator this line here, seg030:178C 26 FE 4F 58           dec  es:[bx+_unitGame.HarvesterSpiceCapacity]NOP that out and the worm eat count wont ever change Quote Link to comment Share on other sites More sharing options...
jordos Posted November 8, 2009 Share Posted November 8, 2009 Ah brilliant, many thanks! I thought I had checked all of segra's posts but guess I wasn't very thorough.edit: still don't understand how those exceptions work though :) the ordos heavy factory and harkonnen light factory ones are obvious but the others... Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 9, 2009 Author Share Posted November 9, 2009 edit: still don't understand how those exceptions work though :) the ordos heavy factory and harkonnen light factory ones are obvious but the others...That depends on what you want to do with them :) If you want to transfer the same effect (e.g. the building always starts fully upgraded) to another House or another structure, you need to change HouseID and/or TypeIndex. If you want to do something else, I'm afraid I'm not competent enough to help you out. Quote Link to comment Share on other sites More sharing options...
Nyerguds Posted November 9, 2009 Share Posted November 9, 2009 If you want to remove the worm code, he said NOP it out. That means, replace it by bytes '90'. They give the program a "do nothing" (NOP = No Operation) command, so it's a handy way to remove code. Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 10, 2009 Author Share Posted November 10, 2009 I wonder if it is possible to limit the number of Starports and Palaces that the player can own at a time to one, like in the Sega version. The Saboteurs are limited to 2 (3 in v1.0), and this limit can be disabled, but it has something to do with the values currently known as "Unit array min/max" IIRC. Quote Link to comment Share on other sites More sharing options...
jordos Posted November 10, 2009 Share Posted November 10, 2009 Thanks Nyerguds, I actually have some extremely basic knowledge of assembly and managed it myself. I also successfully removed the code that turned squads into single soldiers at 50% hp (I replaced the single soldiers with the Fremen&Sardaukar troopers :) ), keeping the retreat check. I was quite proud of that one. :DBut trying to answer Flibble's post I realize I actually don't have a clear idea of what changes I'd like to do yet. For now I wanted to make the Sardaukar light factory start upgraded just like the Harkonnen (and also keep the harkonnen upgraded light factory). With or without trike doesn't matter. But the other tech tree stuff in that post seems to be aimed at not displaying the upgrade button if certain conditions are met (that's just a guess, I really can't make much of assembly code)I'll probably have to replace one of the other exceptions but I'm sure I'll find one suitable for that. Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 10, 2009 Author Share Posted November 10, 2009 I also successfully removed the code that turned squads into single soldiers at 50% hp (I replaced the single soldiers with the Fremen&Sardaukar troopers :) ), keeping the retreat check. I was quite proud of that one. :DCould you please post how you did that? In fact, I have even less knowledge and thus won't figure it out on my own :)But trying to answer Flibble's post I realize I actually don't have a clear idea of what changes I'd like to do yet. For now I wanted to make the Sardaukar light factory start upgraded just like the Harkonnen (and also keep the harkonnen upgraded light factory).Is it possible to do that without adding a new code chunk?But the other tech tree stuff in that post seems to be aimed at not displaying the upgrade button if certain conditions are met (that's just a guess, I really can't make much of assembly code)Makes sense, since the Harkonnen Hi-Tech Factory doesn't need to be upgraded at all (same for the Ordos skipping the 2nd Heavy Factory upgrade, I suppose). Quote Link to comment Share on other sites More sharing options...
jordos Posted November 10, 2009 Share Posted November 10, 2009 Sure, I'll post the IDA code as well so someone with some experience can tell me if I've done something stupid :)I (or rather, segra) found a check for the trooper squad and infantry squad in the UnitTakeDamage function.seg031:0D66          loc_290C6:                          ; CODE XREF: unitTakeDamage+1DAjseg031:0D66 C4 5E 06              les   bx, [bp+unitGamePtr]         ; Load Full Pointer to ES:xxseg031:0D69 26 80 7F 02 05           cmp   byte ptr es:[bx+2], 5        ; troopersseg031:0D6E 74 0A               jz    short TrooperInfantry        ; Jump if Zero (ZF=1)seg031:0D70 C4 5E 06              les   bx, [bp+6]              ; Load Full Pointer to ES:xxseg031:0D73 26 80 7F 02 04           cmp   byte ptr es:[bx+2], 4        ; infantryseg031:0D78 75 79               jnz   short loc_29153           ; Jump if Not Zero (ZF=0)if true it does some misc stuff I can't figure out but just assumed was the soldier spawning code (I saw some references to the hit points :) ). I just skip it by patching in a jump to the code that follows it, which I guessed was the retreat check since it compares against the house weakness which segra told us is also used for that.g031:0D7A          TrooperInfantry:                       ; CODE XREF: unitTakeDamage+1F6jseg031:0D7A EB 46               jmp   short loc_29122           ; Jumpseg031:0D7A          ; ---------------------------------------------------------------------------seg031:0D7C 06                 db   6seg031:0D7D          ; ---------------------------------------------------------------------------seg031:0D7D 26 8A 47 02            mov   al, es:[bx+2]seg031:0D81 04 02               add   al, 2                ; Addseg031:0D83 C4 5E 06              les   bx, [bp+unitGamePtr]         ; Load Full Pointer to ES:xxseg031:0D86 26 88 47 02            mov   es:[bx+_unitGame.typeIndex], alseg031:0D8A C4 5E 06              les   bx, [bp+unitGamePtr]         ; Load Full Pointer to ES:xxseg031:0D8D 26 8A 47 02            mov   al, es:[bx+_unitGame.typeIndex]seg031:0D91 98                 cbw                     ; AL -> AX (with sign)seg031:0D92 BA 5A 00              mov   dx, size _unitDataseg031:0D95 F7 EA               imul   dx                  ; Signed Multiplyseg031:0D97 05 00 00              add   ax, 0                ; Addseg031:0D9A C7 46 FE 0B 3B           mov   word ptr [bp+unitDataPtr+2], seg seg130seg031:0D9F 89 46 FC              mov   word ptr [bp+unitDataPtr], axseg031:0DA2 C4 5E FC              les   bx, [bp+unitDataPtr]         ; Load Full Pointer to ES:xxseg031:0DA5 26 8B 47 10            mov   ax, es:[bx+_unitData.HitPoints]seg031:0DA9 C4 5E 06              les   bx, [bp+unitGamePtr]         ; Load Full Pointer to ES:xxseg031:0DAC 26 89 47 0E            mov   es:[bx+_unitGame.HitPoints], axseg031:0DB0 FF 76 08              push   word ptr [bp+unitGamePtr+2]seg031:0DB3 FF 76 06              push   word ptr [bp+unitGamePtr]      ; unitGamePtrseg031:0DB6 B8 02 00              mov   ax, 2seg031:0DB9 50                 push   ax                  ; funcPtrIndexseg031:0DBA 9A 8E 00 D0 42           call   j_sub_566CF             ; Call Procedureseg031:0DBF 83 C4 06              add   sp, 6                ; AddThe retreat code it jumps to:g031:0DC2          loc_29122:                          ; CODE XREF: unitTakeDamage:TrooperInfantryjseg031:0DC2 9A 0E 00 B8 39           call   mapSeedRandomGet           ; Call Procedureseg031:0DC7 25 FF 00              and   ax, 0FFh               ; Logical ANDseg031:0DCAseg031:0DCA          loc_2912A:                          ; Load Full Pointer to ES:xxseg031:0DCA C4 5E 06              les   bx, [bp+unitGamePtr]seg031:0DCDseg031:0DCD          loc_2912D:seg031:0DCD 50                 push   axseg031:0DCEseg031:0DCE          loc_2912E:seg031:0DCE 26 8A 47 08            mov   al, es:[bx+_unitGame.houseID]seg031:0DD2seg031:0DD2          loc_29132:                          ; AL -> AX (with sign)seg031:0DD2 98                 cbwseg031:0DD3seg031:0DD3          loc_29133:seg031:0DD3 BA 1E 00              mov   dx, size _houseDataseg031:0DD6seg031:0DD6          loc_29136:                          ; Signed Multiplyseg031:0DD6 F7 EA               imul   dxseg031:0DD8seg031:0DD8          loc_29138:seg031:0DD8 8B D8               mov   bx, axseg031:0DDAseg031:0DDA          loc_2913A:seg031:0DDA 58                 pop   axseg031:0DDB 3B 87 F0 37            cmp   ax, houseData.Weakness[bx]      ; Compare Two Operandsseg031:0DDF 73 12               jnb   short loc_29153           ; Jump if Not Below (CF=0)seg031:0DE1 B8 02 00              mov   ax, 2seg031:0DE4 50                 push   ax                  ; actionseg031:0DE5 FF 76 08              push   word ptr [bp+unitGamePtr+2]seg031:0DE8 FF 76 06              push   word ptr [bp+unitGamePtr]      ; unitGamePtrseg031:0DEB 9A 05 00 6F 25           call   unitActionstart           ; Call Procedureseg031:0DF0 83 C4 06              add   sp, 6                ; AddTo patch it, search the exe for02 75 79 C4 5E 06 26 8Aand change it to04 75 79 EB 46 06 26 8A(I hope that's right)About the sardaukar light factory, most likely I'll have to replace another exception for that. (house of WOR springs to mind, tech level 5? Come on  ::) ) unless there's some kind of mathematical formula that can check both the Harkonnen and Sardaukar house ID in one line. Quote Link to comment Share on other sites More sharing options...
Nyerguds Posted November 10, 2009 Share Posted November 10, 2009 It all depends on the size of the commands, and how much space you got. 'some kind of mathematical formula' usually takes more bytes than 2 small checks :PThe check being 3 bytes and the jump 2, the 2 checks would need 10 bytes. Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 11, 2009 Author Share Posted November 11, 2009 With or without trike doesn't matter.Disabling a unit from the tech tree is easily doable with Nyerguds' editor :) Quote Link to comment Share on other sites More sharing options...
jordos Posted November 11, 2009 Share Posted November 11, 2009 You're right :) Actually why did they turn the raider trike into a code exception? It's easy enough to do with the existing parameters in Nyerguds editor, no? Quote Link to comment Share on other sites More sharing options...
Skrilax_CZ Posted November 11, 2009 Share Posted November 11, 2009 Problem is that if you disable a Trike from a house, Light Factory will still be available for it (unless Harkonnen with Hardcoded exception) in the Tech Level 2 (producing Carryalls). Anyway what is the Raider Trike exception like?I don't know how on x86 16bit (cause I only know 32bit x86 and there is no near and far addressing which I can't beat) but mostly visible on ARM the compilers aint perfect, allowing you to restate the disassembled code into less instructions and add some extra. (It is actually easier as the instructions are fixed 2 bytes (Thumb) or 4 bytes (or pair of them is joined).) Quote Link to comment Share on other sites More sharing options...
Nyerguds Posted November 12, 2009 Share Posted November 12, 2009 Does that matter if the player can just build Raiders instead? Quote Link to comment Share on other sites More sharing options...
MrFlibble Posted November 12, 2009 Author Share Posted November 12, 2009 You're right :) Actually why did they turn the raider trike into a code exception? It's easy enough to do with the existing parameters in Nyerguds editor, no?I can also find no plausible reason for this. No other unit is handled like that in the game. Perhaps it allows to avoid some side-effects we're still unaware of?Anyway, would be nice if you posted this code exception here (I think it's not mentioned in Segra's posts, unless I'm missing something) :)Problem is that if you disable a Trike from a house, Light Factory will still be available for it (unless Harkonnen with Hardcoded exception) in the Tech Level 2 (producing Carryalls).Tha Carryall icon is used whenever you have a production facility with nothing to produce from it. For example, if you give the Atreides player a WOR, you also get a Carryall icon (since the Troopers are disabled for Atreides). However, if I'm not mistaken, this does not grant the ability to actually produce Carryalls from such a building. Quote Link to comment Share on other sites More sharing options...
Will Posted November 13, 2009 Share Posted November 13, 2009 Anyway, would be nice if you posted this code exception here (I think it's not mentioned in Segra's posts, unless I'm missing something) :)Tha Carryall icon is used whenever you have a production facility with nothing to produce from it. For example, if you give the Atreides player a WOR, you also get a Carryall icon (since the Troopers are disabled for Atreides). However, if I'm not mistaken, this does not grant the ability to actually produce Carryalls from such a building.You are correct. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.