Jump to content

EXE editing & programming issues


MrFlibble

Recommended Posts

I've been browsing through old posts in the Dune II forum, and found that some people mention the AI is harder in The Building of A Dynasty than in The Battle for Arrakis:

I were playing Dune2 Battle for arrakis then and when i download the game from the internet i get Dune2 a building of a dinasty. Is it the update or what??

I noticed that ai got better and sand worms eat more then 2 units.

On battle for arrakis sandworms eat 2 units and then dissapair.

On building of a dinesty sandworms eat more then 2 units. On battle for arrakis AI even worse. When i used my tactics on buuilding of a dinesy they allmost killed me and believe me i am not a noob at dune2.

but everyone says that ai is better in dynasti

Of course, these people could have been talking about the The Building of A Dynasty v1.0 included with the original Super Dune 2 release, which has the "instant build" hack, thus making the AI more difficult. But I also got the impression that with the team bug fixed, the AI is harder in v1.0 than in v1.07: it builds more units and/or sends out attack teams more often.

I thought it could be due to money management: in v1.07, the AI spends some of its spice on rebuilding structures, whereas it might not do so in v1.0. Would be nice to know if this is true or not, but I don't have time for testing ATM.

Also, here's another topic of interest: http://forum.dune2k.com/index.php?topic=21421.0

EDIT: I decided not to post once more, since this is related to what I said previously. Remember out discussion of the LemonFactor variable?

Perhaps it's the chance a unit will be manufactured to act defensively - i.e. sit around like a lemon? Harkonnen are very defensive, Ordos slightly, Atreides not at all, and Fremen and Sardaukar always attack once they spawn.

I don't know if this has to do with the LemonFactor (probably not, after all), but it seems to me that the AI behavior is different depending on the Human player's House. Remember Daelin said that each playable House represents a difficulty level (Harkonnens=Easy, Atreides=Medium, Ordos=Hard)? I think the AI is less aggressive when you play the Harkonnens as compared to the Ordos for example. Still, more testing is needed to confirm this.

Link to comment
Share on other sites

Remember Daelin said that each playable House represents a difficulty level (Harkonnens=Easy, Atreides=Medium, Ordos=Hard)?

This doesn't relate to the LemonFactor though. LemonFactor  goes from low to high in the order Atreides, Ordos, Harkonnen. Atreides even has 0 there.

Link to comment
Share on other sites

It does not, as it seems, but it has to do with some AI behavior though:

hahah, just to make things really interesting...

LemonFactor only seems to be used within the UnitCreate function, and only if MovementType == 1

its compared against a value from the mapSeedRandomGet function, still not sure what this is does exactly...

but, it sets the 0x400 in the EMCDATA field... hmm

seg031:0A91 26 83 7F 3C 01                    cmp    es:[bx+_unitData.MovementType], 1

...

seg031:0A98 9A 0E 00 B8 39                    call    mapSeedRandomGet

seg031:0A9D 50                                push    ax

...

seg031:0AA8 58                                pop    ax

seg031:0AA9 3B 87 F2 37                      cmp    ax, houseData.LemonFactor[bx]

seg031:0AAD 73 09                            jnb    short loc_28E18

seg031:0ABD C4 5E F8                          les    bx, [bp+unitDataPtr]

seg031:0AB2 26 81 4F 04 00 04                or      word ptr es:[bx+_unitGame.emcData], 400h

Anyhow, it would be nice to find answers to all those questions though.

Link to comment
Share on other sites

Remember Daelin said that each playable House represents a difficulty level (Harkonnens=Easy, Atreides=Medium, Ordos=Hard)? I think the AI is less aggressive when you play the Harkonnens as compared to the Ordos for example. Still, more testing is needed to confirm this.

Actually this observation was related to techtree limitations and nothing more. The computer is just as stupid when playing harkonnen, ordos or atreides. I wonder if that Lemon Factor was actually implemented in the game. If modifying its values heavily does nothing then it's probably unused. Segra and his assembly magic may help here more.

-Daelin

Link to comment
Share on other sites

this is how it works, during unit creation

if( MovementType == _UnitMovement_Tracked ) {

word ax = seedRandomGet();

if( ax < LemonFactor)

      _state |= _objectState_400;   // turn on state400

}

later in one of the unitmovement functions,

once the unit is within 16 pixels of the destination tile,

it checks for '_UnitOpts2_ExplodeAtDestination' flag, if the flag is NOT on,

if( dataGet()->optsFitW & _UnitOpts2_ChangeOrders ) {

       

 < other unrelated junk cut >

       if( _state & _objectState_400 ) {

       if( !(seedRandomGet() & 3))

       objectDamageTake( 1, 0 );

}

(thats 1 point of dmg, only if the seed value doesnt contain the bits for '3')

also just noticed (not sure if we've discussed this before?) but the weakness value in the housedata, when the unit is trooper/infantry is the chance of a unit retreating (when sustaining damage).

this value is also compared against  when a unit is 'deviated'

Link to comment
Share on other sites

Thanks a lot, segra :) So it has to do with the units retreating from danger, eh? I found this particular behavior very annoying when I found out how to activate the attack teams (e.g. when a group of Siege Tanks or even Devastators comes close to your defenses, then the AI decides not to attack, all the while those units get beaten by Missile Turrets' fire).

also just noticed (not sure if we've discussed this before?) but the weakness value in the housedata, when the unit is trooper/infantry is the chance of a unit retreating (when sustaining damage).

this value is also compared against  when a unit is 'deviated'

Hm, I know single soldiers and Troopers that emerge when a squad is beaten below 50% hp retreat from their position, and so do soldiers that come out of destroyed buildings. But I did not know it's connected to the weakness value, which defines the susceptibility to deviation. Perhaps it is responsible for more global unit behavior, then?

Actually this observation was related to techtree limitations and nothing more. The computer is just as stupid when playing harkonnen, ordos or atreides.

Well, I had that impression that the AI behaves differently in each campaign. Maybe it really has something to do with each House's AI settings, and maybe it's just me :)

BTW, I think the AI could be made more dangerous if the "threat value" for turrets was increased (currently it's ridiculously low). For example, in Starcraft, the AI always goes for defenses first, and then proceeds to finish off the rest of the base.

Here's a threat rating comparison table for reference:[pre]Structure      Cost    HP      Threat value

Const Yard      400    400    300

Concrete        5      20      5

Concrete4      20      20      10

Windtrap        300    200    300

Refinery        400    450    300

Outpost        400    500    275

Spice Silos    150    150    150

Light Factory  400    350    200

Heavy Factory  600    200    600

Barracks        300    300    100

WOR            400    400    175

Wall            50      50      30

Turret          125    200    150

R-Turret        250    200    75

Repair Facility 700    200    600

Hi-Tech Factory 500    400    200

Starport        500    500    250

IX              500    400    100

Palace          999    1000    400[/pre]

Link to comment
Share on other sites

I think the developers might have done that on purpose, making the AI's units concentrate on critical structures of the players base. The thing is, the turrets can be really devastating to an enemy army if ignored, and the Heavy Factory and Repair Facility aren't really the most critical structures at all.

I'd suggest the following order of priority: R-Turrets -> Turrets -> Refineries -> (Const. Yard ->) Heavy Factory, Starport -> Light Factory -> everything else

Perhaps with some modifications, but that would surely be more effective, because on later levels, the AI amasses teams of units large enough to take out at least some of the turrets the player may position around the base. Besides, turrets are more vulnerable in the sense that most of them are in the base's perimeter, while the Heavy Factory and other structures of default priority are behind the defensive lines, and therefore more difficult to get to. Same with Refineries, which tend to be positioned close to the rock edge, i.e. outside the base defenses. Another thing worth trying is making a higher priority for Harvesters.

If changing priority levels works, this would mean that the AI in Dune II is customizable to a great degree, as orders of attack could be planned in detail (e.g. after destroying the turrets, the AI may attempt to destroy the Outpost to prevent the player from immediately rebuilding the defenses, and so on).

Link to comment
Share on other sites

The AI doesn't work that way. They do raids against weak but expensive/important buildings while ignoring the defenses. I've often had enemy raids that succeeded in destroying my heavy factory or repair facility. It's a really effective tactic for sabotaging a player.

Link to comment
Share on other sites

The AI doesn't work that way. They do raids against weak but expensive/important buildings while ignoring the defenses.

Isn't that because those "weak but expensive" structures have the highest priority rating (600 for both Repair Facility and Heavy Factory)? If the threat value of other structures is changed, the AI will target the structures we want it to.

I've often had enemy raids that succeeded in destroying my heavy factory or repair facility. It's a really effective tactic for sabotaging a player.

Well, it's actually a pretty lame tactic. First, if the AI ignores the defenses, chances are high that none of the units will reach the target structure intact. The turrets will continue to fire upon the enemy units that are already attacking their target too. Secondly, the Heavy Factory and the Repair Facility are, although important, not the critical structures after all. A Heavy Factory can be replaced fairly easily if spice production and the construction facility are intact. Also, the AI's Launchers have a greater chance of getting within range of the player's turrets if they go for the Heavy Factory or Repair Facility first.

My point is that such a strategy results in little more than the player having to occasionally rebuild his Heavy Factory or Repair Facility. If the AI attacked the turrets first, the chance of success (i.e. destroying a turret) would be greater because the turrets are usually positioned around the base and not inside, so it's easier to approach them. Besides, Launchers and Sonic Tanks can out-range turrets, thus actually making full advantage of their long-range attack. After the turrets, the reasonable targets would be either Refineries or Construction Yards, which are far more important than any factory, even though they're also more difficult to knock out. That should cause a lot more trouble to the player.

Link to comment
Share on other sites

I'm not denying that, but 1) it's still not a huge problem if your spice production is well established (with a considerable cache of credits it's only a matter of time; plus, if you have a Starport, the Heavy Factory is used mostly to produce House special tanks, which require no upgrades) and 2) ignoring the turrets is generally a very bad idea for all the reasons I listed above. If the AI concentrates on destroying the turrets, its chances of success will increase to some extent. And even if it doesn't go further than destroying a couple of turrets, it still remains a factor in harassing the player.

BTW, I think I know why the turrets have such a low threat rating. They do not count in the win/lose conditions, meaning that if you have no structures left but turrets, you still lose. So the developers probably thought the AI shouldn't bother messing with turrets and destroy all the critical structures as quickly as possible to defeat the player. The problem is that the turrets usually make sure the AI's units never get the chance to inflict any considerable damage to the player's base.

Link to comment
Share on other sites

I hope your changes won't mean the AI will systematically kill all my R-turrets with 'thopters though... they're the only good defense against those things.

Good point. In my campaign I avoid giving too many AI opponents Hi-Tech factories, or they swarm you. If they also attack your rocket turrets, it will be impossible to destroy them with a cluster of turrets. You'll have to really space them out, because the turret will shoot at the approaching 'thopter, miss, then SLOWLY turn while the 'thopter flies over it, never getting a chance to shoot again. Ouch.

Link to comment
Share on other sites

I hope your changes won't mean the AI will systematically kill all my R-turrets with 'thopters though... they're the only good defense against those things.

Actually they will.... both your ornithopters and the opponent's go for the turrets.

Link to comment
Share on other sites

The 'thopters attack turrets, but alone they are not enough to destroy them (unless you forget to repair the turrets in time, that is). besides, I think a turret has a bit better chance of hitting a 'thopter when it's flying straight into it to deliver its missile. I haven't had any specific trouble with 'thopters during tests yet (at least, nothing was more complicated compared to the original Dune II).

However, AI's ground assaults have become way more effective (and troublesome for the player ;))

Link to comment
Share on other sites

I'm not sure, but the way the AI picks its targets seems to depend in part on their position on the map, like in Command & Conquer does.

It depends on -which- units you're talking about, units loaded from scen.ini are set with 0x200 at the start which prevents the 'team' scripts from using them, any units which are delivered during the game are set like this as well (starport delivery, carryalls, harvesters)

but for any units constructed,

the use of the team scripts is controlled from the scenario files

[TEAMS]

1=Ordos,Kamikaze,Foot,4,6

5=Harkonnen,Normal,Foot,3,5

numbers on the end represent minimum (target minimum anyway) and max number of units to use in this 'team', and the Kamikaze/Normal represent the script to use inside team.emc

from the team script disassembly,

Execute             sub_2503A

... cut compared number of units in team to 0 ...

Execute             FindUnitForTeam

Execute             scriptObjectTargetGet

PushOp              0

Negate              0

IfNotGoto           l30

Execute             sub_2533D  

l30:

Execute             Actionstart    

these are fairly accurate descriptions of what these functions do:

sub_2503A: Search through all units in this 'team' and find a rendezvous point (averages out the units x/y points) for the team.

FindUnitForTeam: Search and find units which have no team script, and no state 0x200, are not saboteurs and the movement type matches the movement type defined in the scen.ini. add them to the team

scriptObjectTargetGet: Get the 'team' target, if it doesnt have one, call sub_2533D

sub_2533D: Loop through all units which are in this 'team' and find a target,

there is some harcoding here, where 'team kamikaze' attempts to target a structure first, whereas the others target units first. this 'team' target is updated after each pass until a target is found which matches the previous target, or all units are looped

(essentially this finds the best target for the team)

Actionstart: if dont have a 'team' target do guard. if there is a target compare the distance to the units weapon distance, and either start the unit script (units.emc) again with the move action or the attack action

Link to comment
Share on other sites

hm... I've seen similar stuff in RA1's rules. All commands have a setting "Recruitable", meaning that the command given to a unit determines if it can be put inside a team. For example, units set on the map as Guard could be recruited, but units on Area Guard couldn't.

Link to comment
Share on other sites

Whew, after some screw-ups I managed to successfully move this branch of discussion to the DUNE2.EXE Editing Thread. I hope you people don't mind this - I did it so that people interested in Dune II modding can follow the discussion regarding different aspects of it more easily. Now back on topic ;)

Wow segra, thanks for such a detailed explanation of the AI team behavior :)

there is some harcoding here, where 'team kamikaze' attempts to target a structure first, whereas the others target units first. this 'team' target is updated after each pass until a target is found which matches the previous target, or all units are looped

(essentially this finds the best target for the team)

That's a very valuable addition to the Dune II knowledge base. I thought Normal and Kamikaze teams are different in that the former can retreat, while the latter can't. BTW, do you know that there are two other team types that are never used in the game scenarios: Staging and Flee. I've tried testing them a while ago, with some mixed results (check it out here). Would be nice to know how those function, too :)

hm... I've seen similar stuff in RA1's rules. All commands have a setting "Recruitable", meaning that the command given to a unit determines if it can be put inside a team. For example, units set on the map as Guard could be recruited, but units on Area Guard couldn't.

Maybe there's such a feature in Dune II too? This can be checked with your editor :)

Link to comment
Share on other sites

And as Segra said, it seems to depend on how they arrive on the battlefield.

Most pre-placed AI-controlled units on the map have either the Area Guard or Ambush command, and none are set on Guard so I thought it could have been like in Red Alert.

Link to comment
Share on other sites

Ad the Turrets priority:

Well when there are ornithopters in the game you also put some R-Turrents around the base including the opposite direction than the AI units arrive. Therefore if your front turrets are killed and at the moment you got only some in back the units will hunt them down prior and get killed (and the defensive launchers in the back will do more damage to the base cause of thier aimless on close targets :P )

Link to comment
Share on other sites

Most pre-placed AI-controlled units on the map have either the Area Guard or Ambush command, and none are set on Guard so I thought it could have been like in Red Alert.

Segra literally said that all units loaded from the scenario were given a status value that prevents adding them to teams. If it was related to the commands he would've said so.

units loaded from scen.ini are set with 0x200 at the start which prevents the 'team' scripts from using them

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...