Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

maxPlayers in JS API doesn't account for scavengers #3123

Closed
wzdev-ci opened this issue Feb 3, 2012 · 6 comments
Closed

maxPlayers in JS API doesn't account for scavengers #3123

wzdev-ci opened this issue Feb 3, 2012 · 6 comments

Comments

@wzdev-ci
Copy link
Contributor

wzdev-ci commented Feb 3, 2012

keyword_maps keyword_maxPlayers keyword_scavenger resolution_fixed type_bug | by aubergine


Example scenario:

  • I start a 2 player skirmish game on sk-startup T0
  • I enable scavengers

maxPlayers = 2 and the JS API will block any attempts to access players outside the range 0 .. (maxPlayers-1).

Scavengers, on a 2 player map, are player 4. (and player 7 on a 4 player map IIRC).

This means that I can't enumerate scavenger droids or structures, I can't objFromId() any objects owned by scavanger player either.

I'm guessing this is why most AIs don't deal very well with scavengers :)

I assume the scavenger player slot is somehow also interlinked with map files - so the map author creates a scavenger base on their map and the map editor automatically choses either player 4 or player 7 depending on whether the map is 2 or 4 player.

As maps can now have up to 10 players, 0..9, I assume there will never be scavs on a 10 player map. But on maps with 9 players or less, would it make sense to always have scav players as player n+1 where n = number of selectable players on the map?

This way the JS API could limit to the range 0 .. maxPlayers (eg. 0..2 on a 2 player map, unless no scavengers in which case 0..1)?


Issue migrated from trac:3123 at 2022-04-16 08:51:18 -0700

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 3, 2012

aubergine commented


Also, I assume that the playerData array will need to take account of scav players as well. And startPositions array!

Sounds like an icky one to solve :( But quite important for AI scripts.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 3, 2012

aubergine commented


Example of this issue affecting enumDroid() function...

SCRIPT_ASSERT(context, player < MAX_PLAYERS && player >= 0, "Target player index out of range: %d", player);
SCRIPT_ASSERT(context, looking < MAX_PLAYERS && looking >= -1, "Looking player index out of range: %d", looking);

https://github.com/Warzone2100/warzone2100/blob/master/src/qtscriptfuncs.cpp line 1034/1035

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 7, 2012

Per Inge Mathisen changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 7, 2012

Per Inge Mathisen changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 7, 2012

Per Inge Mathisen commented


qtscript: Centralize script asserts dealing with the player index. Fixes #3123

  • Changeset: [/changeset/7bb6f3d3d1a0a8ec827927c71feeab4748bb8b47 7bb6f3d3d1a0a8ec827927c71feeab4748bb8b47]
  • URL: [7]bb6f3d3d1a0a8ec827927c71feeab4748bb8b47

@wzdev-ci wzdev-ci closed this as completed Feb 7, 2012
@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Aug 4, 2012

Per Inge Mathisen commented


qtscript: Centralize script asserts dealing with the player index. Fixes #3123

  • Changeset: [/changeset/7bb6f3d3d1a0a8ec827927c71feeab4748bb8b47 7bb6f3d3d1a0a8ec827927c71feeab4748bb8b47]
  • URL: [7]bb6f3d3d1a0a8ec827927c71feeab4748bb8b47

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant