Jump to content

Someone explain to me why this script doesnt work!


ajs52698

Recommended Posts

ScriptName DeadBodyRot Extends Actor


Group PossibleRottingActors


Race Property Human auto

Race Property SuperMutant auto

Race Property DecayMidRace auto

Race Property DecayEndRace auto



EndGroup


Actor Property Player auto

Formlist Property PossibleNpcList auto


Actor TargetActor

Location MyLocation

Race TargetActorRace



Event OnCellLoad()




MyLocation == Game.getplayer().GetCurrentLocation()


If Mylocation.HasEverBeenCleared()


Debug.notification("LocationClearedTest")



Rot()




Endif

EndEvent




Function Rot()


Int Size = 1000

Int Index = PossibleNpcList.GetSize()

Targetactor == PossibleNpcList.Getat(Index)

TargetActorRace == Targetactor.Getrace()




While Index < Size

Index -= 1


if Player.FindAllReferencesOfType(Targetactor, 2000) && targetactorrace == Human && Targetactor.isDead()




Debug.MessageBox("TargetFound")


Utility.Wait(0.5)

Debug.messagebox("RotOccuring")

TargetActor.SetRace(DecayMidRace)

Utility.Wait(0.5)

TargetActor.SetRace(DecayEndRace)


Endif

EndWhile

EndFunction

Link to comment
Share on other sites

I'm wanting to help, but I need to know a few things. You have a line that checks for the nearest actor but then you are also checking for the race of forms in a list and if any of them are dead.

 

I feel you're wanting to know the race of the actor FOUND from FindAllReferencesOfType() and check its race and if it's dead, and if all check out, change its race. The makes the formlist not needed.

Just wanting to know because I'm re-writing your script and this is confusing me as I don't know what you're really wanting to do there.

 

But for the few things wrong with that script, one is this:

 

MyLocation ==

 

When you are assigning something to a variable, it's always just one equal sign. Double is the comparison operator.

 

Edit: OK I see what the real issue is here. FindAllReferencesOfType returns an array, not a formlist, and you did not assign to an array variable. This answers my question.

I can do everything with just arrays, but again, what do you need to formlist for? Are you wanting to check for actors in the area, or from the formlist?

Edited by TummaSuklaa
Link to comment
Share on other sites

the formlist contains all the actors which are human since those are the only ones that need to rot, not all actors.

 

and to answer your question I want to check if all actors in the area are in the formlist and if they are dead, also are they human race?

 

I might be thinking about it wrong and maybe I dont need the formlist \: Im a noob so :P

Edited by ajs52698
Link to comment
Share on other sites

Ok that helps. Ok so your formlist is actually a list of race forms. Alright, will see what I can do. But there is only one form that is a Human Race. So maybe you want to check against rather or not the actors are of the human race in the area, and then change their race. I can see what kind of mod this will be, sounds like a zombie apocalypse :D

Edited by TummaSuklaa
Link to comment
Share on other sites

Nah its just a simple idea for human which are killed to rot overtime(atleast the ones who dont respawn), immersion!

 

and in the formlist are all of the humans in the human race catagory in the ck.

Edited by ajs52698
Link to comment
Share on other sites

 

ScriptName DeadBodyRot Extends Actor
Group PossibleRottingActors
Race Property Human auto
Race Property SuperMutant auto
Race Property DecayMidRace auto
Race Property DecayEndRace auto
EndGroup
Actor Property Player auto
Formlist Property PossibleNpcList auto
Actor TargetActor
Location MyLocation
Race TargetActorRace
Event OnCellLoad()
MyLocation = Game.getplayer().GetCurrentLocation()
If Mylocation.isCleared()
Debug.notification("LocationClearedTest")
Rot()
Endif
EndEvent
Function Rot()
Int Size = 1000
Int Index = PossibleNpcList.GetSize()
Targetactor == PossibleNpcList.Getat(Index)
TargetActorRace == Targetactor.Getrace()
ObjectReference[] kActorList = Player.FindAllReferencesOfType(PossibleNpcList, 2000)
Int i = 0
Int iIndex = kActorList.Length
While i < iIndex
if (kActorList as Actor).isDead()
Debug.notification("TargetFound")
Utility.Wait(0.5)
Debug.notification("RotOccuring")
(kActorList as Actor).SetRace(DecayMidRace)
Utility.Wait(0.5)
(kActorList as Actor).SetRace(DecayEndRace)
Endif
i += 1
EndWhile
EndFunction

 

See if this works out. As all the actors you say are human.. no need to check for the race. Took out the messagebox functions because they would pause your script, the waits are already pauses to begin with.

Edited by TummaSuklaa
Link to comment
Share on other sites

Ah man it worked, thanks! Now im gonna do some small fixes and figure out what the heck you did to the script :tongue: if I ever upload this to the nexus ill be sure to credit you fully :D

Edited by ajs52698
Link to comment
Share on other sites

I already explained assignment in my other posts, but a quick run down on what else I did:

There is no "HasEverBeenCleared" though I think you wrote that in frustration :P.
isCleared() when checking if a location is cleared.

FindAllReferencesOfType() returns an array, and will take formlists as the thing to fill an array with. Then you can do stuff with the array, like get its length(how many were found or added to the array). From there I was able to call IsDead on the array variable and cast the array as actor, since all the forms in the formlist were actors. You never needed to get the size of the formlist and do additional stuff.

A breakdown of the While loop:

It checks every actor if any of them are dead, skipping those that are, and changing the race of those that aren't. Each one that is dead or not dead, i increases by 1, thereby going to the next index in the array, starting from index 0.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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