Jump to content

How to SetProtected with Script


larsepan

Recommended Posts

I'm working on a mortal NPC follower.

 

The conundrum: An - IsProtected 0 NPC >> becomes an IsProtected 1 NPC - when following. I could set their healrate / magickarate to zero, and sure the rates will remain the same. However, there appears to be a bonus regen rate for active followers. I guessed that this had to be because of the additional protected status.

 

So I tried to test it out:

 

In game, I thought I'd try something like - SetProtected NPC 0 - but nope. SetProtected doesn't seem to be a command.

 

In CK, I thought I'd try to compile something like - actorProperty.SetProtected(false) - but nope. SetProtected doesn't appear to be a function.

 

Huh. Any ideas?

Link to comment
Share on other sites

 

SetProtected requires using the ActorBase rather than the specific actor. You'll need to use GetActorBase on the actor first before calling SetProtected. Something like:

myActor.GetActorBase().SetProtected(false)

Right. Much like SetEssential ActorBase 1 etc. It's just that SetProtected ActorBase 1 doesn't appear to exist as a console command. Plus, I had thought that ActorBase would be the script requirement, but this CK page confused me regarding Actor.

 

Link to comment
Share on other sites

This is a snippet of the script I made to toggle an NPC between Protected/UnProtected status:

function OnEffectStart(Actor Target, Actor Caster)

	actorbase TargetBase = Target.GetActorBase()
	if TargetBase.IsProtected() == false
		TargetBase.SetProtected(1 as Bool)
		debug.MessageBox("Target is Protected.")
	else
		TargetBase.SetProtected(0 as Bool)
		debug.MessageBox("Target is Not Protected.")
	endIf
endFunction
Link to comment
Share on other sites

 

This is a snippet of the script I made to toggle an NPC between Protected/UnProtected status:

function OnEffectStart(Actor Target, Actor Caster)

	actorbase TargetBase = Target.GetActorBase()
	if TargetBase.IsProtected() == false
		TargetBase.SetProtected(1 as Bool)
		debug.MessageBox("Target is Protected.")
	else
		TargetBase.SetProtected(0 as Bool)
		debug.MessageBox("Target is Not Protected.")
	endIf
endFunction

Nice spell!

 

I made a quick Mortality config thanks to both your help. It works fine to toggle protected on and off. It does seem that NPCs, while following, don't appear to be using their ActorBase protected settings. Is that right?

 

Some testings:

 

(1) Before following: NPC has 0 for Protected.

(2) Before following: Use dialogue to change ActorBase Protected value to true.

(3) Before following: Disable/Enable NPC - NPC has 1 for Protected.

(4) During following: NPC has 1 for Protected.

(5) During following: Use dialogue to change ActorBase Protected value to false.

(6) During following: Disable/Enable NPC - NPC has 1 for Protected.

(7) Ungroup NPC: NPC has 0 for Protected.

 

(Edit: Just for more context)

(1) Before following: NPC has 0 for Protected.

(2) During following: NPC has 1 for Protected.

(3) Ungroup NPC: NPC has 0 for Protected.

 

Interesting, eh?

Edited by larsepan
Link to comment
Share on other sites

  • Recently Browsing   0 members

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