vegastrike / Assets-Masters

Vega Strike Upon The Coldest Sea Original Game Data Art Sources (e.g. hi-poly/hi-res source models/images)
8 stars 6 forks source link

Python error when attempting Jenek's second mission with a ship that doesn't have enough cargo space #32

Closed stephengtuggy closed 2 years ago

stephengtuggy commented 2 years ago

I'm not sure if the error with Jenek's second mission is new or not. But that's something we should probably find out before merging this.

So evidently, the error with Jenek's second mission occurs when the ship you are using is too small to hold the cargo for the mission. And it's not a new error.

Using the starting Llama, I was able to complete Jenek's missions no problem, using the code from this branch/PR.

Originally posted by @stephengtuggy in https://github.com/vegastrike/Vega-Strike-Engine-Source/issues/509#issuecomment-895486084

stephengtuggy commented 2 years ago

When I first attempted Jenek's second mission the other day (hauling cargo to Serenity), I tried it with a ship that was too small to hold the requisite amount of cargo. I believe the ship I used was a Dostoevsky.

The result was that the Python code errored out with the following error:

TypeError: 'type' object is not subscriptable

The error seems to occur on this line , which reads:

                rang=list[list(range(you.numCargo()))]
stephengtuggy commented 2 years ago

After the above error occurs, planet/base interfaces will no longer be clickable. So wherever you dock next (or if you're already docked), you won't be able to do anything. You'll have to kill the Vega Strike process to exit.

P-D-E commented 2 years ago

A little investigation on this; missions can have conditions to be met for them to be available (e.g. we only meet Jenek in Atlantis) and campaign_lib.py offers a condition class that checks for cargo space:

class CargoSpaceCondition(Condition):
    def __init__(self,type,num=1):
        Condition.__init__(self)
        self.type=type
        self.num=num

    def __call__(self):
        you=VS.getPlayer()
        mpart=VS.GetMasterPartList()
        carg=mpart.GetCargo(self.type)
        carg.SetContent(self.type)
        carg.SetQuantity(self.num)
        numcarg=you.addCargo(carg)
        you.removeCargo(self.type,numcarg,True)
        if numcarg<self.num:
            debug.debug('*** CargoSpace return false::IGNORED')
            #return False
        debug.debug('*** CargoSpace return true')
        return True

As you can see, though, it has been set to never return False, just log it when it happens; I've checked the oldest version I could find, 0.5.1 on SF, and it was already like that, so no idea about why returning False was disabled and what impact it might have to enable it back.

If enabling it had no cons, this condition could be used to prevent Jenek from appearing in the bar if the player lacks the needed cargo space.

Further thought, Jenek actually assigns 2 missions with different requirements, 2 and 50 units, and it'd be ideal to be able to check them separately, each at its occurrence along the campaign path; this way he would still appear and the player could talk to him and be informed that he needs cargo space; no idea atm if that's supported.

P-D-E commented 2 years ago

After changing the offending line like this

rang=list(range(you.numCargo()))

the error is gone. Some of the stuff I had bought to leave no space in my ship has been sold automatically to make room for the mission cargo, this might turn into a bad bargain for a careless player :)

The auto-sale feature is probably why the cargo room check has been disabled.

stephengtuggy commented 2 years ago

@P-D-E Hmm. Interesting.

Thanks for doing that research. I'm not sure yet exactly what we might want to do about this.

P-D-E commented 2 years ago

You're welcome, I'd say take out the bug ASAP, preserving the current game logic; changes can be discussed with less pressure with bugs ironed out.

BenjamenMeyer commented 2 years ago

@P-D-E so preserve the current behavior for 0.8.x and fix it in 0.9.x or later?

P-D-E commented 2 years ago

@BenjamenMeyer I mean, fixing the bug in AddCargo will preserve the current (or better, the original) behavior and can be done immediately, like the intro scroll bug; also, it's perfectly in theme with 0.8.x as it seems to be another sneaky consequence of the py2->py3 change.

IMHO, brainstorming about CargoSpaceCondition can come at any time while players happily play a working game.

P-D-E commented 2 years ago

@stephengtuggy @BenjamenMeyer Draft PR above, needs pre-emptive test on all platforms.