Jump to content

Scripts on npc's by ll'd spawner


Recommended Posts

So, I learned that if I have a level list spawner and it spawns an NPC that has a script that disables it, the spawner actually gets disabled. Annoying, but manageable.

 

However, I have a script that randomizes a bunch of stats on certain npc's that can be spawned by the spawner, will those modvalue's/perks added carry over to other npc's when the respawner goes through its reset?

 

Here's a condensed snippet of what I mean. I add perks based on the luck, for example. Do I need to "undo" all this stuff on unload?

 

Scriptname blah extends Actor 
{Randomizes special stats on load}
 
;Set up actor values for modification
ActorValue property Strength Auto
ActorValue Property Perception Auto 
ActorValue Property Endurance Auto 
ActorValue Property Charisma Auto 
ActorValue Property Intelligence Auto
ActorValue Property Agility Auto
ActorValue Property Luck Auto 
 
; Set up other we need. I can likely remove level here.
ActorValue Property HealthAV Auto 
int Level
float LuckTotal
;Crippling values for awful Luck
ActorValue Property LeftMobilityCondition Auto
ActorValue Property RightMobilityCondition Auto 
 
Event OnInit()
 
Modvalue(Strength, Utility.RandomFloat(2.0, 10.0))
Modvalue(Perception, Utility.RandomFloat(2.0, 10.0))
Modvalue(Endurance, Utility.RandomFloat(2.0, 10.0))
Modvalue(Charisma, Utility.RandomFloat(2.0, 10.0))
Modvalue(Intelligence, Utility.RandomFloat(2.0, 10.0))
Modvalue(Agility, Utility.RandomFloat(2.0, 10.0))
Modvalue(HealthAV, GetValue(Endurance)*10.0)
 
;Luck for other bonus calculation
Modvalue(Luck, Utility.RandomFloat(0.0, 10.0)) 
LuckTotal = GetValue(Luck)
 
if LuckTotal < 1.0
 
elseif LuckTotal < 6.0
 
elseif LuckTotal < 7.0
 
elseif LuckTotal < 8.0
 
elseif LuckTotal < 9.0
 
elseif LuckTotal < 10.0
 
elseif LuckTotal < 11.0
 
elseif LuckTotal > 10.0
 
EndIf
 
endEvent
Edited by PhanomGames
Link to comment
Share on other sites

If that script is attached to the Actor (actually ActorBase) form, each instance of that ActorBase that is spawned will have its own instance of the script with its own variables.

 

A child script/object disabling itself will not disable the parent script/object unless you tell it to.

Link to comment
Share on other sites

If that script is attached to the Actor (actually ActorBase) form, each instance of that ActorBase that is spawned will have its own instance of the script with its own variables.

 

A child script/object disabling itself will not disable the parent script/object unless you tell it to.

Ok, thanks for the clarification. Was worried considering I get tons of these warnings generated and I couldn't figure out why the game thinks it's a problem to have scripted actors in the level lists for spawns.

 

MASTERFILE: LVLN 'LCharRaiderLegendary' (00184756) LeveledCharacter 'LCharRaiderLegendary' (00184756) contains scripted actors.
Remove actor 'EncRaider01Template' (0003183A).
A similar script to the one I posted is attached to the encraider01template, in this case.
Link to comment
Share on other sites

OK right you should not do that. I assumed your spawner was a script.

 

The sequence is ENC > LChar > LVL and scripts should be attached to the LVL actors not the lower level ENC actors used by the Lchar lists.

 

Edit: follow a base game asset like EncWorkshopNPCMaleFarmer01Template > LCharWorkshopNPC > WorkshopNPC

Edited by SKK50
Link to comment
Share on other sites

Ok, that sucks but not too hard to fix from what I've already done. So anything done/added to a lvlchar won't propogate to other actors when the level list spawner resets, great to know.

 

Will they cleared if a cell resets as well? For example if I go to an area, an NPC spawns and runs that script, if I leave and come back 30 in game days later, nothing from that script should still be in effect, and it will be re-ran on him, right?

 

Thanks for the help on this.

Link to comment
Share on other sites

I have never tested reset persistence on loose spawned actors so dont absolutely know.

 

To avoid building up detritus in games, my mods always hold any spawned actors in a quest reference collection so I can manage their actions, state and cleanup. That makes them persistemt so a reset will not affect them.

 

I was thinking about WorkshopNPCs spawned by the recruitment beacon, but, as settlement zones are marked no reset they dont help.

 

be interested in the answer...

Link to comment
Share on other sites

  • 1 month later...

Finally had time to mess with this, start polishing and reworking parts. Interestingly for what I wanted to accomplish, it seems like doing it the way I have works just like I wanted it to. I wanted to have the base actors of every type have scripts on them (which are inherited by their derived actors) that do different things based on race/equipment etc.

 

Cell resets properly reset all the variables on them, and each actor has unique properties. Their properties are saved on unload/load as well, so while it makes the saves marginally bigger, it gives persistence to their stats until cell reset (Which is good).

 

The use case for this is that I have scripts for different races on each base actor type, shove them all in random level lists/spawners are placed using those level lists. This allows me to (for example) have global variables for number of raiders there are in the world, and killing them impacts the scripts the remaining raiders have (reading from that global). So if you go on a huge purge of raiders, for example, you can wipe them from areas of the map by removing them on spawn if that global's too low.

Edited by PhanomGames
Link to comment
Share on other sites

Hmm, I have a similar issue, mine is far more simple but Confusing to me because I can't understand how scripts work. lol.

 

So, I added a script to an NPC that is inside a Lvl list. It was supposed to spawn with crippled limbs. Console spawning it works fine but when spawned from the lvl list the script doesn't work.

 

So, I need to apply script to the lvl actor not the enc actor if I understand correctly?

 

It was hard for me to test because I made the actor very rare.. but in hindsight I could have made it common while testing, didn't even think to do that. But I have seen now that it spawns and walks normally.

Link to comment
Share on other sites

Exact same use case as what I put in the top? If you want every actor of that type to always have the script, it seems like enc will work fine. I can post some code for it when I get home.

If you want only ones spawned through your ll to have it, then yes.

I think you're hitting a different issue though. I noticed while testing my luck debuffs (one of which is damaged limbs) they'd have full limb hp if I set it to 0 or less by mobilitycondition. I have to set it to 1% then damage the limb another 1%

Scriptname CU_RandomizeSpecialStats extends Actor 
{Randomizes special stats on load}
 
;Set up actor values for modification
ActorValue property Strength Auto
ActorValue Property Perception Auto 
ActorValue Property Endurance Auto 
ActorValue Property Charisma Auto 
ActorValue Property Intelligence Auto
ActorValue Property Agility Auto
ActorValue Property Luck Auto 
 
; Set up other we need. I can likely remove level here.
ActorValue Property HealthAV Auto 
int Level
float LuckTotal
;Crippling values for awful Luck
ActorValue Property LeftMobilityCondition Auto
ActorValue Property RightMobilityCondition Auto 
 
Event OnInit()
 
Modvalue(Strength, Utility.RandomFloat(2.0, 10.0))
Modvalue(Perception, Utility.RandomFloat(2.0, 10.0))
Modvalue(Endurance, Utility.RandomFloat(2.0, 10.0))
Modvalue(Charisma, Utility.RandomFloat(2.0, 10.0))
Modvalue(Intelligence, Utility.RandomFloat(2.0, 10.0))
Modvalue(Agility, Utility.RandomFloat(2.0, 10.0))
Modvalue(HealthAV, GetValue(Endurance)*10.0)
 
;Luck for other bonus calculation
Modvalue(Luck, Utility.RandomFloat(0.0, 10.0)) 
LuckTotal = GetValue(Luck)
 
if LuckTotal < 1.0
Modvalue(Strength, -1.0)
Modvalue(Perception, -1.0)
Modvalue(Endurance, -1.0)
Modvalue(Charisma, -1.0)
Modvalue(Agility, -1.0)
Modvalue(Intelligence, -1.0)
Modvalue(HealthAV, -10)
Modvalue(LeftMobilityCondition,-70)
Modvalue(RightMobilityCondition,-70)
elseif LuckTotal < 2.0
Modvalue(LeftMobilityCondition,-40)
Modvalue(RightMobilityCondition,-40)
elseif LuckTotal < 3.0
Modvalue(LeftMobilityCondition,-30)
Modvalue(RightMobilityCondition,-30)
elseif LuckTotal < 4.0 
Modvalue(LeftMobilityCondition,-20)
Modvalue(RightMobilityCondition,-20)
elseif LuckTotal < 5.0
Modvalue(LeftMobilityCondition,-10)
Modvalue(RightMobilityCondition,-10)
elseif LuckTotal < 6.0
 
elseif LuckTotal < 7.0
Modvalue(HealthAV, 5)
elseif LuckTotal < 8.0
Modvalue(HealthAV, 10)
elseif LuckTotal < 9.0
Modvalue(HealthAV, 10)
elseif LuckTotal < 10.0
Modvalue(HealthAV, 10)
elseif LuckTotal < 11.0
Modvalue(HealthAV, 10)
elseif LuckTotal > 10.0
Modvalue(HealthAV, 10)
EndIf
 
endEvent
Edited by PhanomGames
Link to comment
Share on other sites

To clear up confusion, script attachment depends on the context:

 

YES you can attach a script to an ENC actor form if it will not be used by an LChar level list.

 

You can NOT attach a script to an ENC actor form if it is used by an LChar level list to feed the templates that make a LVL actor. The script must be attached to the final LVL actor form.

 

The general sequence is ENC > LCHAR > LVL

Link to comment
Share on other sites

  • Recently Browsing   0 members

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