Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scn FastTravelCallBack
- ;Script Version 1.40, - Lime - 22/10/2021.
- ;Master script that handles all encounters for "Immersive Fast Travel Encounters" Mod for FNV.
- ;This script is attached to a fast travel event handler. Once fast travel occurs this script runs.
- ;This script is conditioned so that only relevant functions are called as relevant checks are passed or failed.
- ;Some general purpose rules for the player. Player will NOT be punished for not possessing an item (i.e water, stimpak etc.)
- ;Player WILL be Punished for taking a descision that rolls unfavorably / they do not posses the required skills to pass the check.
- ;Player will NOT be killed during fast travel, checks are in place to ensure encounters do not cause Radiation
- ;Levels to exceed 1000 or health to drop below 1.
- ;As of v1.20 this script contains the vast majority of functionality. This allows me to fire the script at a delay (preventing pip boy ui remaining
- ;On screen with certain mods). Additionally paired down the debug info to essential and information used multiple times. Improved performance by
- ;Only getting certain info if it is only used once instead of grabbing everything on chance check pass. Reconditioned random values to Rand function
- ;For the sake of readability. Removed JIP and NVSE version checks as they would returning zero after first travel and would need to be re-initialized
- ;to be of any use. Also added checks that allow the player to avoid addiction with a high endurance or survival skill.
- ;As of v1.30 various sweeping gramamtical checks and bugfixes across all scripts. Added configuration options and revisions to skeleton "Additional support"
- ;As of v1.40 added the ability to skip encounters with addiction for the sake of character or roleplaying. ( bEnableAddictionEncounters )
- ;As of v1.50 reconditioned some encounters to prevent conflicts with other mods which may cause dehydration to be incorrectly applied.
- ;Additionally removed a rougue print which was added during testing.
- ;Note to self, might change weighting of Vanity & WW encounters.
- ;Calling ref
- ref rCallingRef
- ;General purpose variables / internal tracking
- int EncounterChance
- int NumberOfEncounters
- int EncounterSelection
- int CurrentRadLevel
- int CurrentHPLevel
- int CurrentLuck
- int CurrentSurvivalSkill
- int CurrentEndurance
- int Random
- int RandomSmall
- int watercount
- int PlayerLevel
- int WWEncounters
- int VanityEncounters
- ;Names & random vars for game & person playing.
- String_Var Person
- String_Var Game
- int GameChance
- int PersonChance
- ;Aux variables (Encounters.ini)
- int bChance
- int bDebug
- int bEnableAddictionEncounters
- ;Function attached to eventhandler
- begin Function {}
- set rCallingRef to this
- ;Removes this as a callback until called again.
- SetGameMainLoopCallback FastTravelCallBack 0
- ;Grab user defined chance of something happening from Aux value.
- set bChance to Player.AuxiliaryVariableGetFloat "*bChance"
- ;If the encounter chance passes the percentage check
- if rand 1, 100 <= bChance
- ;Calculate some general purpose information about the player. These values are generally used multiple times in this script.
- ;Those used just once have been conditioned per encounter, try to avoid unessecary calls here for the sake of performance.
- set Random to rand 1, 100 ;Random general purpose variable between 1 & 100.
- set RandomSmall to rand 1, 3
- set CurrentHPLevel to Player.GetAv Health
- set CurrentSurvivalSkill to Player.getav Survival
- set watercount to player.getitemcount WaterPurified
- ;Change this if more encounter states are added (Set higher than number of states to weight vanity and WW encounters)
- set NumberOfEncounters to 40
- ;Generates a number between 1 and the total number of possible outcomes. Used to determine *what* will happen.
- set EncounterSelection to rand 1, NumberofEncounters
- ;Query AuxVars
- set bDebug to Player.AuxiliaryVariableGetFloat "*bDebug"
- set bEnableAddictionEncounters to Player.AuxiliaryVariableGetFloat "*bEnableAddictionEncounters"
- ;Debug info prints to terminal if enabled in .ini
- if bDebug == 1
- print "Encounter State: " + $EncounterSelection + " Selected"
- print $NumberofEncounters + " Encounter states Loaded"
- print "Chance roll: " + $bChance
- print "Random roll 01 (1-100): " + $Random
- print "Random roll 02 (1-3): " + $RandomSmall
- print "Current HP: " + $CurrentHPLevel
- print "Current Survival Skill: " + $CurrentSurvivalSkill
- print "Water count: " + $WaterCount
- endif
- if EncounterSelection == 1
- MessageBoxEx ("Your trip was long and strenuous - you were attacked by a gang of raiders. You barely manage to escape them. [ " + $RandomSmall + " Stimpak(s)]")
- ;I don't quite understand the string formatting here, so I can't verify that it follows the format of [+/-Stimpak] with no spaces between
- player.removeitem Stimpak RandomSmall
- playsound NPCHumanUsingStimpak
- elseif EncounterSelection == 2
- MessageBoxEx ("Warm sands, calm winds, and not a raider in sight - unusual for the wasteland. During a calm moment, you spot some caps in the sand. [+" + $Random + " cap(s)]")
- player.additem Caps001 Random
- elseif EncounterSelection == 3
- MessageBoxEx "During your trip you get lost and incredibly thirsty. [-2 Purified Water]"
- if watercount >= 2
- player.removeitem WaterPurified 2
- playsound NPCHumanDrinkingBottleGulp
- elseif watercount < 2 && playerref.IsHardcore == 1
- ;Damage dehydration if in Hardcore mode.
- MessageBoxEx "You didn't have enough water. [-150 H2O]"
- player.damageav Dehydration 150
- endif
- elseif EncounterSelection == 4
- MessageBoxEx "You find a raided caravan - luckily, it seems they missed a stimpak. [+Stimpak]"
- player.additem Stimpak 1
- elseif EncounterSelection == 5
- MessageBoxEx "You find a raided caravan, but it's been picked dry. You get ill from the flies surrounding the dead Brahmin. [-75 HP]"
- ;I'd just say you threw up and lose food needs
- call FastTravelPainSoundRandomiserUDF
- if CurrentHPLevel > 75
- player.DamageActorValue Health 75
- else
- player.DamageActorValue Health (CurrentHPLevel - 1)
- endif
- elseif EncounterSelection == 6
- MessageBoxEx "The wind turns, and your geiger counter begins ticking frantically. [+150 Rads]"
- ;this is the one of the few instances where a penalty uses a + in it's brackets, due to the way that radiation works
- playsound UIPipBoyRadiationB
- ;Set here as only used in one encounter
- set CurrentRadLevel to Player.GetAv RadiationRads
- if CurrentRadLevel < 850
- player.damageav RadiationRads 150
- elseif CurrentRadLevel == 999 ;this check prevents the player rad level from bouncing between 999 and 998 at the max range of radiation
- ;Don't do anything (Hold rad level at 999)
- else
- player.damageav RadiationRads ((1000 - CurrentRadLevel) -1)
- endif
- elseif EncounterSelection == 7
- ;Randomize some of the encounter
- set PersonChance to 1 + GetRandomPercent * 4/100
- set GameChance to 1 + GetRandomPercent * 4/100
- if PersonChance == 1
- let Person := "wastelander"
- elseif PersonChance == 2
- let Person := "prospector"
- else if Personchance == 3
- let Person := "adventurer"
- else
- let Person := "merchant"
- endif
- ;took off the capitals on these cause they're non-proper nouns in the middle of a sentence
- if GameChance == 1
- let Game := "caravan"
- elseif GameChance == 2
- let Game := "dice Roll"
- else if GameChance == 3
- let Game := "cap Flip"
- else
- let Game:= "cards"
- endif
- MessageBoxExAlt FastTravelWager ("^Wager Offer^You meet a passing " + $Person + ",%rthey offer you a wager on a game of " + $Game + ":|Accept|Decline")
- elseif EncounterSelection == 8
- MessageBoxExAlt FastTravelLootTheBox "^Buried Footlocker^You spot a footlocker, partally sunken into the%rwastes. |Investigate|Move on"
- elseif ( EncounterSelection == 9 && bEnableAddictionEncounters == 1 )
- set CurrentEndurance to Player.GetAv Endurance
- if Player.HasPerk NVDLC03TraitLogansLoophole
- MessageBoxEx "Anything to make the long, hot day pass faster. [Perk] Logans loophole allows you to avoid a nasty Alchol addiction."
- elseif (CurrentSurvivalSkill <= 70 || CurrentEndurance <= 7)
- MessageBoxEx "The harsh wastes take their toll on even the most steadfast of travelers. You find yourself relying on alcohol to take the edge off. [+Alcohol Addiction]"
- player.CastImmediateOnSelf WithdrawalAlcohol
- Playsound UIHealthChemsAddicted
- else
- MessageBoxEx "The harsh wastes take their toll on even the most steadfast of travelers, except you. You find strength where others cannot."
- endif
- elseif ( EncounterSelection == 10 && bEnableAddictionEncounters == 1 )
- if Player.HasPerk NVDLC03TraitLogansLoophole
- MessageBoxEx "Anything to make the long, hot day pass faster. [Perk] Logans loophole allows you to avoid a nasty Jet addiction."
- elseif (CurrentSurvivalSkill <= 70 || CurrentEndurance <= 7 )
- MessageBoxEx "Anything to make the long, hot day pass faster. You've become reliant on Jet to get through the day. [-Jet Addiction]"
- player.CastImmediateOnSelf WithdrawalJet
- Playsound UIHealthChemsAddicted
- else
- MessageBoxEx "Anything to make the long, hot day pass faster. But where others may have faltered, you come out the other side stronger than ever."
- endif
- elseif EncounterSelection == 11
- MessageBoxEx "You come across some raiders that are drinking and shouting - they don't notice your approach. You dispatch them easily. [+50 XP]"
- RewardXP 50
- elseif EncounterSelection == 12
- set PlayerLevel to Player.Getlevel
- if PlayerLevel <15
- MessageBoxEx ("You come across a Deathclaw and are forced to run, you pop a couple of Stimpaks and lose some caps during your escape. [-2 Stimpaks] " + "[-" + $Random + " Caps ]")
- player.removeitem Stimpak 2
- player.removeitem Caps001 Random
- RewardXP 150
- playsound NPCDeathclawIdleClawScrape
- elseif PlayerLevel >= 20 && PlayerLevel < 25
- MessageBoxEx "You come across a Deathclaw - a long an intense fight ensues. You come out badly bruised, but alive. [+150 XP] [-1 Stimpak]"
- player.removeitem Stimpak 1
- RewardXP 150
- playsound NPCDeathclawIdleClawScrape
- elseif PlayerLevel > 24
- MessageBoxEx "During your journey, you come across a Deathclaw - it's no match for an experienced wastelander like you. You take it's hand as a trophy. [+150 XP] [+1 Deathclaw Hand]"
- RewardXP 150
- player.additem DeathClawHand 1
- playsound NPCDeathclawDeath
- endif
- elseif EncounterSelection == 13
- MessageBoxExAlt FastTravelRaiderGang "^Raider Gang Ahead^You spot a large group of raiders in the distance.%rThey're drinking and yelling,%rand haven't spotted you.|Fight|Sneak past"
- elseif EncounterSelection == 14
- MessageBoxExAlt FastTravelDeadWastelander "^Dead Wastelander^A dead wastelander lies before you. They seem to%rhave been carrying some medical supplies:|Bury them|Desecrate their body|Loot them"
- elseif EncounterSelection == 15
- MessageBoxEx "Though your journey is safe, the dry wasteland takes a toll, and you consume extra water during this trip. [-2 Purified Water]"
- player.removeitem WaterPurified 2
- playsound NPCHumanDrinkingBottleGulp
- if watercount >= 2
- player.removeitem WaterPurified 2
- playsound NPCHumanDrinkingBottleGulp
- elseif watercount < 2 && playerref.IsHardcore == 1
- ;Damage dehydration if in Hardcore mode.
- MessageBoxEx "You didn't have enough water [- 150 H2O]"
- player.damageav Dehydration 150
- endif
- elseif EncounterSelection == 16
- MessageBoxExAlt FastTravelCaravanInTrouble "^Distressed Caravan^In the distance, you spot a caravan surrounded by%rraiders. They seem to be in considerable distress:|Help the caravan|Ignore them"
- elseif EncounterSelection == 17
- MessageBoxExAlt FastTravelBoobyTrapped "^Suspicious Trunk^You come across one of the wasteland's many%rabandoned, inoperable cars. This one seems%rdifferent though - it's trunk appears to be tied%rshut with a flimsy looking rope. Upon closer%rinspection, the trunk is clearly trapped.|Attempt to disarm the trap|Leave the trunk alone"
- elseif EncounterSelection == 18
- MessageBoxExAlt FastTravelStrangeMan "^Encounter With A Stranger^An elderly wastelander offers you an open drink:|Accept the drink|Reject the drink"
- elseif EncounterSelection == 19
- if playerref.IsHardcore == 1 ; if hardcore is activated
- MessageBoxEx "The weather is nice, and your journey is peaceful. You feel refreshed [-150 Sleep Deprivation]."
- player.restoreav SleepDeprevation 150
- else
- MessageBoxEx "The weather is nice, and your journey is peaceful. You come across a clean water pipe, and you fill up a spare bottle. [+1 Purified Water]"
- player.additem waterpurified 1
- endif
- elseif EncounterSelection == 20
- if Player.HasPerk WildWasteland
- MessageBoxEx "The heat is starting to get to you - in the distance, you see a dance party in the middle of the wasteland, complete with multi-colored stand lights and blaring Sinatra. You excitedly approach to find out it's just a group of Brahmin grazing by a muddy pond. Dissapointing."
- playSound UIWildWasteland
- else
- MessageBoxEx "Nothing of note happens on your journey - what a relief."
- endif
- elseif EncounterSelection == 21
- MessageBoxEx "An extreme heat wave forces you to take a risky shortcut. You slip in the process, and injure both of your legs. [+Crippled Legs]"
- call FastTravelPainSoundRandomiserUDF
- player.damageav leftmobilitycondition 100
- player.damageav rightmobilitycondition 100
- elseif EncounterSelection == 22
- MessageBoxExAlt FastTravelRaiderShakedown "^Raider Leader^You run into a Raider gang, their leader%rdemands 200 caps. He threatens to break your legs%rif you don't comply. He seems tough:|Pay them|Attack them|Trick them"
- elseif EncounterSelection == 23
- if CurrentSurvivalSkill >= 70
- MessageBoxEx "You get turned around on your travels, but your excellent sense of direction allows you to quickly reorient yourself, with very little lost time."
- else
- MessageBoxEx "You get turned around on your travels, wasting a lot of time and making you thirsty. [-1 Purified Water]"
- player.removeitem WaterPurified 1
- playsound NPCHumanDrinkingBottleGulp
- endif
- elseif EncounterSelection == 24
- MessageBoxEx "A friendly Caravaneer offers you a ride to your destination, you have time to rest and plan your next move. [+Health Restored]"
- player.resethealth
- elseif EncounterSelection == 25
- MessageBoxExAlt FastTravelCazadoreSting "^Cazadore Sting^An encounter with some cazadors leaves%ryou in great pain as one of the insects%rstings you with it's tail.%rHow will you deal with the sting?|Find a doctor|Tough it out|Attempt to treat the sting yourself"
- elseif EncounterSelection == 26
- MessageBoxExAlt FastTravelBighornerEncounter "^Bighorner Herd^A wandering herd of Bighorners crosses your path.%rThey seem uninterested in you. |Attack|Leave them alone"
- elseif EncounterSelection == 27
- MessageBoxExAlt FastTravelUnsuspectingWastelander "^Unsuspecting Wastelander^There's a wastelander traveling infront of you.%rThey appear to be alone, and armed only with a%rpolice baton:|Rob|Attack|Pickpocket|Leave them alone"
- elseif EncounterSelection == 28
- if Player.HasPerk WildWasteland == 1
- MessageBoxEx "You accept some cave mushrooms from a bearded gentleman wearing sexy sleepwear. You wake up in the desert feeling strangely refreshed. You have no idea what just happened, but you feel fantastic."
- playSound UIWildWasteland
- else
- MessageBoxEx "You take a moment to stare out across the wastes - the horizon is calm. Just you, the sand, the heat, and a faint breeze."
- endif
- elseif EncounterSelection == 29
- MessageBoxExAlt FastTravelGhoulPack "^Ghoul Pack^A roaming pack of feral ghouls blocks your path.%rYou can choose to take an alternate route,%rbut it would likely add hours to your journey.:|Attack|Sneak by|Take the alternate path"
- ;Some general vanity encounters
- elseif EncounterSelection >= 30 && EncounterSelection <= 35
- ;This line will need to be changed if more vanity encounters are added.
- set VanityEncounters to Rand 1, 10
- if VanityEncounters == 1
- MessageBoxEx "Your geiger counter begins ticking very rapidly as you pass a rusty car wreck, but it abruptly stops once you take two steps to the north of the rusted hulk. Nothing looks suspicious about the vehicle. Is your geiger counter working properly?"
- elseif VanityEncounters == 2 && GetPlayerTeammateCount > 0
- MessageBoxEx "You and your companion share stories during the trip. The time passes quickly."
- elseif VanityEncounters == 2 && GetPlayerTeammateCount < 1
- MessageBoxEx "With no travelling companion to keep you company, you hum to yourself to pass the time."
- elseif VanityEncounters == 3
- MessageBoxEx "You pass by a few unrecognizable bodies. The smell is unbearable."
- elseif VanityEncounters == 4
- MessageBoxEx "You find a deceased Deathclaw, it's hands and horns missing. A dozen laser burns crisscross it's chest and face."
- elseif VanityEncounters == 5
- MessageBoxEx "Your travels are tiring, and your bones are weary. If only you had a working car..."
- elseif VanityEncounters == 6
- MessageBoxEx "You find yourself wondering about how other states and countries fared after the bombs dropped."
- elseif VanityEncounters == 7
- MessageBoxEx "You spot a trail of blood but it quickly dissapears into the sand. It's probably not worth following further anyway."
- elseif VanityEncounters == 8
- MessageBoxEx "You find yourself itching. Did something bite you? Maybe it's just the heat..."
- elseif VanityEncounters == 9
- MessageBoxEx "You recall reading about small creatures called cats in a pre-war magazine. You wish you could pet one."
- elseif VanityEncounters == 10
- MessageBoxEx "You find the long dried skeleton of a vault dweller, evident by the scrap of jumpsuit next to the skull."
- endif
- ;Some general WW encounters (Mostly vanity although some have effects)
- ;This line will need to be changed if more vanity encounters are added.
- elseif EncounterSelection > 35
- if Player.HasPerk WildWasteland == 1
- playSound UIWildWasteland
- set WWEncounters to Rand 1, 10
- if WWEncounters == 1
- MessageBoxEx "A crowd of angry Brahmin rushes at you, mooing with fervor and hate in their eyes. They trample you viciously before leaving. [-15 HP]"
- if CurrentHPLevel > 15
- player.DamageActorValue Health 15
- else
- player.DamageActorValue Health (CurrentHPLevel - 1)
- endif
- playsound NPCBrahminAttack
- playsound NPCBrahminIdleMoo
- playsound NPCBrahminInjured
- playsound NPCBrahminFootL
- playsound NPCBrahminFootR
- call FastTravelPainSoundRandomiserUDF
- elseif WWEncounters == 2
- MessageBoxEx "You come across a giant footprint, filled in with rainwater. There's no others in the area. A crushed stealth boy sits in the puddle."
- elseif WWEncounters == 3
- MessageBoxEx "A small glowing dot hovers above you in the sky. Suddenly, it begins flying to the east, then abruptly changes it's direction at a perfect right angle and shoots directly up into the sky, beyond your view. You don't feel like you're completely alone..."
- elseif WWEncounters == 4
- MessageBoxEx "You come across a crashed Nuka-Cola delivery truck. The driver's skeleton has been crushed inside the cabin, and most of the Nuka-Cola bottles have popped open or shattered."
- ;Only used here so only update luck when needed
- set Currentluck to Player.GetAV Luck
- if Currentluck > 6
- MessageBoxEx "You're lucky enough to find an intact bottle of Nuka-Cola!"
- player.addItem Nukacola 1
- endif
- elseif WWEncounters == 5
- MessageBoxEx "You feel some ammo sliding out of your pocket. A thief! You turn around quickly, but nobody is there."
- elseif WWEncounters == 6
- MessageBoxEx "You come across a man drinking what appears to be car coolant. Your geiger counter ticks when he gets nearby. You leave the man to his beverage."
- elseif WWEncounters == 7
- MessageBoxEx "In a crater, you see massive mounds of blubber and huge bones. Something very large died here."
- elseif WWEncounters == 8
- MessageBoxEx "In a crater, you see massive mounds of blubber and huge bones. Something very large died here."
- elseif WWEncounters == 9
- MessageBoxEx "In the distance, you spot a hunter leading along a golden gecko with a leash and a collar. The gecko seems complacent."
- elseif WWEncounters == 10
- MessageBoxEx "You come across a group of cannibals. They seem desperate."
- else
- ;Exception for player not having WW so that something happens
- MessageBoxEx "Your spine tingles as you walk past the decaying remains of a Brahmin. Organs and bones half-covered in viscera lay strewn around. Something terrible happened here."
- endif
- endif
- else
- ;Generally this block will never be entered. Here for debugging purposes.
- MessageBoxEx "FAST TRAVEL ENCOUNTERS: Error002, something should have happened here but an exception occured and the handler has attempted to launch a non-existant encounter. check for conflicts, mod updates or attempt to reinstall. This message will only diplay once per game-session"
- ;I.e in the event where another mod / script modifies the variable controlling selection.
- Print "Error, something should have happened here but an exception occured and the handler has attempted to launch a non-existant encounter. check for conflicts"
- endif
- else
- ;do nothing
- ;print "Nothing happened"
- endif
- ;Send help
- end
Advertisement
Add Comment
Please, Sign In to add comment