swlegion / tts

Table Top Simulator Mod for Star Wars: Legion
MIT License
43 stars 27 forks source link

Some corps units cannot add a training upgrade after equipping a trooper captain upgrade #127

Closed NocturnalLoner closed 4 years ago

NocturnalLoner commented 4 years ago

Describe the bug In the army builder within the mod a script error occurs after attempting to equip a training upgrade to a stormtrooper or rebel trooper corps unit who also has a trooper captain upgrade. The error seems to spit out a varying group of numbers in relation to whether it is a stormtrooper or rebel trooper unit and what upgrade was attempted to be put on the unit. The GAR trooper captain works as it should. It is only an issue with the GCW factions.

To Reproduce Steps to reproduce the behavior: Open up the in-game army builder and select either a rebel trooper or a stormtrooper. Add the captain trooper upgrade and attempt to add a training upgrade to the unit. The upgrade will not appear and the system will state an error in script.

Expected behavior Being able to equip the training slot upgrade without issue.

matanlurey commented 4 years ago

Looks like this is the line that fails:

-- 273 in spawnUpgradeCard(cardData, cardPos, upgradeNumber)
local a = cardPos.c * math.cos(math.rad(cardPos.q + rot.y ))
matanlurey commented 4 years ago

I don't see anything specifically different between Phase Is and Rebel Troopers 😢

    cardInfo.unitCards.phaseICloneTroopers = {
        guid = "2443de",
        ptCost = 52,
        availableUpgrades = {
            cardInfo.upgradeMenu.republic.phaseICloneTroopersTrooper,
            cardInfo.upgradeMenu.republic.phaseICloneTroopersSpecialist,
            cardInfo.upgradeMenu.republic.tech,
            cardInfo.upgradeMenu.republic.tech,
            cardInfo.upgradeMenu.republic.tactics,
            cardInfo.upgradeMenu.republic.grenade
        },
        miniInfo = {
            miniInfo.phaseICloneTrooperLeader,
            miniInfo.phaseICloneTrooper1,
            miniInfo.phaseICloneTrooper2,
            miniInfo.phaseICloneTrooper3
        },
        tokenName = "Republic Corps Command Token",
        fullName = "Phase I Clone Troopers",
        rank = "Corps"
    }
    cardInfo.unitCards.rebelTrooper = {
        guid = "2972de",
        ptCost = 40,
        availableUpgrades = {
            cardInfo.upgradeMenu.rebel.rebelTrooperTrooper,
            cardInfo.upgradeMenu.rebel.rebelTrooperSpecialist,
            cardInfo.upgradeMenu.rebel.tech,
            cardInfo.upgradeMenu.rebel.grenade,
            cardInfo.upgradeMenu.rebel.comms,
            cardInfo.upgradeMenu.rebel.tech,
            cardInfo.upgradeMenu.rebel.tactics
        },
        miniInfo = {
            miniInfo.rebelTrooperLeader,
            miniInfo.rebelTrooper1,
            miniInfo.rebelTrooper2,
            miniInfo.rebelTrooper3
        },
        tokenName = "Rebel Corps Command Token",
        fullName = "Rebel Troopers",
        rank = "Corps"
    }
matanlurey commented 4 years ago

LOL! Ok, I figured it out. There is hard-coded support for up to 6 upgrade card slots:

    templateMenu.upgradeCardPos = {}
    templateMenu.upgradeCardPos[1] = {q = 146.451578117502, c = 2.2437691503361}
    templateMenu.upgradeCardPos[2] = {q = -37.790038154384, c = 2.3663051367058}
    templateMenu.upgradeCardPos[3] = {q = -90, c = 1.45}
    templateMenu.upgradeCardPos[4] = {q = -142.209961845616, c = 2.3663051367058}
    templateMenu.upgradeCardPos[5] = {q = -65.897765498839, c = 4.5792248252297}
    templateMenu.upgradeCardPos[6] = {q = -90, c = 4.18}

And these units are the first ones that use the 7th slot