Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human mission 10 instantly fails #458

Closed
zzam opened this issue Apr 9, 2024 · 2 comments · Fixed by #459
Closed

Human mission 10 instantly fails #458

zzam opened this issue Apr 9, 2024 · 2 comments · Fixed by #459

Comments

@zzam
Copy link
Contributor

zzam commented Apr 9, 2024

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):

  • OS: Gentoo Linux
  • Stratagus Version master 2024/04/07, revision 1896f595e21958f4a307531aca77d694d70c9157
  • Wargus Version master 2024/04/07, revision 970f948
@zzam
Copy link
Contributor Author

zzam commented Apr 9, 2024

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

@zzam
Copy link
Contributor Author

zzam commented Apr 9, 2024

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)
  1. wargus: Adjust trigger to also count unit-peasant
  2. wargus: Adjust mission to use a replaced CreateUnit function that directly replaces the unit-type for player 4.
  3. Stratagus: run triggers only at GameCycle>=2 (or maybe even later).
  4. Stratagus: Change TransformUnit to have immediate effect.

zzam added a commit to zzam/wargus that referenced this issue Apr 9, 2024
With the original TransformUnit the unit-peasant become unit-attack-peasant
only in GameCycle=2.
But the Defeat-Trigger that counts them is already executed in in GameCycle=1.
This trigger then counts 0 units of type 'unit-attack-peasant' and the
mission is lost.

Closes: Wargus#458
zzam added a commit to zzam/wargus that referenced this issue Apr 9, 2024
With the original TransformUnit the unit-peasant become unit-attack-peasant
only in GameCycle=2.
But the Defeat-Trigger that counts them is already executed in in GameCycle=1.
This trigger then counts 0 units of type 'unit-attack-peasant' and the
mission is lost.

This happens since Wargus/stratagus#626 was
merged: b5e5bb0c6a18ccbf ("Merge pull request #626 from zzam/trigger-each-cycle")

Before the code was fragile but it worked due to the ordering of
triggers.

Closes: Wargus#458
zzam added a commit to zzam/wargus that referenced this issue Apr 9, 2024
With the original TransformUnit the unit-peasant become unit-attack-peasant
only in GameCycle=2.
But the Defeat-Trigger that counts them is already executed in in GameCycle=1.
This trigger then counts 0 units of type 'unit-attack-peasant' and the
mission is lost.

This happens since Wargus/stratagus#626 was
merged: b5e5bb0c6a18ccbf ("Merge pull request #626 from zzam/trigger-each-cycle")

Before the code was fragile but it worked due to the ordering of
triggers.

Closes: Wargus#458
Jarod42 pushed a commit that referenced this issue Apr 10, 2024
With the original TransformUnit the unit-peasant become unit-attack-peasant
only in GameCycle=2.
But the Defeat-Trigger that counts them is already executed in in GameCycle=1.
This trigger then counts 0 units of type 'unit-attack-peasant' and the
mission is lost.

This happens since Wargus/stratagus#626 was
merged: b5e5bb0c6a18ccbf ("Merge pull request #626 from zzam/trigger-each-cycle")

Before the code was fragile but it worked due to the ordering of
triggers.

Closes: #458
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant