transhumandesign / kag-base

King Arthur's Gold base folder.
256 stars 118 forks source link

[fixed] Sandbox: Non-Builder classes won't receive Wood and Stone after respawning #2021

Open mugg91 opened 2 months ago

mugg91 commented 2 months ago

Status

Description

[changed] Sandbox mode hard-sets 500 wood, 250 stone to builder only, instead of all classes
[changed] Sandbox mode hard-sets 30 arrows to archer
[fixed] On first join offline & online, player could receive twice as many materials (1000 wood, 500 stone)

Fixes https://github.com/transhumandesign/kag-base/issues/1998

Sandbox mode uses script files CTF_GiveSpawnItems.as and Sandbox_Rules.as. The former:

But the latter overwrites that so:

Also, because of void onPlayerChangedTeam(CRules@ this, CPlayer@ player, u8 oldteam, u8 newteam) in CTF_PickSpawn.as, the player could receive twice the amount of materials on their first join, both in online and offline. This is related to an old issue which was fixed by adding check this.isMatchRunning(). So it was fixed for all game modes except Sandbox because this.isMatchRunning() is already true.

This PR fixes these issues by adding a check this.gamemode_name != "Sandbox" to CTF_PickSpawn.as. After applying this fix, I'm only receiving the regular 500 wood and 250 stone.

Sandbox_Rules.as now sets materials to 500 wood and 250 stone only for builder and now also sets 30 arrows for archer (so they receive it always in this game mode even if someday the "out of pity" rule in CTF_GiveSpawnItems.as were to be removed.

Archer and Knight no longer receive unwanted wood and stone materials.

Because I ran into unnecessary misunderstandings, I changed wording // if user is new and //hard-set the respawn blob to // for newly joined player, hard-set blob to builder and placed it above the lines of code so the programmer can easily see what this code section does.

Tested in offline and online.

Steps to Test or Reproduce

Join Sandbox. Receive 1000 wood and 250 stone After this PR, you receive the normal amount of 500 wood and 250 stone.

Change class to Knight, then die and respawn. Receive 500 wood and 250 stone. Be annoyed that you have to spend time opening your inventory and throwing these unwanted materials away. After this PR, Knight receives nothing. Archer still always receives 30 arrows each respawn.