# This file contains all of the scripted events of the game's story. # And some logic to go with it. import bge import aud from Scripts import Reuse from Scripts import Character_Controll from Scripts import Vehicle from Scripts import Map from Scripts import Main_update from Scripts import Garage from Scripts import Money from Scripts.Common import * Story = {"currentEvent":"01_Bring_Neonspeedster_To_Racetrack","passed":[]} Speakers = {} def Run(scene, dani): # This function runs the script if Story["currentEvent"] in Story: Story[Story["currentEvent"]](scene, dani) # This needed incase some character started speaking RemoveSpeakerAnimation() def RingPhone(): # This function rings the phone. bge.logic.globalDict["print"] = "Press P to answer the phone.\nPress H to hang up." device = bge.logic.globalDict["SoundDevice"] s = "//sfx/music/ringtone.ogg" if s not in bge.logic.globalDict["sounds"]: bge.logic.globalDict["sounds"][s] = {"sound":aud.Sound(bge.logic.expandPath(s)), "play":None} sound = bge.logic.globalDict["sounds"][s] sound["play"] = device.play(sound["sound"]) sound["play"].volume = 0.5 return sound["play"] def AnsweredPhone(): # This function answers phone if player presses P sound = Story["ringing"] # Answer Phone if keycodes["P"] in bge.logic.globalDict["keys"]: sound.stop() return True # Hang Up elif keycodes["H"] in bge.logic.globalDict["keys"]: sound.stop() return False # Do nothing else: return False def PlayDialogue(number, character=None): # This function plays dialogue from the specific scene. device = bge.logic.globalDict["SoundDevice"] s = "//sfx/voices/scenes/"+Story["currentEvent"]+"/"+number+".ogg" if s not in bge.logic.globalDict["sounds"]: bge.logic.globalDict["sounds"][s] = {"sound":aud.Sound(bge.logic.expandPath(s)), "play":None} sound = bge.logic.globalDict["sounds"][s] sound["play"] = device.play(sound["sound"]) sound["play"].volume = 2 if character: sound["play"].location = character.worldPosition sound["play"].velocity = character.getLinearVelocity() sound["play"].relative = False sound["play"].distance_maximum = 200 sound["play"].distance_reference = 1 sound["play"].attenuation = 0 sound["play"].volume = 2 # Setting speaking animation character["speaking"] = True # Removing the speaking animation # when the sound file is finished Speakers[character.name] = {"sound":sound, "character":character} return sound["play"] def RemoveSpeakerAnimation(): # This function removes speaker animations # for when characters speak. for charactername in Speakers: speaker = Speakers[charactername] character = speaker["character"] sound = speaker["sound"] if not sound["play"].status: character["speaking"] = False def emote(dani, data, sound): # This function will set off face animations # based on the data and sound timing. for emotion in data: start, end = emotion[0] emotion = emotion[1] if start < sound.position < end: Character_Controll.ApplyAnimation(dani, emotion) def StatusText(text, bold=[]): # This function prints a status text that is visible all # the time. scene = bge.logic.getCurrentScene() st = scene.objects["Game_Status_Text"] if "status-text" not in bge.logic.globalDict: bge.logic.globalDict["status-text"] = "" if text != bge.logic.globalDict["status-text"]: # Updating text # I'm doing this and not `st["Text"] = text` because # I want it it update the blender object data now. # Since next part will be to boldify the text. st.blenderObject.data.body = text # Storing the text value, so it will not update on every frame. bge.logic.globalDict["status-text"] = text bge.logic.globalDict["status-bold"] = "" if "status-bold" not in bge.logic.globalDict: bge.logic.globalDict["status-bold"] = "" if bold != bge.logic.globalDict["status-bold"]: bge.logic.globalDict["status-bold"] = bold # Boldifying the text for n, i in enumerate(st.blenderObject.data.body_format): if n in bold: i.use_bold = True i.material_index = 0 else: i.use_bold = False i.material_index = 1 def StatusUpdate(stages, stage): t = "" bold = [] for n, s in enumerate(stages): if n == stage: bold = range(len(t), len(t)+len(s)+5+3) t = t + "-> " if stage > n: t = t + s + " <+>\n" else: t = t + s + " < >\n" try:StatusText(t, bold) except Exception as e: print("error", e) ############################################################################## # Mission : Deliver Neonspeedster to Racetrack. # Challenge: Not to break the car. def scene(scene, dani): # First we will make the phone called to Dani. # He needs to pick it up to start the mission itself. # The phone call should only ring when Dani is close to the house # since we don't want the player to be near the Racetrack and # see that Paps isn't there yet. We will spawn him there later. stages = [ "Find Neonspeedster", "Deliver it to Paps" ] house = scene.objects["TheHouse"] pointer = scene.objects["PointingArrow"] targetLocation = [-62.82, 967.5, 4.738] # Showing on the map if not dani.get("race"): Map.Show(house, icon="Map_Circle", color=[1,0.8,0]) if dani.getDistanceTo(house) < 600 and not dani.get("race"): # If at least 20 seconds have been passed from the start of the game. if bge.logic.getRealTime() > Story.get("lastring", 20): Story["ringing"] = RingPhone() Story["lastring"] = bge.logic.getRealTime() + 400 # If the phone is still ringing we can answer it if "ringing" in Story and Story["ringing"].status and AnsweredPhone(): del Story["ringing"] Story["dialogue01"] = PlayDialogue("brief") dani["race"] = Story["currentEvent"] # Animation of dani holding the phone if "dialogue01" in Story: Character_Controll.ApplyAnimation(dani, "AnswerPhone") # Emoting to the phone conversation emotion_data = [ [[ 3.1 , 3.6 ], "Talk" ], [[ 8.6 , 8.9 ], "Laugh"], [[ 18.1 , 19.0 ], "Talk" ] ] emote(dani, emotion_data, Story["dialogue01"]) # When we finished listening to it activate the event if "dialogue01" in Story and not Story["dialogue01"].status: del Story["dialogue01"] bge.logic.globalDict["print"] = "Find the Neonspeedster.\nIt should be in the garage." Story["stage0"] = True StatusUpdate(stages, 0) # Animation of putting away the phone Character_Controll.ApplyAnimation(dani, "PutPhoneAway") # We we will a neonspeedste at a specific point in the garage for this to work # relying on the spawn system is stupid, since it might decide that we will not # get a NeonSpeedster NeonSpeedsterPosition = [-754.61, -1043.9, 409.32] NeonSpeedsterOrientation = [0, 0, -1.79] TruckPosition = [-44.62, 960.8, 4.738] if "stage1" not in Story and not "NeonSpeedster" in Story and dani.getDistanceTo(NeonSpeedsterPosition) < 50: f = False for c in Garage.Inside(): if c.name == "NeonSpeedsterBox": Story["NeonSpeedster"] = c f = True if not f: # We need properly declare the car, otherwise it will break things Story["NeonSpeedster"] = Vehicle.Spawn("NeonSpeedsterBox", NeonSpeedsterPosition, NeonSpeedsterOrientation) # Showing all neonspeedsters on the map if "stage0" in Story and str(dani.get("drving")) != "NeonSpeedsterBox": for car in bge.logic.globalDict["allcars"]: if car.name == "NeonSpeedsterBox": Map.Show(car, color=Vehicle.GetColor(car)) # As soon as dani found the Neonspeedster, we activate the second stage if "stage0" in Story and dani["driving"] and dani["driving"].name == "NeonSpeedsterBox": del Story["stage0"] try: del Story["NeonSpeedster"] except: pass bge.logic.globalDict["print"] = "Drive the Neonspeedster to the Racetrack.\nNot a single scratch!" pointer.visible = True # Making a cylinder where the mission ends Story["stage1"] = Reuse.Create("Starter.Cylinder") Story["stage1"].position = targetLocation Story["stage1"].scaling = [8,8,1] StatusUpdate(stages, 1) # Spawning Paps To make sure he is there to recieve # the car Reuse.Delete(scene.objects["PapsBox"]) Story["Paps"] = Reuse.Create("PapsBox") Story["Paps"].position = [-54.875, 972.66, 4.7383] # He spawns in an area where the physics arent enabled for # the ground yet. Story["Paps"].suspendDynamics(True) Story["Paps"]["deactivated"] = True # Same thing but for Moria Story["Moria"] = Reuse.Create("MoriaBox") Story["Moria"].position = [-56.875, 972.66, 4.7383] Story["Moria"].suspendDynamics(True) # And Jack Story["Jack"] = Reuse.Create("JackBox") Story["Jack"].position = [-52.875, 972.66, 4.7383] Story["Jack"].suspendDynamics(True) # Fixing Pap's dynamics and making paps go at Dani if "Paps" in Story and Story["Paps"].getDistanceTo(dani) < 500: if Story["Paps"]["deactivated"]: Story["Paps"].restoreDynamics() Story["Moria"].restoreDynamics() Story["Jack"].restoreDynamics() Story["Paps"]["deactivated"] = False # Draw a pointer to the racetrack if "stage1" in Story: # Showing the racetrack on the map Map.Show(targetLocation, icon="Map_Circle", color=[1,0.8,0]) # Point the pointer to the racetrack tocheck = pointer.getVectTo(targetLocation) pointer.alignAxisToVect(tocheck[1], 1, 0.1) pointer.alignAxisToVect( (0,0,1), 2, 1.0 ) # Spawning the truck that paps was talking about near paps if "Truck" not in Story and dani.getDistanceTo(TruckPosition) < 200: Story["Truck"] = Vehicle.Spawn("TruckBox", TruckPosition, [0,0,0]) # Deciding on the mission if dani["driving"] and dani["driving"].name == "NeonSpeedsterBox" and dani["driving"].getDistanceTo(targetLocation) < 8: StatusUpdate(stages, 2) #Character_Controll.ApplyAnimation(Story["Paps"], "Stand") Reuse.Delete(Story["stage1"]) del Story["stage1"] if dani["driving"]["health"] >= 0.99: bge.logic.globalDict["print"] = "Excellent Job!" Story["dialogue02"] = PlayDialogue("win", Story["Paps"]) Story["verdict"] = "won" Story["Neonspeedster"] = dani["driving"] else: bge.logic.globalDict["print"] = "You Failed! There was a scratch!" Story["dialogue02"] = PlayDialogue("lose", Story["Paps"]) Story["verdict"] = "lost" # While the paps is telling you that you won if "dialogue02" in Story: emotion_data = [ [[ 1.15 , 8 ], "Talk" ] ] emote(Story["Paps"], emotion_data, Story["dialogue02"]) if 50 > Story["Paps"].getDistanceTo(dani) > 4: Character_Controll.walkToward(Story["Paps"], dani) if 50 > Story["Moria"].getDistanceTo(dani) > 4: Character_Controll.walkToward(Story["Moria"], dani) if 50 > Story["Jack"].getDistanceTo(dani) > 4: Character_Controll.walkToward(Story["Jack"], dani) # When the dialog ende# d. if not Story["dialogue02"].status: # Going for the next story if Story["verdict"] == "won": Story["passed"].append(Story["currentEvent"]) Story["currentEvent"] = "02_Bring_Truck_To_House" Story["timer"] = 100 #else: # try: del Story["Truck"] # except: pass # Ending the event del Story["dialogue02"] pointer.visible = False dani["race"] = "" StatusText("") Story["01_Bring_Neonspeedster_To_Racetrack"] = scene ############################################################################## def scene(scene, dani): global Story # Stopping this scene from working in the night if "stage" not in Story: timeis = bge.logic.globalDict.get("time", 0) if timeis > 19 or timeis < 8: return house = scene.objects["TheHouse"] pointer = scene.objects["PointingArrow"] fixGaragePosition = [-754.61, -1043.9, 409.32] # Moria goes to the racetrack and does some racing by herself. if "Moria" in Story and Story.get("stage", 0) < 15: # Moria goes to the car if not dani.get("driving") and not Story["Moria"].get("driving"): Character_Controll.getIntoCar(Story["Moria"], Story["Neonspeedster"]) if Story["Moria"].get("driving"): racepos = [-61.7856, 1028, 0] # Moria drive the car to the race if Story["Moria"]["driving"].getDistanceTo(racepos) > 2 and "Moria-Practicing" not in Story: Story["Moria"]["driving"]["npc"] = "story" Story["Moria"]["driving"]["target"] = racepos Vehicle.TargetedNPC(Story["Moria"]["driving"]) # Moria racing the race elif "Moria-Practicing" not in Story: Story["Moria"]["driving"]["race"] = "RacetrackRace" Story["Moria"]["driving"]["npc"] = "racer" Story["Moria"]["driving"]["racing"] = True Story["Moria-Practicing"] = True # Optmization Deleting both Moria and the car she drives # if Dani is far enough away. if dani.getDistanceTo(Story["Moria"]) > 500: if Story["Moria"].get("driving"): Story["Moria"]["driving"]["racing"] = False Reuse.Delete(Story["Moria"]["driving"]) Character_Controll.getOutCar(Story["Moria"]) Reuse.Delete(Story["Moria"]) del Story["Moria"] # Paps if "Paps" in Story: # Optimization if not "dialogue1" in Story and not "dialogue2" in Story: if dani.getDistanceTo(Story["Paps"]) > 500: Reuse.Delete(Story["Paps"]) del Story["Paps"] # Jack if "Jack" in Story: # Optimization if dani.getDistanceTo(Story["Jack"]) > 500 and Story.get("stage", 0) < 5: Reuse.Delete(Story["Jack"]) if Story["Jack"].get("driving"): Character_Controll.getOutCar(Story["Jack"]) del Story["Jack"] dani["race"] = "" try: del Story["stage"] except: pass pointer.visible = False # Truck if "Truck" in Story: # Optimization if dani.getDistanceTo(Story["Truck"]) > 500 and Story.get("stage", 0) < 5: Reuse.Delete(Story["Truck"]) del Story["Truck"] dani["race"] = "" try: del Story["stage"] bge.logic.globalDict["print"] = "Mission Failed! You've abandoned it." except: pass pointer.visible = False racetrack = [-62.82, 967.5, 4.738] # Showing on the map if not dani.get("race"): Map.Show(racetrack, icon="Map_Circle", color=[1,0.8,0]) # If dani is close to the racetrack and everything has been despawned # spawned it back in if dani comes. if dani.getDistanceTo(racetrack) > 450: try: del Story["blown-too-close"] except: pass if dani.getDistanceTo(racetrack) < 450 and "stage" not in Story and not dani.get("race")\ and "blown-too-close" not in Story: # Restoring truck, Paps and Jack if "Truck" not in Story: TruckPosition = [-44.62, 960.8, 4.738] Story["Truck"] = Vehicle.Spawn("TruckBox", TruckPosition, [0,0,0]) if not Story["Truck"].get("cargo"): # There is a car in the truck actually DarkShadowLocation = [-44.62, 960.8, 10] Story["DarkShadow"] = Vehicle.Spawn("DarkShadowBox", DarkShadowLocation, [0,0,0], color="pallete") Vehicle.PackCargo(Story["Truck"], Story["DarkShadow"]) if "Paps" not in Story: Story["Paps"] = Reuse.Create("PapsBox") Story["Paps"].position = [-54.875, 972.66, 4.7383] try: Reuse.Delete(Story["Jack"]) del Story["Jack"] except:pass try: Reuse.Delete(Story["Truck"]) del Story["Truck"] except:pass if "Jack" not in Story: Story["Jack"] = Reuse.Create("JackBox") Story["Jack"].position = [-52.875, 972.66, 4.7383] # Paps coming to Dani if 100 > Story["Paps"].getDistanceTo(dani) > 4: Character_Controll.walkToward(Story["Paps"], dani) # Not restoring Moria. if Story.get("timer", 100): Story["timer"] = Story.get("timer", 100) - 1 else: # Paps is telling Jack to go inside the truck. if dani.getDistanceTo(Story["Paps"]) < 50 and "dialogue1" not in Story: Story["dialogue1"] = PlayDialogue("d1", Story["Paps"]) # Paps emoting if "dialogue1" in Story: emotion_data = [ [[ 0.18 , 0.7 ], "Talk" ], [[ 1.52 , 2.5 ], "Talk" ] ] emote(Story["Paps"], emotion_data, Story["dialogue1"]) # When he finished talking Jack goes to the truck. if "dialogue1" in Story and not Story["dialogue1"].status: if Story["Jack"].get("driving") != Story["Truck"]: Character_Controll.getIntoCar(Story["Jack"], Story["Truck"], passanger=True) else: Story["stage"] = 1 del Story["dialogue1"] # Paps telling you how he wants you to hummiliate jack if Story.get("stage") == 1: # Paps coming to Dani if "Paps" in Story: if 100 > Story["Paps"].getDistanceTo(dani) > 4: Character_Controll.walkToward(Story["Paps"], dani) if "dialogue2" not in Story: Story["dialogue2"] = PlayDialogue("brief", Story["Paps"]) if Story["Truck"].get("blown"): if "dialogue2" in Story: Story["dialogue2"].stop() # Paps emoting if "dialogue2" in Story: emotion_data = [ [[ 0.0 , 0.8 ], "Talk" ], [[ 2.6 , 3.5 ], "Talk" ], [[ 4.7 , 12.7 ], "Talk" ], [[ 14.1 , 15.4 ], "Talk" ], [[ 17.3 , 20.303 ], "Talk" ], [[ 21.37 , 27 ], "Talk" ], [[ 28.5 , 34.6 ], "Talk" ], [[ 36.6 , 37.6 ], "Talk" ], [[ 38.3 , 40.0 ], "Talk" ], ] emote(Story["Paps"], emotion_data, Story["dialogue2"]) if "dialogue2" in Story and not Story["dialogue2"].status: Story["stage"] = 2 del Story["dialogue2"] bge.logic.globalDict["print"] = "Get the truck home!" # Now you are faced with the choice to either get the truck or # continue doing some stupid stuff. if Story.get("stage") == 2: # Mapping the truck on the map Map.Show(Story["Truck"], color=[0,0,1]) # If you sit in the truck the mission begins. if dani.get("driving") == Story["Truck"]: dani["race"] = Story["currentEvent"] Story["stage"] = 3 Story["timer"] = 500 pointer.visible = True if Story.get("stage") == 3: # Mapping the house Map.Show(house, icon="Map_Circle", color=[1,0.8,0]) # Point to the house tocheck = pointer.getVectTo(house) pointer.alignAxisToVect(tocheck[1], 1, 0.1) pointer.alignAxisToVect( (0,0,1), 2, 1.0 ) # If Truck blows up you loose if Story["Truck"].get("blown"): # bge.logic.globalDict["print"] = "Mission failed! You broke the truck." # dani["race"] = "" # del Story["stage"] # try: # Reuse.Delete(Story["Paps"]) # del Story["Paps"] # except:pass pointer.visible = False if "dialogue3" in Story: Story["dialogue3"].stop() if "dialogue4" in Story: Story["dialogue4"].stop() # Jack telling his side of the story. if Story["timer"]: Story["timer"] -= 1 else: if "dialogue3" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue3"] = PlayDialogue("d2") Story["Jack"]["saying"] = Story["dialogue3"] # Jack emoting if "dialogue3" in Story: emotion_data = [ [[ 4.2 , 4.7 ], "Talk" ], [[ 10 , 10.5 ], "Laugh" ], ] emote(dani, emotion_data, Story["dialogue3"]) emotion_data = [ [[ 0.1 , 0.8 ], "Talk" ], [[ 1.2 , 3.7 ], "Talk" ], [[ 6.5 , 7.1 ], "Talk" ], [[ 8.3 , 10.1 ], "Talk" ], [[ 11.3 , 14.8 ], "Talk" ], [[ 15.4 , 17.3 ], "Talk" ], [[ 18.6 , 22.1 ], "Talk" ], [[ 23.5 , 25.1 ], "Talk" ], [[ 26.3 , 30.2 ], "Talk" ], [[ 30.9 , 31.8 ], "Talk" ], [[ 32.5 , 33.7 ], "Talk" ], [[ 34.6 , 38.5 ], "Talk" ], [[ 39.6 , 41.6 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue3"]) # If Jack told his story and we are close enough to the house if "dialogue3" in Story and not Story["dialogue3"].status: # Jack tells changes the mission if Story["Truck"].getDistanceTo(house) < 450: if "dialogue4" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue4"] = PlayDialogue("twist") Story["Jack"]["saying"] = Story["dialogue4"] # Jack emoting if "dialogue4" in Story: emotion_data = [ [[ 3.4 , 3.7 ], "Talk" ], [[ 9.8 , 10.2 ], "Talk" ], ] emote(dani, emotion_data, Story["dialogue4"]) emotion_data = [ [[ 0.1 , 0.5 ], "Talk" ], [[ 1.1 , 1.8 ], "Talk" ], [[ 2.2 , 3.0 ], "Talk" ], [[ 4.3 , 5.0 ], "Talk" ], [[ 5.5 , 7.9 ], "Talk" ], [[ 8.4 , 9.6 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue4"]) if "dialogue4" in Story and not Story["dialogue4"].status: del Story["dialogue3"] del Story["dialogue4"] Story["stage"] = 4 # Unlocking the race in the middle of this Story["start_race"] = True if Story.get("stage") == 4: racepos = [-254.4, -508.1, 189.2] # No need to show the race on the map, since it # will temporarily unlocked and that will make # the standard system show it on the map. # Point to the race tocheck = pointer.getVectTo(racepos) pointer.alignAxisToVect(tocheck[1], 1, 0.1) pointer.alignAxisToVect( (0,0,1), 2, 1.0 ) if Story["Truck"].getDistanceTo(racepos) < 70: bge.logic.globalDict["print"] = "Press D to unload the car." if not Story["DarkShadow"].get("isCargo"): Story["stage"] = 5 Character_Controll.getOutCar(Story["Jack"]) pointer.visible = False # Jack goes into the car that you've brought. if Story.get("stage") == 5: if Story["Jack"].get("driving") != Story["DarkShadow"]: Character_Controll.getIntoCar(Story["Jack"], Story["DarkShadow"], passanger=True) # Detecting when the race ends. if not dani.get("race"): Story["stage"] = 6 # Jack is panicing about the broken car. if Story.get("stage") == 6: if "dialogue5" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue5"] = PlayDialogue("after_race_brief") Story["Jack"]["saying"] = Story["dialogue5"] if "dialogue5" in Story: emotion_data = [ [[ 0.1 , 2.5 ], "Talk" ], [[ 3.5 , 9.2 ], "Talk" ], [[ 9.7 , 10.4 ], "Talk" ], [[ 11.6 , 15.6 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue5"]) if "dialogue5" in Story and not Story["dialogue5"].status: Character_Controll.getOutCar(Story["Jack"]) Story["stage"] = 7 bge.logic.globalDict["print"] = "Pick the car up with the truck." # Jack is coming back to the truck if Story.get("stage") == 7: if Story["Jack"].get("driving") != Story["Truck"]: Character_Controll.getIntoCar(Story["Jack"], Story["Truck"], passanger=True) elif dani.get("driving") == Story["Truck"]: Story["stage"] = 8 # Jack is telling you to pick up the car. if Story.get("stage") == 8: if Story["Truck"].get("is_unloaded"): if "dialogue6" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue6"] = PlayDialogue("pick_up_the_car") Story["Jack"]["saying"] = Story["dialogue6"] bge.logic.globalDict["print"] = "Press D to pick the car back up." if "dialogue6" in Story: emotion_data = [ [[ 0.3 , 1.1 ], "Talk" ],] emote(Story["Jack"], emotion_data, Story["dialogue6"]) elif Story["Truck"].get("cargo") != Story["DarkShadow"]: if "dialogue7" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue7"] = PlayDialogue("no_pick_up_the_car") Story["Jack"]["saying"] = Story["dialogue7"] if "dialogue7" in Story: emotion_data = [ [[ 0.2 , 2.4 ], "Talk" ],] emote(Story["Jack"], emotion_data, Story["dialogue7"]) elif Story["Truck"].get("cargo") == Story["DarkShadow"]: Story["stage"] = 9 pointer.visible = True bge.logic.globalDict["print"] = "Drive the Truck home." # Going with the truck home. if Story.get("stage") == 9: Map.Show(fixGaragePosition, icon="Map_Circle", color=[1,0.8,0]) # Point to the house tocheck = pointer.getVectTo(fixGaragePosition) pointer.alignAxisToVect(tocheck[1], 1, 0.1) pointer.alignAxisToVect( (0,0,1), 2, 1.0 ) # If we are at the place. if Story["Truck"].getDistanceTo(fixGaragePosition) < 60: Story["stage"] = 10 Character_Controll.getOutCar(Story["Jack"]) pointer.visible = False # Fixing the car. if Story.get("stage") == 10: if "Jack-got-to-garage-door" not in Story: garageDoor = [-789.7, -1035, 405.5] if Story["Jack"].getDistanceTo(garageDoor) > 1.5: Character_Controll.walkToward(Story["Jack"], garageDoor) else: Story["Jack-got-to-garage-door"] = True else: # Opening Garage door doors = bge.logic.globalDict["doors"]["House_Garage"] if doors.get("OpenClosed", "Closed") == "Closed": doors["OpenClosed"] = "Open" doors["doOpenClose"] = True fixToolPoint = [-754.1, -1039, 405.8] if Story["Jack"].getDistanceTo(fixToolPoint) > 1: Character_Controll.walkToward(Story["Jack"], fixToolPoint, avoidObstacles=False) elif "dialogue8" in Story and not Story["dialogue8"].status: if Story["DarkShadow"] in Garage.Inside(): Story["stage"] = 11 if "dialogue8" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue8"] = PlayDialogue("get_the_car_out_here", Story["Jack"]) Story["Jack"]["saying"] = Story["dialogue8"] if "dialogue8" in Story: emotion_data = [ [[ 0.5 , 1.8 ], "Talk" ],] emote(Story["Jack"], emotion_data, Story["dialogue8"]) if Story.get("stage") == 11: if "dialogue9" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue9"] = PlayDialogue("take_this_power_wrench", Story["Jack"]) Story["Jack"]["saying"] = Story["dialogue9"] if "dialogue9" in Story: emotion_data = [ [[ 0.0 , 0.5 ], "Talk" ], [[ 1.1 , 6.9 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue9"]) if "dialogue9" in Story and not Story["dialogue9"].status: Story["stage"] = 12 if Story.get("stage") == 12: fixComputerPoint = [-755, -1047, 405.8] if Story["Jack"].getDistanceTo(fixComputerPoint) > 1: Character_Controll.walkToward(Story["Jack"], fixComputerPoint, avoidObstacles=False) else: # Jack is buing parts that the car is missing. wheels = 0 parts = 0 for wheel in Story["DarkShadow"].get("wheels", []): if not wheel.visible: wheels += 1 for part in Story["DarkShadow"].get("doors", []): if not part.visible: parts += 1 Garage.inventory["Parts" ] = max(Garage.inventory.get("Parts" , 0), parts ) Garage.inventory["Wheels"] = max(Garage.inventory.get("Wheels", 0), wheels) Garage.UpdateShelfs() Money.Sound() Story["stage"] = 13 bge.logic.globalDict["print"] = "Fix the car." if Story.get("stage") == 13: if Story["Jack"].getDistanceTo(dani) > 3: Character_Controll.walkToward(Story["Jack"], dani) if "dialogue10" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue10"] = PlayDialogue("seems_we_have_everything", Story["Jack"]) Story["Jack"]["saying"] = Story["dialogue10"] if "dialogue10" in Story: emotion_data = [ [[ 0.4 , 1.9 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue10"]) # Find out what is the health of the exteriour of the car. parts = [] for wheel in Story["DarkShadow"].get("wheels", []): parts.append(wheel.get("health", 1)) for part in Story["DarkShadow"].get("doors", []): parts.append(part.get("health", 1)) health = sum(parts) / len(parts) if health == 1.0: Story["stage"] = 14 if Story.get("stage") == 14: if Story["Jack"].getDistanceTo(dani) > 3: Character_Controll.walkToward(Story["Jack"], dani) if "dialogue11" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue11"] = PlayDialogue("tidy_from_below", Story["Jack"]) Story["Jack"]["saying"] = Story["dialogue11"] if "dialogue11" in Story: emotion_data = [ [[ 0.1 , 3.8 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue11"]) if Story["DarkShadow"].getDistanceTo(fixGaragePosition) < 2: Story["stage"] = 15 if Story.get("stage") == 15: # Spawning neonspeedster if "NeonSpeedster" not in Story: Story["NeonSpeedster"] = Vehicle.Spawn("NeonSpeedsterBox", (-798.3, -1006, 405.5), (0,0,0)) if "Moria" not in Story: Story["Moria"] = Reuse.Create("MoriaBox") Character_Controll.getIntoCar(Story["Moria"], Story["NeonSpeedster"], immediately=True) if "Paps" not in Story: Story["Paps"] = Reuse.Create("PapsBox") Character_Controll.getIntoCar(Story["Paps"], Story["NeonSpeedster"], passanger=True, immediately=True) # Opening Garage door doors = bge.logic.globalDict["doors"]["House_Garage"] if doors.get("OpenClosed", "Closed") == "Closed": doors["OpenClosed"] = "Open" doors["doOpenClose"] = True if Story["NeonSpeedster"].getDistanceTo(fixGaragePosition) > 20: Story["NeonSpeedster"]["npc"] = "story" Story["NeonSpeedster"]["target"] = fixGaragePosition Vehicle.TargetedNPC(Story["NeonSpeedster"]) else: Character_Controll.getOutCar(Story["Paps"]) Character_Controll.getOutCar(Story["Moria"]) Story["stage"] = 16 if Story.get("stage") == 16: Vehicle.IdleBraking(Story["NeonSpeedster"]) if "dialogue12" not in Story and ( not Story["Jack"].get("saying") or not Story["Jack"]["saying"].status ): Story["dialogue12"] = PlayDialogue("final_jack", Story["Jack"]) Story["Jack"]["saying"] = Story["dialogue12"] if "dialogue13" not in Story: Story["dialogue13"] = PlayDialogue("final_paps", Story["Paps"]) if "dialogue14" not in Story: Story["dialogue14"] = PlayDialogue("final_dani") if "dialogue12" in Story: emotion_data = [ [[ 2.6 , 3.5 ], "Talk" ], [[ 4.3 , 7.8 ], "Talk" ], [[ 9.8 , 10.3 ], "Talk" ], [[ 11.6 , 12.3 ], "Talk" ], [[ 15.1 , 16.0 ], "Talk" ], [[ 16.3 , 17.3 ], "Talk" ], [[ 18.9 , 20.2 ], "Talk" ], [[ 21.3 , 22.2 ], "Talk" ], [[ 29.8 , 31.2 ], "Talk" ], [[ 32.0 , 33.3 ], "Talk" ], ] emote(Story["Jack"], emotion_data, Story["dialogue12"]) if "dialogue13" in Story: emotion_data = [ [[ 1.1 , 2.8 ], "Talk" ], [[ 3.5 , 4.3 ], "Talk" ], [[ 7.7 , 9.3 ], "Talk" ], [[ 10.2 , 11.2 ], "Talk" ], [[ 17.0 , 18.3 ], "Talk" ], [[ 20.6 , 21.4 ], "Talk" ], [[ 23.9 , 26.5 ], "Talk" ], [[ 28.7 , 29.7 ], "Talk" ], [[ 34.2 , 34.4 ], "Talk" ], [[ 37.5 , 38.2 ], "Talk" ], [[ 39.3 , 40.0 ], "Talk" ], [[ 44.7 , 55.3 ], "Talk" ], [[ 57.2 , 58.6 ], "Talk" ], ] emote(Story["Paps"], emotion_data, Story["dialogue13"]) if "dialogue14" in Story: emotion_data = [ [[ 14.5 , 14.9 ], "Talk" ], [[ 26.8 , 27.4 ], "Laugh" ], [[ 36.7 , 37.1 ], "Talk" ], [[ 41.0 , 41.8 ], "Talk" ], ] emote(dani, emotion_data, Story["dialogue14"]) # Paps and Jack walking after you. if Story["Jack"].getDistanceTo(dani) > 3: Character_Controll.walkToward(Story["Jack"], dani) if Story["Paps"].getDistanceTo(dani) > 3: Character_Controll.walkToward(Story["Paps"], dani) if "dialogue13" in Story and not Story["dialogue13"].status: Story["stage"] = 17 bge.logic.globalDict["print"] = "Go to your room." pointer.visible = True del Story["NeonSpeedster"] del Story["DarkShadow"] if Story.get("stage") == 17: roomPosition = [-752.78, -937.4, 411.08] # Point to the room tocheck = pointer.getVectTo(roomPosition) pointer.alignAxisToVect(tocheck[1], 1, 0.1) pointer.alignAxisToVect( (0,0,1), 2, 1.0 ) if dani.getDistanceTo(roomPosition) < 7: bge.logic.globalDict["print"] = "Mission Passed!" if "Moria" in Story: Reuse.Delete(Story["Moria"]) del Story["Moria"] if "Paps" in Story: Reuse.Delete(Story["Paps"]) del Story["Paps"] if "Jack" in Story: Reuse.Delete(Story["Jack"]) del Story["Jack"] Story["passed"].append(Story["currentEvent"]) Story = {"passed":Story["passed"]} Story["currentEvent"] = "03_Karting_Lessons" # If Truck blows up you loose if "Truck" in Story and Story["Truck"].get("blown"): bge.logic.globalDict["print"] = "Mission failed! You broke the truck." dani["race"] = "" try: del Story["stage"] except:pass try: Reuse.Delete(Story["Paps"]) del Story["Paps"] except:pass pointer.visible = False if dani.getDistanceTo(racetrack) < 450: Story["blown-too-close"] = True Story["02_Bring_Truck_To_House"] = scene # Mission: Deliver the Truck with Jack to the house. def scene(scene, dani): pass Story["03_Karting_Lessons"] = scene # Mission: Go to the karting lessons.