Jump to content

Script command to count number of actors in current cell?


FishBiter

Recommended Posts

I need to make a script count the number of actors in the current cell the player is in, and I am wondering if there is a command available for that. It would be really helpful if it could actually count the number of one specific type of actor.

 

 

Basically something like this

 

Set NumActors to (this is where the command would go)

 

If NumActors < 6

Do this

ElseIf NumActorse <= 6

Do Nothing

EndIf

 

 

So basically the script would do one thing if there are more than 6 actors in the current cell, and something else if there's less. Again, it would be really helpful if it could count a specific type of actor (for example, radroaches).

Edited by FishBiter
Link to comment
Share on other sites

So then GetNumRefs is what I need, but trying to use it I'm getting nothing.

 

 

If GetNumRefs 43 >= 3
Set SpawnIt to 0
Else
Set SpawnIt to 1
EndIf
So I thought that that bit right there would set SpawnIt to 0 if there were 3 or more creatures in the current cell. That didn't happen though.
Basically I'm trying to change the Zombie Apocalypse script so that it doesn't keep spawning zombies if there is a certain number of them in the current cell already.
Link to comment
Share on other sites

Then I would use a quest script and a REFWalk for what you want to do. If there is more than one zombie type, put them in a form list. Otherwise you can just use GetIsID




scn MyZombieControlQuestScript


short iZombieCount
ref rActorREF
short iEnableSpawn


;Quest delay 1-3 seconds, start game enabled


BEGIN GameMode


Label 10
set iZombieCount to 0
set rActorREF to GetFirstREF 200 1 ;Actors, and if outside - current cell plus 8 surrounding cells


Label 20
if (rActorREF)
if (rActorREF.IsInList MyZombieActorFormList) ;Or just use rActorREF.GetIsID ZombieBaseEditorID if there is only one zombie type
set iZombieCount to iZombieCount + 1
endif
set rActorREF to Pencil01
set rActorREF to GetNextREF
Goto 20
endif


if (iZombieCount >= 50)
set iEnableSpawn to 0
else
set iEnableSpawn to 1
endif


Goto 10


END



Link to comment
Share on other sites

All right, so I implemented that script. Made the quest, the form list, and copy pasted your script right in. The only thing I changed was the last part, making iEnableSpawn into a Global so that I could call it in the other script that spawns the zombies.

 

Now whenever I try to go into an exterior where there would be zombies, the game freezes.

Edited by FishBiter
Link to comment
Share on other sites

  • Recently Browsing   0 members

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