Jump to content

Need Help Making an "On Hit Randomizer" Work


FinalBossJosh

Recommended Posts

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 Locations1
array_var Locations2
array_var Locations3
array_var Locations4
array_var Locations5
array_var Locations6
array_var Locations7
array_var Locations8
array_var Locations9
array_var Locations10
array_var Locations11
array_var Locations12
array_var Locations13
array_var Locations14
array_var Locations15
array_var Locations16
array_var Locations17
array_var Locations18
array_var Locations19
array_var LocationsArray
array_var rArray
array_var messages
int Rnumber
int ArrayNumber
ref rLocation
ref rmessage
begin GameMode
let Locations1 := Ar_List v188Heading, v188Heading, vAerotechHeadin, vAlliedTechOfficesHeading, vAntMoundHeading, vBitterSpringsHeading, vBitterSpringsRecreationHeading, vBlackRockHeading, vBlackRockCaveHeading, vBloodborneCaveHeading
let Locations2 := Ar_List vBlueParadiseVacationRentalsHeading, vBonnieSpringsHeading, vBoulderBeachCampgroundHeading, BoulderCityTravelMarker, vBradleysShackHeading, vBeerBootleggersHeading, vBrocFlowerCaveHeading, vBrooksTumbleweedRanchHeading, vBrotherhoodofSteelSafehouseHeading, vCaesarsLegionSafehouseHeading
let Locations3 := Ar_List vCaliforniaSunsetDriveInHeading, vCaliforniaSunsetDriveInHeading, vCallvilleBayHeading, vCampForlornHopeHeading, vCampGolfHeading, vCampGuardianHeading, vCampMcCarranHeading, vSearchlightHeading, vCannibalJohnsonsCaveHeading, vCapCounterfeitingShackHeading
let Locations4 := Ar_List vCazadorNestHeading, vCazadorNestHeading, vChanceMapHeading, vCharlestonCaveHeading, vClarkFieldHeading, vCliffsideProspectorCampHeading, vCottonwoodCoveHeading, vCottonwoodCoveHeading, vCottonwoodOverlookHeading, vCoyoteDenHeading
let Locations5 := Ar_List vCoyoteMinesHeadings, vCoyoteTailRidgeHeading, vCrashedB29Heading, vCrashedVertibirdHeading, vCrescentCanyonEastHeading, vCrescentCanyonWestHeading, vCrimsonCaravanCompanyHeading, vDeadWindCavernHeading, vDesertedShackHeading, vDurableDunnsSackedCaravanHeading
let Locations6 := Ar_List vEastPumpStationHeading, vElDoradoDryLakeHeading, vElDoradoGasServiceHeading, vElDoradoSubstationHeading, vElReyMotelHeading, vEmergencyServiceRailyardHeading, vFields'ShackHeading, vFireRootCavernHeading, vFishermansPrideShackHeading, vFollowersOutpostHeading
let Locations7 := Ar_List vFollower'sSafehouseHeading, vFreesideEastGateHeading, FreesideFastTravelMarker, vGibsonScrapYardHeading, GoodspringsArrivalMarker, vGoodspringsCaveHeading, vGoodspringsCemeteryHeading, vGoodspringsSourceHeading, vGreatKahnEncampmentHeading, vGriffinWaresSackedCaravanHeading
let Locations8 := Ar_List vGrubn'GulpRestStopHeading, vGuardianPeakHeading, vGunRunnersHeading, vGypsumTrainYardHeading, vHHToolsHeading, vHarper'sShackHeading, vHELIOSOneHeading, vHiddenSupplyCaveHeading, HiddenValleyCenterMarker, vHighway95VipersEncampmentHeading
let Locations9 := Ar_List VHDHooverDamMapMarkerStartREF, vHorowitzFarmsteadHeading, vHunterFarmHeading, vIvanpahDryLakeHeading, vIvanpahRaceTrackHeading, vJackRabbitSpringsHeading, JacobstownEntranceMarker, vJeanSkyDivingHeading, vJunction15RailwayStationHeading, vLakeLasVegasHeading
let Locations10 := Ar_List vLakeMeadCaveHeading, vLakeMeadCaveHeading, vLegionRaidCampHeading, vLoneWolfRadioHeading, vLuckyJimMineHeading, vMakeshiftGreatKhanCampHeading, vMatthewsAnimalHusbandryFarmHeading, vMesquiteMountainsCampSiteHeading, vMesquiteMountainsCraterHeading, vMiguelsPawnShopHeading
let Locations11 := Ar_List MojaveDriveInMarkerHeadingREF, vMojaveOutpostHeading, vMoleRatRanchHeading, vMonteCarloSuitesHeading, vMorningStarCavernHeading, vMountainShadowsCampgroundHeading, vNCRCFHeading, vNCRRangerSafehouseHeading, SharecropperFieldArrivalMarker, BlackMountainStartMarker
let Locations12 := Ar_List vNellisAirForceBaseHeading, vNellisAirForceBaseHeading, vNellisArrayHeading, vNelsonHeading, vNevadaHighwayPatrolStationHeading, vNewVegasMedicalClinicHeading, vNewVegasSteelHeading, vNiptonHeading, vNiptonRoadPitStopHeading, vNiptonRoadReststopHeading
let Locations13 := Ar_List vNopahCaveHeading, vNorthVegasSquareHeading, vNorthernPassageHeading, vNovacHeading, vOldNuclearTestSiteHeading, vPoseidonGasStationHeading, vPowderGangerCampEastHeading, vPowderGangerCampNorthHeading, vPowderGangerCampSouthHeading, vPowderGangerCampWestHeading
let Locations14 := Ar_List vPrimmHeading, vPrimmPassHeading, vQuarryJunctionHeading, vRaidedFarmsteadHeading, vRangerMoralesCorpseHeading, vRSAlphaHeading, vRSBravoHeading, vRSCharlieHeading, vRSDeltaHeading, vRSEchoHeading
let Locations15 := Ar_List vRSFoxtrotHeading, vRaulsShackHeading, vRedRockCanyonHeading, vRedRockDrugLabHeading, vRemnantsBunkerHeading, vREPCONNHeadquartersHeading, vREPCONNTestSiteHeading, vRubyHillMineHeading, vRockCrushingPlantHeading, vScavengerPlatformHeading
let Locations16 := Ar_List vSearchlightAirportHeading, vSearchlightAirportHeading, vSearchlightEastGoldMineHeading, vSearchlightNorthGoldMineHeading, vSilverPeakMineHeading, vSloanHeading, vSmithMesaProspectorCampHeading, vSnipersNestHeading, vSnyderProspectorCampHeading, vSpringMtRanchStateParkHeading
let Locations17 := Ar_List vSloanHeading, vSouthVegasRuinsEastEntranceHeading, vSouthVegasRuinsWestEntranceHeading, vSouthernNevadaWindFarmHeading, vSunsetSarsaparillaHeadquartersHeading, vTechatticupMineHeading, vTheBasincreekBuildingHeading, vTheDevilsGulletHeading, vTheDevilsThroatHeading, vTheFortHeading
let Locations18 := Ar_List vTheProspectorsDenHeading, vTheStripNorthGateHeading, vTheThornHeading, vTribalVillageHeading, vToxicDumpSiteHeading, vVault3Heading, vVault11Heading, vVault19Heading, vVault22Heading, vVault34Heading, vWestPumpStationHeading
let 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 / 100
let 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

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 by Radioactivelad
Link to comment
Share on other sites

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 TeleporterQuest

set TeleporterQuest.RandomNumber to Rand x y

 

 

endif

 

End

 

------TeleporterQuest script-----

 

int RandomNumber

 

Begin Gamemode

 

If RandomNumber == X

 

Player.Moveto Blahblahblah

Set RandomNumber to 0

Stopquest Teleporterquest

 

elseif RandomNumber == Y

 

Player.Moveto Yaddayadda

set RandomNumber to 0

stopquest TeleporterQuest

 

Endif

 

 

End

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...