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

Implement #776: Level script - fixed alliances #1969

Merged
merged 2 commits into from Nov 10, 2022

Conversation

IntelOrca
Copy link
Contributor

@IntelOrca IntelOrca commented Nov 10, 2022

Resolves #776

Used the last 3 unused bits in player->allied_players to represent which allies (blue, green, yellow) are locked. This means that this functionality is currently limited to single player.

Changes to ALLY_PLAYERS:

  • Unlocked enemy: ALLY_PLAYERS(PLAYER1,PLAYER2,0)
  • Unlocked ally: ALLY_PLAYERS(PLAYER1,PLAYER2,1)
  • Locked enemy: ALLY_PLAYERS(PLAYER1,PLAYER2,2)
  • Locked ally: ALLY_PLAYERS(PLAYER1,PLAYER2,3)

New command: IF_ALLIED({PLAYER},{PLAYER}{OP}{VALUE}):
Allows you to check the ally status of any two players. This will allow all sorts of use cases, such as forming a reply alliance in single player, or special events in multiplayer if two particular players are allied.

Example script:
Add this to the end of Korros Tor (levels\deepdngn\map00081.txt) or any other 2 player map.

ALLY_PLAYERS(PLAYER0,PLAYER1,1)
IF_ALLIED(PLAYER0,PLAYER1==0)
    QUICK_OBJECTIVE(1,"Blue will not accept this betrayal, prepare for battle.",PLAYER1)

    REM no going back now, lock as enemies
    ALLY_PLAYERS(PLAYER0,PLAYER1,2)
ENDIF
IF_ALLIED(PLAYER0,PLAYER2==1)
    IF_ALLIED(PLAYER0,PLAYER1==1)
        QUICK_OBJECTIVE(2,"Blue will not accept your alliance with Green, prepare for battle.",PLAYER1)
        REM lock blue as enemy
        ALLY_PLAYERS(PLAYER0,PLAYER1,2)
    ENDIF

    REM lock green as ally
    ALLY_PLAYERS(PLAYER0,PLAYER2,3)
ENDIF

Allying with green causes the player to automatically win the level. I am not exactly sure why, since I would have thought the unally with blue would execute first, before the ally with green command. I guess there is something about the way scripts are executed which I don't quite understand.

@IntelOrca IntelOrca force-pushed the feature/locked-allies branch 3 times, most recently from a4e18d5 to 213866d Compare November 10, 2022 00:50
@PieterVdc
Copy link
Member

well multiplayer and campaigns where the player isn't red, I guess we could also look if one of the many unnamed fields might just be unused by the game, and have the locked stuff in there instead

@Loobinex
Copy link
Member

Allying with blue with that script triggered victory because it checked against the ALL_DUNGEONS_DESTROYED var for victory, which ignores allies.

@Loobinex Loobinex merged commit 4961dba into dkfans:master Nov 10, 2022
@eddebaby
Copy link
Contributor

eddebaby commented Oct 21, 2023

For my own sake really...
ALLY_PLAYERS works like this:

  • set PLAYER2 as enemy of PLAYER1 (remove PLAYER2 from PLAYER1's ally list) and unlock PLAYER2 in PLAYER1's ally/enemy list:
    ALLY_PLAYERS(PLAYER1,PLAYER2,0)
  • set PLAYER2 as ally of PLAYER1 (add PLAYER2 to PLAYER1's ally list) and unlock PLAYER2 in PLAYER1's ally/enemy list:
    ALLY_PLAYERS(PLAYER1,PLAYER2,1)
  • set PLAYER2 as enemy of PLAYER1 (remove PLAYER2 from PLAYER1's ally list) and lock PLAYER2 in PLAYER1's ally/enemy list:
    ALLY_PLAYERS(PLAYER1,PLAYER2,2)
  • set PLAYER2 as ally of PLAYER1(add PLAYER2 to PLAYER1's ally list) and lock PLAYER2 in PLAYER1's ally/enemy list:
    ALLY_PLAYERS(PLAYER1,PLAYER2,3)

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 this pull request may close these issues.

Level script - fixed alliances
4 participants