gerg357 Posted August 15, 2016 Share Posted August 15, 2016 I can make a spawn point in ck but im having a hard time generating a random one from a list dunno if i need an array or form list i tried a form list using this code but this wont compile int s = spawnpoints.GetSize() - 1 s = utility.RandomInt(0, S)spawnpoints.GetAt(s).PlaceActorAtMe(EncBandit01Melee1HNordM,1) im guessing it has to do with the spawnpoints.GetAt(s) part.. Any help on how to do this? Link to comment Share on other sites More sharing options...
FrankFamily Posted August 15, 2016 Share Posted August 15, 2016 Post the full script, with it's properties and everything and the compile error it givesIf that's you full script you are missing half the script, check this tutorial: http://www.cipscis.com/skyrim/tutorials/beginners.aspxAnd here you find all events and functions: http://www.creationkit.com/index.php?title=Category:Papyrus Link to comment Share on other sites More sharing options...
gerg357 Posted August 15, 2016 Author Share Posted August 15, 2016 Scriptname TownCheckScript extends ObjectReferenceActorBase Property EncBandit01Melee1HNordM AutoActorBase Property WEDL05Thug AutoActorBase Property EncVampire01BretonF AutoObjectReference Property SpawnPoint1 AutoMessage Property checkfail AutoMessage Property bandits1 AutoMessage Property bandits2 AutoMessage Property bandits3 AutoMessage Property nobandits AutoMessage Property thugs1 AutoMessage Property thugs2 AutoMessage Property thugs3 AutoMessage Property nothugs AutoFormList Property spawnpoints AutoMessage Property vampires1 AutoMessage Property vampires2 AutoMessage Property vampires3 AutoMessage Property novampires Autofloat CheckTime ; the only status variable neededEvent OnActivate(ObjectReference akActionRef) if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this return endif if CheckTime == 0.0 ; starting a shift CheckTime = 2.0 + Utility.GetCurrentGameTime() * 24.0 ; converts days to hours int s = spawnpoints.GetSize() - 1 s = utility.RandomInt(0, S) int random = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2 If random == 0 int random1 = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2 If random1 == 0 spawnpoints.GetAt(s).PlaceActorAtMe(EncBandit01Melee1HNordM,1) bandits1.Show() ElseIf random1 == 1 bandits2.Show() spawnpoints.GetAt(s).PlaceActorAtMe(EncBandit01Melee1HNordM,2) spawnpoints.GetAt(s).PlaceActorAtMe(EncBandit01Melee1HNordM,2) ElseIf random1 == 3 bandits3.Show() spawnpoints.GetAt(s).PlaceActorAtMe(EncBandit01Melee1HNordM,3) spawnpoints.GetAt(s).PlaceActorAtMe(EncBandit01Melee1HNordM,3) spawnpoints.GetAt(s).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 spawnpoints.GetAt(s).PlaceActorAtMe(WEDL05Thug,1) thugs1.Show() ElseIf random2 == 1 thugs2.Show() spawnpoints.GetAt(s).PlaceActorAtMe(WEDL05Thug,2) spawnpoints.GetAt(s).PlaceActorAtMe(WEDL05Thug,2) ElseIf random2 == 3 thugs3.Show() spawnpoints.GetAt(s).PlaceActorAtMe(WEDL05Thug,3) spawnpoints.GetAt(s).PlaceActorAtMe(WEDL05Thug,3) spawnpoints.GetAt(s).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 spawnpoints.GetAt(s).PlaceActorAtMe(EncVampire01BretonF,1) vampires1.Show() ElseIf random3 == 1 vampires2.Show() spawnpoints.GetAt(s).PlaceActorAtMe(EncVampire01BretonF,2) spawnpoints.GetAt(s).PlaceActorAtMe(EncVampire01BretonF,2) ElseIf random3 == 3 vampires3.Show() spawnpoints.GetAt(s).PlaceActorAtMe(EncVampire01BretonF,3) spawnpoints.GetAt(s).PlaceActorAtMe(EncVampire01BretonF,3) spawnpoints.GetAt(s).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 else ; not done yet! The message can show how many hours are left checkfail.Show() endif endEvent Link to comment Share on other sites More sharing options...
gerg357 Posted August 15, 2016 Author Share Posted August 15, 2016 error i was getting was placeatme isnt a function.. Link to comment Share on other sites More sharing options...
lofgren Posted August 15, 2016 Share Posted August 15, 2016 When you get something from a formlist it comes as a base form. You need to cast it to something if you want to use functions that are not on the form script. (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,1) Link to comment Share on other sites More sharing options...
gerg357 Posted August 15, 2016 Author Share Posted August 15, 2016 Ok sorry to bother you with all this but can you explain what you mean by baseform and why you added it there. I can use this code but I wanna also learn why I'm adding that front part. Link to comment Share on other sites More sharing options...
gerg357 Posted August 15, 2016 Author Share Posted August 15, 2016 And thx very much for the code too Link to comment Share on other sites More sharing options...
lofgren Posted August 15, 2016 Share Posted August 15, 2016 If you look at the top line of each script you will see something like: Scriptname ObjectReference extends Form Hidden That bit where it says "extends" indicates that this type of object also has access to all of the functions in the type of script it extends. So an objectreference has access to all of the functions in the form script. The same is not true in the other direction. Forms do not have access to the functions in the objectreference script. When you use GetAt() to access an entry on a formlist, it is automatically returned as a form. You have to tell Papyrus that this form is actually an objectreference (and therefore ought to have access to objectreference functions) by "casting" it using the word "as" like in the example. Link to comment Share on other sites More sharing options...
gerg357 Posted August 15, 2016 Author Share Posted August 15, 2016 hey thanks for the fast response i get it now.. thanks for clearing that up for me you have been a tremendous help ;) Link to comment Share on other sites More sharing options...
PeterMartyr Posted August 16, 2016 Share Posted August 16, 2016 " int random = Utility.RandomInt(0, 6) ; Generates a random number between 0 and 2 " no it generates a random Int between 0 and 6, not 0 and 2 Scriptname TownCheckScript extends ObjectReferenceActorBase Property EncBandit01Melee1HNordM AutoActorBase Property WEDL05Thug AutoActorBase Property EncVampire01BretonF AutoObjectReference Property SpawnPoint1 AutoMessage Property checkfail AutoMessage Property bandits1 AutoMessage Property bandits2 AutoMessage Property bandits3 AutoMessage Property nobandits AutoMessage Property thugs1 AutoMessage Property thugs2 AutoMessage Property thugs3 AutoMessage Property nothugs AutoFormList Property spawnpoints AutoMessage Property vampires1 AutoMessage Property vampires2 AutoMessage Property vampires3 AutoMessage Property novampires Autofloat CheckTime ; the only status variable neededEvent OnActivate(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() ; Only player can trigger if CheckTime == 0.0 ; starting a shift CheckTime = 2.0 + Utility.GetCurrentGameTime() * 24.0 ; converts days to hours int s = spawnpoints.GetSize() - 1 s = utility.RandomInt(0, S) int random = Utility.RandomInt(0, 2) ; Generates a random number between 0 and 2 If random == 0 int random1 = Utility.RandomInt(0, 2) ; Generates a random number between 0 and 2 If random1 == 0 (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,1) bandits1.Show() ElseIf random1 == 1 bandits2.Show() (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,2) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,2) ElseIf random1 == 2 bandits3.Show() (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,3) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,3) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncBandit01Melee1HNordM,3) Else nobandits.Show() EndIf ElseIf random == 1 int random2 = Utility.RandomInt(0, 2) ; Generates a random number between 0 and 2 If random2 == 0 (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(WEDL05Thug,1) thugs1.Show() ElseIf random2 == 1 thugs2.Show() (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(WEDL05Thug,2) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(WEDL05Thug,2) ElseIf random2 == 2 thugs3.Show() (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(WEDL05Thug,3) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(WEDL05Thug,3) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(WEDL05Thug,3) Else nothugs.Show() EndIf ElseIf random == 3 int random3 = Utility.RandomInt(0, 2) ; Generates a random number between 0 and 2 If random3 == 0 (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncVampire01BretonF,1) vampires1.Show() ElseIf random3 == 1 vampires2.Show() (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncVampire01BretonF,2) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncVampire01BretonF,2) ElseIf random3 == 2 vampires3.Show() (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncVampire01BretonF,3) (spawnpoints.GetAt(s) as ObjectReference).PlaceActorAtMe(EncVampire01BretonF,3) (spawnpoints.GetAt(s) as ObjectReference).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 else ; not done yet! The message can show how many hours are left checkfail.Show() endif EndIf endEvent Link to comment Share on other sites More sharing options...
Recommended Posts