HowTo:Edit Missions:Sample:Sample1

From VsWiki
Jump to: navigation, search

THE DOCKING DISPUTE

import quest
import Vector
import VS
import unit
import vsrandom
import launch
import faction_ships
class quest_peteyg (quest.quest):
        def __init__ (self):
                playa=VS.getPlayer()

                # I think this will get a mining base from the system, and assign it to 'station'
                self.station=unit.getUnitByName('MiningBase')

                # launch the two freighters.  perhaps give the socialist ship a 'sitting duck' AI
                self.merchant=launch.launch_wave_around_unit("VulCorp Transport A-5",'merchant','plowshare',"default",1,100,2,self.station)
                self.socialist=launch.launch_wave_around_unit("Lenin's Mercy",'ISO','llama',"default",1,100,2,self.station)

                self.merchantHull = self.merchant.GetHull()
                self.prevMerchantHull = self.merchantHull
                self.talk=1
                self.talk2=1
                self.starttime=VS.GetGameTime()


        def Execute (self):
                playa=VS.getPlayer()

                # some checking that I noticed in another quest, seeing if the player and station exist I think
                if (playa):
                        if (1==1):

                                # checks to see if the player is within 5k of the station
                                if (self.station.getDistance(playa) < 5000):
                                        if (self.talk==1):
                                                # the comm interchange between the two ships
                                                VS.IOmessage (0,"game","all","[VulCorp Transport A-5] VulCorp Transport alpha five requesting priority docking.")
                                                VS.IOmessage (1,"game","all","[VulCorp Transport A-5] We have a load of spare parts that needs to be delivered within the next half hour, or else we don't get paid.")
                                                VS.IOmessage (4,"game","all","[Lenin's Mercy] Negative, transport Lenin's Mercy requesting emergency docking.  We have thirteen critically injured passengers.")
                                                VS.IOmessage (5,"game","all","[Lenin's Mercy] We picked them up after a squadron of pirates attacked their ship.  They need immediate medical attention!")
                                                VS.IOmessage (8,"game","all","[VulCorp Transport A-5] Station control, might we remind you that we have a contract with your base?  We demand priority in the docking queue so we can complete our transaction.")
                                                VS.IOmessage (10,"game","all","[Lenin's Mercy] You capitalist pigs!  We have dying men and women on board, and all you can think about is your filthy money!")
                                                VS.IOmessage (14,"game","all","[VulCorp Transport A-5] Socialist vessel:  Stay out of the docking queue or you will be fired upon.  We will not let a bunch of bleeding communists turn this major deal sour!")
                                                VS.IOmessage (16,"game","all","[Lenin's Mercy] Negative, VulCorp Transport.  The lives of our passengers are worth more than your profits!")
                                                VS.IOmessage (18,"game","all","[VulCorp Transport A-5] All batteries!  Open fire!!")
                                                self.talk=0

                                        # the two ships start to attack each other
                                        self.merchant.SetTarget(self.socialist)

                                        if (self.talk2==1):
                                                # the privateer gets involved...   or does he?
                                                VS.IOmessage (0,"game","all","[Lenin's Mercy] Mayday!  We are under attack!  Privateer, please help us...  we are no match for them.  We have wounded on board!")
                                                VS.IOmessage (1,"game","all","[VulCorp Transport A-5] Privateer, if you look the other way...  you will be duly compensated.")
                                                self.talk2=0


                                        # if the merchant has taken hull damage, destroy him, give player their socialist rewared
                                        if (self.merchant.GetHull() < self.prevMerchantHull):

                                                # destroy the merchant ship
                                                pos=self.merchant.Position()
                                                size=3*self.merchant.rSize()
                                                VS.playAnimation("explosion_wave.ani",pos,size)
                                                self.merchant.DealDamageToHull ((0,0,0),self.merchant.GetHull()*2)



                                                # dock the socialist (just make him disappear)...   I think Kill is what I want to use
                                                self.socialist.Kill()
                                                self.socialist.setNull() # not really sure what i'm doing...  i want to be able to check the dead/alive status later by seeing if the pointer is null or not, maybe there's a better way to do it.
                                                # player gets transmission telling about the socialist's dumped cargo, like 5,000k away or something
                                                # the player can tractor it in and make some serious cash
                                                VS.IOmessage (0,"game","all","[Lenin's Mercy] Thank you, Privateer!  The Interstellar Socialist Organization is in your debt.  We are getting our wounded to the base's medical facility.")
                                                VS.IOmessage (2,"game","all","[Lenin's Mercy] We have no money...  but we are transmitting you coordinates of the cargo we dumped to make room for the attack victims.  Do with it what you will.")
                                                VS.IOmessage (4,"game","all","[Lenin's Mercy] You have made a friend with the ISO today.  Safe journey.")

                                                # launches the cargo, puts cargo in the new unit...   or something like that
                                                # self.cargo=launch.launch_wave_around_unit("Dumped Cargo",'neutral','generic_cargo',"default",5000,3000,6000,playa)

                                                # rep with ISO goes way up.  Not sure of the number
                                                VS.AdjustRelation(playa.getFactionName(),'ISO',.1,.5)


                                                VS.IOmessage (0,"game","news","PRIVATEER SAVES SHIPLOAD OF WOUNDED:  see subject -1, redundant")
                                                self.removeQuest()
                                                return 0

                                        # if the merchant ship is still alive after 40 seconds
                                        if (VS.GetGameTime() - self.starttime > 50):

                                                # destroy the socialist ship
                                                pos=self.socialist.Position()
                                                size=3*self.socialist.rSize()
                                                VS.playAnimation("explosion_wave.ani",pos,size)
                                                self.socialist.DealDamageToHull ((0,0,0),self.socialist.GetHull()*2)

                                                # if the merchant is still friends with the player, the merchant gives him a nice chunk of cash
                                                if (5 > -.1):
                                                        VS.IOmessage (0,"game","all","[VulCorp Transport A-5] Privateer, thank you for your cooperation.")
                                                        VS.IOmessage (1,"game","all","[VulCorp Transport A-5] We will be able to make a killing on this shipment thanks to you.  Here are 15,000 credits for your trouble.")
                                                        playa.addCredits(15000)

                                                        # rep with merchants goes up
                                                        VS.AdjustRelation(playa.getFactionName(),'merchants',.1,.5)

                                                        VS.IOmessage (0,"game","news","MALICIOUS MERCHANT MASSACRES MARXIST MERCY MISSION:  see subject -1, overrated")
                                                        self.removeQuest()
                                                        return 0

                                                # update the merchant hull status and previous frame's hull status at the end of the while loop
                                        self.prevMerchantHull = self.merchant.GetHull()
                                return 1

class quest_peteyg_factory (quest.quest_factory):
        def __init__ (self):
                quest.quest_factory.__init__ (self,"quest_peteyg")
        def create (self):
                return quest_peteyg()