Jump to content

Problems with calling a LeveledActor from a script


Recommended Posts

I'm working on improving my Wave Spawner (and Spawn Grenade, since it probably has the same problem). User M1stLynx pointed out that they spawn multiple copies of the same guy whenever the device triggers. I've tried separating out the spawns into individual rolls like so, and the same thing happens. It always picks the first actor in the LeveledActor list. For reference, this is what my properties look like.

Function SpawnRandom(Int MenuChoice, Int SpawnChoice, Int SpawnNum)

	Int Count = 1
	While Count <= SpawnNum
		If MenuChoice == 0
			ToSpawn = AnimalWave[SpawnChoice]
		ElseIf MenuChoice == 1
			ToSpawn = RobotWave[SpawnChoice]
		ElseIf MenuChoice == 2
			ToSpawn = EnemyWave[SpawnChoice]
		ElseIf MenuChoice == 3
			ToSpawn = GangWave[SpawnChoice]
		ElseIf MenuChoice == 4
			ToSpawn = MonsterWave[SpawnChoice]
		EndIf
		PlaceAtMe(ToSpawn, 1)
		Count += 1
	EndWhile

EndFunction

For example, if I choose Raider off the menu, I get EncRaider01Template every time. Bear in mind, I tested this with a level 100 character.

 

Do scripts simply not know how to handle leveled actors, or am I doing something wrong with either the script or the properties? Full script under spoiler below.

 

  Reveal hidden contents

 

 

Link to comment
Share on other sites

All the NPC spawning my mods do is always based on random indexing of lvlNPC FormLists rather than the intermediate LCharNPC level lists. You need to change PlaceAtMe() to PlaceactorAtMe() as well

 

For a quick test create a formlist drag in some lvlNPCs and stick this in your while:

FormList Property pNPCList Auto Const Mandatory 

Int iIndex = Utility.RandomInt(0, (pNPCList.GetSize() - 1) )
ActorBase ToSpawn = ( pNPCList.GetAt(iIndex) as ActorBase)
ObjectReference akActorRef = MarkerToSpawnAt.PlaceActorAtMe(ToSpawn)

Disclaimer: extensive sampling suggests that the seeding used for Utility.Random in papyrus is not that random, I always add a synthetic layer (While iIndex == iLastIndex) to avoid using the last value.

Edited by SKK50
Link to comment
Share on other sites

  • Recently Browsing   0 members

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