FinalBossJosh Posted February 21, 2023 Share Posted February 21, 2023 Hi all! This is my first real mod Idea that I have sunk my teeth into. The basic idea is that whenever an enemy hits the player, the player is forcefully teleported to one of the fast travelable locations on the map. Ive gotten the random teleport to work OnFire with a weapon but I am unsure how to make it work OnHit on the player. Below is the script I have been testing with, please excuse its messiness. (I have old test code commented away that needs to be removed I know) scn 0TestLocationRando array_var Locations array_var Locations1array_var Locations2array_var Locations3array_var Locations4array_var Locations5array_var Locations6array_var Locations7array_var Locations8array_var Locations9array_var Locations10array_var Locations11array_var Locations12array_var Locations13array_var Locations14array_var Locations15array_var Locations16array_var Locations17array_var Locations18array_var Locations19 array_var LocationsArrayarray_var rArray array_var messagesint Rnumberint ArrayNumberref rLocationref rmessage begin GameMode let Locations1 := Ar_List v188Heading, v188Heading, vAerotechHeadin, vAlliedTechOfficesHeading, vAntMoundHeading, vBitterSpringsHeading, vBitterSpringsRecreationHeading, vBlackRockHeading, vBlackRockCaveHeading, vBloodborneCaveHeadinglet Locations2 := Ar_List vBlueParadiseVacationRentalsHeading, vBonnieSpringsHeading, vBoulderBeachCampgroundHeading, BoulderCityTravelMarker, vBradleysShackHeading, vBeerBootleggersHeading, vBrocFlowerCaveHeading, vBrooksTumbleweedRanchHeading, vBrotherhoodofSteelSafehouseHeading, vCaesarsLegionSafehouseHeadinglet Locations3 := Ar_List vCaliforniaSunsetDriveInHeading, vCaliforniaSunsetDriveInHeading, vCallvilleBayHeading, vCampForlornHopeHeading, vCampGolfHeading, vCampGuardianHeading, vCampMcCarranHeading, vSearchlightHeading, vCannibalJohnsonsCaveHeading, vCapCounterfeitingShackHeadinglet Locations4 := Ar_List vCazadorNestHeading, vCazadorNestHeading, vChanceMapHeading, vCharlestonCaveHeading, vClarkFieldHeading, vCliffsideProspectorCampHeading, vCottonwoodCoveHeading, vCottonwoodCoveHeading, vCottonwoodOverlookHeading, vCoyoteDenHeadinglet Locations5 := Ar_List vCoyoteMinesHeadings, vCoyoteTailRidgeHeading, vCrashedB29Heading, vCrashedVertibirdHeading, vCrescentCanyonEastHeading, vCrescentCanyonWestHeading, vCrimsonCaravanCompanyHeading, vDeadWindCavernHeading, vDesertedShackHeading, vDurableDunnsSackedCaravanHeadinglet Locations6 := Ar_List vEastPumpStationHeading, vElDoradoDryLakeHeading, vElDoradoGasServiceHeading, vElDoradoSubstationHeading, vElReyMotelHeading, vEmergencyServiceRailyardHeading, vFields'ShackHeading, vFireRootCavernHeading, vFishermansPrideShackHeading, vFollowersOutpostHeadinglet Locations7 := Ar_List vFollower'sSafehouseHeading, vFreesideEastGateHeading, FreesideFastTravelMarker, vGibsonScrapYardHeading, GoodspringsArrivalMarker, vGoodspringsCaveHeading, vGoodspringsCemeteryHeading, vGoodspringsSourceHeading, vGreatKahnEncampmentHeading, vGriffinWaresSackedCaravanHeadinglet Locations8 := Ar_List vGrubn'GulpRestStopHeading, vGuardianPeakHeading, vGunRunnersHeading, vGypsumTrainYardHeading, vHHToolsHeading, vHarper'sShackHeading, vHELIOSOneHeading, vHiddenSupplyCaveHeading, HiddenValleyCenterMarker, vHighway95VipersEncampmentHeadinglet Locations9 := Ar_List VHDHooverDamMapMarkerStartREF, vHorowitzFarmsteadHeading, vHunterFarmHeading, vIvanpahDryLakeHeading, vIvanpahRaceTrackHeading, vJackRabbitSpringsHeading, JacobstownEntranceMarker, vJeanSkyDivingHeading, vJunction15RailwayStationHeading, vLakeLasVegasHeadinglet Locations10 := Ar_List vLakeMeadCaveHeading, vLakeMeadCaveHeading, vLegionRaidCampHeading, vLoneWolfRadioHeading, vLuckyJimMineHeading, vMakeshiftGreatKhanCampHeading, vMatthewsAnimalHusbandryFarmHeading, vMesquiteMountainsCampSiteHeading, vMesquiteMountainsCraterHeading, vMiguelsPawnShopHeadinglet Locations11 := Ar_List MojaveDriveInMarkerHeadingREF, vMojaveOutpostHeading, vMoleRatRanchHeading, vMonteCarloSuitesHeading, vMorningStarCavernHeading, vMountainShadowsCampgroundHeading, vNCRCFHeading, vNCRRangerSafehouseHeading, SharecropperFieldArrivalMarker, BlackMountainStartMarkerlet Locations12 := Ar_List vNellisAirForceBaseHeading, vNellisAirForceBaseHeading, vNellisArrayHeading, vNelsonHeading, vNevadaHighwayPatrolStationHeading, vNewVegasMedicalClinicHeading, vNewVegasSteelHeading, vNiptonHeading, vNiptonRoadPitStopHeading, vNiptonRoadReststopHeadinglet Locations13 := Ar_List vNopahCaveHeading, vNorthVegasSquareHeading, vNorthernPassageHeading, vNovacHeading, vOldNuclearTestSiteHeading, vPoseidonGasStationHeading, vPowderGangerCampEastHeading, vPowderGangerCampNorthHeading, vPowderGangerCampSouthHeading, vPowderGangerCampWestHeadinglet Locations14 := Ar_List vPrimmHeading, vPrimmPassHeading, vQuarryJunctionHeading, vRaidedFarmsteadHeading, vRangerMoralesCorpseHeading, vRSAlphaHeading, vRSBravoHeading, vRSCharlieHeading, vRSDeltaHeading, vRSEchoHeadinglet Locations15 := Ar_List vRSFoxtrotHeading, vRaulsShackHeading, vRedRockCanyonHeading, vRedRockDrugLabHeading, vRemnantsBunkerHeading, vREPCONNHeadquartersHeading, vREPCONNTestSiteHeading, vRubyHillMineHeading, vRockCrushingPlantHeading, vScavengerPlatformHeadinglet Locations16 := Ar_List vSearchlightAirportHeading, vSearchlightAirportHeading, vSearchlightEastGoldMineHeading, vSearchlightNorthGoldMineHeading, vSilverPeakMineHeading, vSloanHeading, vSmithMesaProspectorCampHeading, vSnipersNestHeading, vSnyderProspectorCampHeading, vSpringMtRanchStateParkHeadinglet Locations17 := Ar_List vSloanHeading, vSouthVegasRuinsEastEntranceHeading, vSouthVegasRuinsWestEntranceHeading, vSouthernNevadaWindFarmHeading, vSunsetSarsaparillaHeadquartersHeading, vTechatticupMineHeading, vTheBasincreekBuildingHeading, vTheDevilsGulletHeading, vTheDevilsThroatHeading, vTheFortHeadinglet Locations18 := Ar_List vTheProspectorsDenHeading, vTheStripNorthGateHeading, vTheThornHeading, vTribalVillageHeading, vToxicDumpSiteHeading, vVault3Heading, vVault11Heading, vVault19Heading, vVault22Heading, vVault34Heading, vWestPumpStationHeadinglet Locations19 := Ar_List vVault22Heading,vSnipersNestHeading, vQuarryJunctionHeading, vWalkingBoxCavernHeading, vWestPumpStationHeading, vWestsideWestEntranceHeading, vWhittakerFarmsteadHeading, vWolfhornRanchHeading, vWreckedHighwaymanHeading, vYangtzeMemorialHeading let LocationsArray := Ar_List Locations1, Locations2, Locations3, Locations4, Locations5, Locations6, Locations7, Locations8, Locations9, Locations10, Locations11, Locations12, Locations13, Locations14, Locations15, Locations16, Locations17, Locations18, Locations19 ;let Locations := Ar_List VProspectorTravel188PostMarkerREF, BitterSpringsMarkerREF, BMNeilConvinceMarker, GoodspringsArrivalMarker, HVSandStormFastTravelTriggerREF, VHeliosONEMapMarkerREF, HouseToolsMarker, JacobstownEntranceMarker ;let messages := Ar_List AbilityWellRestedEndMsg, AbilityWellRestedStartMsg, AddictionRemovalMsg, AprilMartimerDead, AtomicWranglerSlotsMsg, AWMDoorOpenedRepairHighMsg, AWMDoorOpenedRepairLowMsg, AWMHighPerceptionPassFridgeMsg, AWMStashFridgeKeyMsg, AWMStashNoteFridgeMsg, BCTrooperHostageMsgF, BCTrooperHostageMsgM, BigSalDead, BisonElevatorMessage, BMDebugOutputNumber, BMGetRightOnItMsg, BMGivePasswordMsg, BMHutRadioBroadcastPathMsg, BMHutRadioBroadcastSummitMsg, BMHutRadioBroadcastVillageMsg end Begin OnHit Player EnableFastTravel 1 0 1 let Rnumber := 0 + GetRandomPercent * 9 / 100let ArrayNumber := 0 + GetRandomPercent * 18 / 100 let rArray := LocationsArray[ArrayNumber] let rLocation := rArray[Rnumber];let rmessage := messages[Rnumber] player.MoveTo rLocation;showmessage rmessage End Thank you for any help given! Link to comment Share on other sites More sharing options...
FinalBossJosh Posted February 21, 2023 Author Share Posted February 21, 2023 Actually figured out a solution using SetOnHitEventHandler. if anyone knows a better solution that is still appreciated! Link to comment Share on other sites More sharing options...
Radioactivelad Posted February 21, 2023 Share Posted February 21, 2023 (edited) It feels like you're vastly overcomplicating something that could be done with a couple If statements and the Rand function. (Saying back-to-back If statements are bad is a meme by people who either don't understand programming or have seriously misplaced priorities. The important thing is is that it works and is human readable.) Edited February 21, 2023 by Radioactivelad Link to comment Share on other sites More sharing options...
FinalBossJosh Posted February 21, 2023 Author Share Posted February 21, 2023 Could you elaborate? Sorry I'm very new to this Link to comment Share on other sites More sharing options...
Radioactivelad Posted February 22, 2023 Share Posted February 22, 2023 Instead of doing this whole Array thing, you can use the Rand function to ask the engine for a random number between two specified values, then you can use that result to send the player to a specific location. I would store all that code in a Quest script thats started by your Onhit Event Something like- -----Hit Event Script------- Begin Onhit If GetquestRunning TeleporterQuest != 1 Startquest TeleporterQuestset TeleporterQuest.RandomNumber to Rand x y endif End ------TeleporterQuest script----- int RandomNumber Begin Gamemode If RandomNumber == X Player.Moveto BlahblahblahSet RandomNumber to 0Stopquest Teleporterquest elseif RandomNumber == Y Player.Moveto Yaddayaddaset RandomNumber to 0stopquest TeleporterQuest Endif End Link to comment Share on other sites More sharing options...
FinalBossJosh Posted February 23, 2023 Author Share Posted February 23, 2023 I think I see what you mean, but it is still a bit confusing. I just need to look over your example some more. Thank you so much for the help! Link to comment Share on other sites More sharing options...
Recommended Posts