Wargus / wargus

Importer and scripts for Warcraft II: Tides of Darkness, the expansion Beyond the Dark Portal, and Aleonas Tales
GNU General Public License v2.0
360 stars 55 forks source link

Human mission 10 instantly fails #458

Closed zzam closed 5 months ago

zzam commented 5 months ago

Describe the bug DileriumL reported in Discord: When starting the human mission 10 in wargus then the mission is immediately lost.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Single Player Game'
  2. Go to 'Campaign Game'
  3. Go to 'Tides of Darkness / Alliance'
  4. Select mission 10 (X. Die Gefangenen in German)
  5. Click 'Start mission'
  6. Close the Briefing
  7. Immediately the dialog 'You failed to achieve victory' appears.

Expected behavior The game starts and can be played

Screenshots and Logs image

Desktop (please complete the following information):

zzam commented 5 months ago

I verified that stratagus PR 626 (Check each trigger-condition in each cycle) causes the failure.

zzam commented 5 months ago

More details: campaigns/human/level10h_c.sms:

for i,unit in ipairs(GetUnits(4)) do
   if GetUnitVariable(unit, "Ident") == "unit-peasant" then
       TransformUnit(unit, "unit-attack-peasant")
   end
end

In GameCycle=1 the units are still of type unit-peasant. In GameCycle=2 the units are of type unit-attack-peasant.

Before PR 626, in GameCycle=1 the first trigger was checked (IfRescuedNearUnit). In GameCycle=2 the second trigger (the problematic one, GetPlayerData ....) was executed. Switching the order of triggers would also have broken it.

Now all triggers are executed in each cycle and it fails now in GameCycle=1 running the second trigger.

Options to fix it:

  1. wargus: Adjust trigger code of mission to only run when GameCycle>=2:
    AddTrigger(
    function() 
    return GameCycle > 1 and (GetPlayerData(4, "UnitTypesCount", "unit-attack-peasant") + 
    GetPlayerData(GetThisPlayer(), "UnitTypesCount", "unit-attack-peasant")) <= 3 end,
    function() return ActionDefeat() end)
  2. wargus: Adjust trigger to also count unit-peasant
  3. wargus: Adjust mission to use a replaced CreateUnit function that directly replaces the unit-type for player 4.
  4. Stratagus: run triggers only at GameCycle>=2 (or maybe even later).
  5. Stratagus: Change TransformUnit to have immediate effect.