REAL ship deliveries

For collaboration on developing the mod capabilities of VS; request new features, report bugs, or suggest improvements

Moderator: Mod Contributor

ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post by ace123 »

Which room are you talking about?

Is this the "base comptuer" that is written in C++?
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

In weapons_lib.py there is the sentence:

Code: Select all

	Base.Link (room1, 'my_link_id', -0.0175, 0.336667, 0.66, 0.45, 'Upgrade_Ship', room0)
That seems to be the link to the ship purchase dialog.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Good hunting, javier. So, I guess, taking the code as is presently in PU,

Code: Select all

def CanBuyShip(shipname):
	import VS
	creds=VS.getPlayer().getCredits()
	return creds+ShipValue(VS.getPlayer().getName(),True)+CargoValue(VS.getPlayer())>=ShipValue(shipname,False)
We'd have to add here a check to see if the cargo in the player's ship fits in the new ship's cargo space. Not sure how, but one complicating factor is that we need to communicate to the user what the problem is, if the cargo can't be moved.

Then...

Code: Select all

def BuyShip(shipname):
	import VS
	import Base
	name=VS.getPlayer().getName()
	value=CargoValue(VS.getPlayer())+ShipValue(name,True)
	oldcargo=[]
	oldun=VS.getPlayer()
	for i in range(oldun.numCargo()):
		c=oldun.GetCargoIndex(i)
		if c.GetCategory().find("upgrades")!=0:
			oldcargo.append(c)
	#print value
	#print VS.getPlayer().getCredits()
	VS.getPlayer().addCredits(value)
	success=Base.BuyShip(shipname,False,True)
	if (success!=False):
		
		Base.SellShip(name)
		#print VS.getPlayer().getCredits()
		#VS.getPlayer().addCredits(-ShipValue(shipname,False))
		#print VS.getPlayer().getCredits()
		#for carg in oldcargo:
		#	VS.getPlayer().addCargo(carg)
		where=shipname.find(".blank")
		if (where!=-1):
			shipname=shipname[0:where]
		VS.playSound('sales/pitch'+shipname+'accept.wav',(0,0,0),(0,0,0))
		return True
	else:
		where=shipname.find(".blank")
		if (where!=-1):
			shipname=shipname[0:where]
		VS.playSound("sales/pitch"+shipname+"duplicate.wav",(0,0,0),(0,0,0))		
		return False
And here we need code to move the cargo from the old ship to the new.

While we're at it, we could also try to move mission cargos... Well, I'm not sure what the problem is, but there's a problem with taking a mission and then changing ships that the mission is lost.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

This functions are invoked from function ShipPurchase in bases/weapons_lib.py. The way to solve it could be creating a new function CanHoldCargo that compares cargo hold of the objective vessel with actual cargo volume, and inserting a call to it after successful invocation to CanBuyShip, adjusting fixer dialog on failure, something like

Code: Select all

def ShipPurchase(shipname):
.
.
.
    elif CanBuyShip(shipname+".blank"):
          if CanHoldCargo(shipname+."blank"):
             # sucess
             .
             .
          else:
             # failure
But the problem with this is that this function doesn't get invoked from the upgrade ship computer screen, as I mentioned before. And that's what I'm trying to find now. Where the the upgrade ship dialog control is. I'm afraid this have to be C++ code, that I'm not capable to deal with at the moment. This can be a simple question for one of the core developers.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

I guess this is then a feature request that the python purchase function be called from the Ships GUI code; so that all purchases go through a common, interceptable piece of code.

OT:
I'd also like to add another request, namely that all quitting actions be interceptable by Python. This is to be able to change quit actions so they quit to main menu, rather than to the desktop.
/OT
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

chuck_starchaser wrote:I guess this is then a feature request that the python purchase function be called from the Ships GUI code; so that all purchases go through a common, interceptable piece of code.

OT:
I'd also like to add another request, namely that all quitting actions be interceptable by Python. This is to be able to change quit actions so they quit to main menu, rather than to the desktop.
/OT
Yes, I do think so. Indeed, it seems the only way to go in this case, because all the ships in the game but the original ones can only be bought from the computer screen. Theoretically, it could be solved with fixers and a lot of scripting, but it's not worth the effort.

So, I think we have reached a dead end about all of this. The inevitable conclusion is we really need a set of callback python functions embedded in the C++ code, and that this need is only to be greater in the future. This have to be a high priority feature to be implemented, IMHO.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

I kept looking at c++ code and I found the function buyShip in source module basecomputer.cpp. I'm going to open a feature request in the Future Development forum.
But, looking at the source, I have found too the configuration variable persistent_mission_across_ship_switch under general section, who does exactly that. If set, the active missions will be carried at ship changes.
I think this question has been asked before, and don't know if someone has come with this solution nor the option is documented anywhere.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Wow, good find! Gotta try that variable tonight. And I'll have a look at basecomputer.cpp too. Maybe we could make a few functions callable from python.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Indeed, the only thing I could fathom for this variable not be set by default is precisely there should be problems with cargo missions if the ship hold cannot contain the mission cargo.
Dilloh
Elite Hunter
Elite Hunter
Posts: 1149
Joined: Mon Aug 14, 2006 3:56 pm
Location: Black Forest, Germany

Post by Dilloh »

That's already adressed by the cargo_mission.py itself - If the cargo space ain't enough, you automatically fail when launching. But it's still a possible glitch for switching while doing a cargo mission currently doesn't transfer your mission cargo to the new ship.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

This is something it should be fixed sooner or later. Not knowing the amount of cargo in mission description is at least annoying. If I remember correctly, it have something to do with persistence of data between c++ and python layers. I think I will take a look at it sometime this week.
Dilloh
Elite Hunter
Elite Hunter
Posts: 1149
Joined: Mon Aug 14, 2006 3:56 pm
Location: Black Forest, Germany

Post by Dilloh »

I do not know if I actually want to see that fixed. It's like booking a passage on a ship, which is being shown as a luxury liner on the ad image, but then there's this tiny footnote saying "ship example image, may vary slightly" and then you're being transfered to a chinese container freighter moving 300 brutto register tons of hard-cooked eggs which have expired in 1972 and are now being transfered to iceland so they do not stink that much.

Or imagine you have a real hot delivery, say you want to smuggle some cocaine from A to B, and then you're being introduced to a guy who'll do it for you for 500$, and he has this really fast but unsuspicious looking car. You think "yeah, that's exactly what I'm looking for" and hire this guy. The next day he comes around to pick up the cocaine, in a purple-orange monster truck with a text on the back window, "Fuck Da Bloody Donut-Eatin' Mothafuckin' Cops", hits the hump and 90 decibels of synthesized "Catch me if you can" break the windows of that major police station on the other side of the street.

I mean, you do not only hire the pilot, you also hire the ship. You want to make sure your cargo makes it from A to B, and even if it's not a cargo mission you want to make sure that the mission is completed in time.

What I'd rather like to see would be a mission log per-ship. Missions can be aborted at any time, and campaign missions can be retaken, so there's no problem with that. But if you decided to clean Perry from confed presence in your eject pod and your customer is insane enough to accept that, damn, you'll have to do it like that - maybe he just wants to see you roasted :)
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Sorry, maybe I don't explained myself. :oops:
What I'm saying is that you know, reading the mission briefing, what you will be carrying but not how much, so you don't know in advance if you have the storage needed to fulfill it. Only when accepted a decision is made, so you could get one mission and find it aborted before start. This should not happen.
If this is solved, then you could think about how failing a mission affects your reputation or relation with the faction you chose the mission from.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Yeah, the mission should specify space needed, and if it doesn't fit you should get a message "you don't have enough space", rather than silently fail the mission.
Dilloh
Elite Hunter
Elite Hunter
Posts: 1149
Joined: Mon Aug 14, 2006 3:56 pm
Location: Black Forest, Germany

Post by Dilloh »

Well, atm the engine takes your overall cargo hold and calculates the missions in a way that even the three most cargo-intensive cargo missions cannot bust your luggage. There are two problems though:
1) The engine doesn't care for cargo which you already have
2) When switching ships the missions don't get updated to your new cargo hold, you need to save and load for that

So best solution would be, for autogenerated missions, some sort of live-update every time you switch a ship. So buying/switching a ship should reload the whole basescript, as well as leaving the commodity exchange.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Dilloh wrote:Well, atm the engine takes your overall cargo hold and calculates the missions in a way that even the three most cargo-intensive cargo missions cannot bust your luggage. There are two problems though:
1) The engine doesn't care for cargo which you already have
2) When switching ships the missions don't get updated to your new cargo hold, you need to save and load for that

So best solution would be, for autogenerated missions, some sort of live-update every time you switch a ship. So buying/switching a ship should reload the whole basescript, as well as leaving the commodity exchange.
And that drives us again to the need of fixing the excess cargo bug. That way, after accepting the mission you cannot switch to a ship unable to hold the compromised cargo. I'm beginning to feel the importance of that problem is greater than thought.
The first problem shouldn't be too much difficult to nail. But I think generating the amount with the mission itself is a more elegant solution.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

I think the first step would be to remove the buy ship function from c++, and replace it with a python function, if that's possible. Inside python we know the cargo hold space of ships, and can test for transferability.

A nice touch would be that if a cargo expansion would allow you to make the cargo tranfer, you'd be given a chance to pay for the expansion and have it installed together with the switchover.

And while we're at it, we might want to add a Dump button to the upgrades, for like when an upgrade costs more to fix than to buy new.
And also, the having to buy your own ship in order to switch ships is a bit unintuitive.
Xit
Bounty Hunter
Bounty Hunter
Posts: 186
Joined: Mon Aug 06, 2007 2:34 am
Location: Cambs

Post by Xit »

chuck_starchaser wrote: And also, the having to buy your own ship in order to switch ships is a bit unintuitive.
Agreed, any chance you could throw in the a sale value indicator for ships too?
Save The Economy
http://vegastrike.sourceforge.net/forum ... hp?t=10605

My boxes: Dual Opteron 280s, Geforce 7600, 2GB RAM, but waiting for a new PSU! grrr...
500 MHz Compaq laptop that gives DC electric burns
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Sorry, I was busy setting up svn repos last night; haven't had a chance to look at the code, yet; probably tonight.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

I'm testing a patch right now, and if everything works I'll post it this afternoon, intended to be revised by developers, in thread http://vegastrike.sourceforge.net/forum ... hp?t=10814

Could somebody change the above thread from Future Development to Bug Triage? I think it belongs there.
Post Reply