Jump to content

Using array or formlist for random spawnpoint


gerg357

Recommended Posts

It'll spawn something at the marker if I call it by name when I leave room then it's there waiting it's only when I try the code you give me is where I'm having issues what I want to do is spawn stuff at a random location which would be from a list that I use I thought formlist would be what I need... maybe an array would be better?
Link to comment
Share on other sites

When you put the spawn point directly into a property, it makes the reference persistent so that it can be found and used even when it is not loaded. Putting the objects in a formlist doesn't have the same effect. Switching to an array should solve the issue.
Link to comment
Share on other sites

this is what i got so far playing with arrays from what little i could find online i dunno how to add a array to ck im guessing they are just form lists??

 

Scriptname TownCheckScript extends ObjectReference
ActorBase Property EncBandit01Melee1HNordM Auto
ActorBase Property WEDL05Thug Auto
ActorBase Property EncVampire01BretonF Auto
ObjectReference Property SpawnPoint1 Auto
ObjectReference Property SpawnPoint2 Auto
ObjectReference Property SpawnPoint3 Auto
ObjectReference Property SpawnPoint4 Auto
ObjectReference Property SpawnPoint5 Auto
ObjectReference Property SpawnPoint6 Auto
ObjectReference Property SpawnPoint7 Auto
ObjectReference Property SpawnPoint8 Auto
Message Property checkfail Auto
Message Property OffPatrol Auto
Message Property bandits1 Auto
Message Property bandits2 Auto
Message Property bandits3 Auto
Message Property nobandits Auto
ObjectReference[] Property spawnpoints Auto

Message Property thugs1 Auto
Message Property thugs2 Auto
Message Property thugs3 Auto
Message Property nothugs Auto
Message Property vampires1 Auto
Message Property vampires2 Auto
Message Property vampires3 Auto
Message Property novampires Auto
Message Property timesup Auto
float CheckTime ; the only status variable needed
GlobalVariable Property OnPatrol Auto


Event OnActivate(ObjectReference akActionRef)

if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this
return
endif
if OnPatrol.GetValue() == 1
if CheckTime == 0.0 ; starting a shift
CheckTime = 2.0 + Utility.GetCurrentGameTime() * 24.0 ; converts days to hours

int spawns = spawnpoints.Length
int randomm = Utility.RandomInt(0, spawns)
int random = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2
ObjectReference points = spawnpoints[randomm]
If random == 0
int random1 = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2
If random1 == 0
points.PlaceActorAtMe(EncBandit01Melee1HNordM,1)
bandits1.Show()
ElseIf random1 == 1
bandits2.Show()
points.PlaceActorAtMe(EncBandit01Melee1HNordM,2)
points.PlaceActorAtMe(EncBandit01Melee1HNordM,2)
ElseIf random1 == 3
bandits3.Show()
points.PlaceActorAtMe(EncBandit01Melee1HNordM,3)
points.PlaceActorAtMe(EncBandit01Melee1HNordM,3)
points.PlaceActorAtMe(EncBandit01Melee1HNordM,3)
Else
nobandits.Show()
EndIf


ElseIf random == 1
int random2 = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2
If random2 == 0
points.PlaceActorAtMe(WEDL05Thug,1)
thugs1.Show()
ElseIf random2 == 1
thugs2.Show()
points.PlaceActorAtMe(WEDL05Thug,2)
points.PlaceActorAtMe(WEDL05Thug,2)
ElseIf random2 == 3
thugs3.Show()
points.PlaceActorAtMe(WEDL05Thug,3)
points.PlaceActorAtMe(WEDL05Thug,3)
points.PlaceActorAtMe(WEDL05Thug,3)
Else
nothugs.Show()
EndIf

ElseIf random == 3
int random3 = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2
If random3 == 0
points.PlaceActorAtMe(EncVampire01BretonF,1)
vampires1.Show()
ElseIf random3 == 1
vampires2.Show()
points.PlaceActorAtMe(EncVampire01BretonF,2)
points.PlaceActorAtMe(EncVampire01BretonF,2)
ElseIf random3 == 3
vampires3.Show()
points.PlaceActorAtMe(EncVampire01BretonF,3)
points.PlaceActorAtMe(EncVampire01BretonF,3)
points.PlaceActorAtMe(EncVampire01BretonF,3)
Else
novampires.Show()
EndIf

Else
nobandits.Show()
EndIf

elseif Utility.GetCurrentGameTime() * 24.0 >= CheckTime ; have worked long enough
CheckTime = 0.0 ; reset for next time
timesup.Show()



else ; not done yet! The message can show how many hours are left
checkfail.Show()
endif
else
OffPatrol.Show()
endif
endEvent

 

 

it is now spawning them in the room im using it in and not at the spawn points i was hoping i had this right but apparently not...

 

any ideas whats wrong?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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