Jump to content

Script Editing Assistance


kingtitan

Recommended Posts

Hello again to all! I have what I hope will be a relatively easy issue to solve. I am dealing with a script right now and trying to work out a "bug" (I think it is more of a script technicality and can be fixed though). First off here is the script in question:

 

scn ATLuciferDPAbilityScript

short Activate
short Button
short DoOnce
float Timer

begin OnActivate
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	messagebox "Take the body down?" "Take it down" "Leave it up"
	set Activate to 1
else
	return
endif
end

begin GameMode
if GetFactionRank ATLuciferFaction < 1
	removespell ATLuciferAbility
endif
if IsIdlePlaying == 0
	pickidle 1
endif
if Activate == 1
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		SetActorsAI 1
		SetDestroyed 0
		SetUnconscious 0
		SetRestrained 0
		SetFactionRank ATLuciferFaction -1
		kill
		set Activate to 0
		set DoOnce to 0
		set Timer to 0
		removespell ATLuciferAbility
	elseif Button == 1
		set Activate to 0
	endif
endif
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	if IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 1 && Timer < 2
		SetUnConscious 1
	elseif IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 2
		SetActorsAI 0
		set DoOnce to 1
	elseif DoOnce == 0 && Timer < 2
		set Timer to Timer + GetSecondsPassed
	endif
endif
end

 

 

Here is the problem I am facing. This script is used to "execute" NPC's. Basically I have a pose spell that I can cast on individuals and one of the options is to execute (hanging). So, the idle activates and makes it look as if the NPC is hanging. When activated, you are given the option to "Leave it up" or "Take it down" (the body of course). When the take it down option is selected the NPC dies and falls to the ground. Then I generally use the "resurrect" console code to bring the NPC back to life. However, this is where the problems stem from. Whenever I try to talk to an NPC after resurrecting them, I am unable to do so. What needs to be edited in the above script so that I am able to talk to NPC's again after resurrecting them?

Link to comment
Share on other sites

Try adding the "Activate" command in the OnActivate block. It basically instructs the Oblivion engine to "do the default activation behaviour". Without it, the script simply quits without doing anything else.

 


begin OnActivate
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	messagebox "Take the body down?" "Take it down" "Leave it up"
	set Activate to 1
else
	Activate
	return
endif
end

 

P.S. It might be an idea to add if IsActionRef player == 1 in the OnActivate block as well just in case NPCs try to talk to your hanging victims or something equally wierd.

Link to comment
Share on other sites

Unfortunately, that did not solve the problem. I repeated the same process (after editing the script) and I still could not talk to the NPC after resurrecting them. I'm no scripter by any means but I figured the section with all the "setdestroyed" and ai commands would be the culprit.  So, I guess that would be close to the entire last section of the script. Is the script registering the NPC as unconscious even after death? Whenever I try to speak to them all that happens is that their name flashes once like it was doing beforehand. Edited by kingtitan
Link to comment
Share on other sites

It looks like the NPC's SetUnconsious state is set to 1 if he's standing around like an idiot.

 

On the surface, your script looks good, but I noticed two things happen in the same frame when the NPC is released:

 

SetFactionRank ATLuciferFaction -1

and the second bit:

 if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
               if IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 1 && Timer < 2
                       SetUnConscious 1
etc. etc.

 

I'm guessing that by the time the second bit starts running, the faction rank hasn't been changed to -1 yet (my understanding is that the script runs in entirety before it makes any changes external to the script). Try putting a Return after

removespell ATLuciferAbility

 

See if that works... if not, we'll keep trying. :)

Link to comment
Share on other sites

Here is what I changed it to:

 

scn ATLuciferDPAbilityScript

short Activate
short Button
short DoOnce
float Timer

begin OnActivate
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	messagebox "Take the body down?" "Take it down" "Leave it up"
	set Activate to 1
else
	return
endif
end

begin GameMode
if GetFactionRank ATLuciferFaction < 1
	removespell ATLuciferAbility
	return
endif
if IsIdlePlaying == 0
	pickidle 1
endif
if Activate == 1
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		SetActorsAI 1
		SetDestroyed 0
		SetUnconscious 0
		SetRestrained 0
		SetFactionRank ATLuciferFaction -1
		kill
		set Activate to 0
		set DoOnce to 0
		set Timer to 0
		removespell ATLuciferAbility
	elseif Button == 1
		set Activate to 0
	endif
endif
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	if IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 1 && Timer < 2
		SetUnConscious 1
	elseif IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 2
		SetActorsAI 0
		set DoOnce to 1
	elseif DoOnce == 0 && Timer < 2
		set Timer to Timer + GetSecondsPassed
	endif
endif
end

 

 

Same results :( It seems that when being resurrected, the game still thinks the NPC is unconscious perhaps?

Also, I don't know what kind of effect this has, but there is technically no "-1" rank in said faction when I checked.

 

This also may help. It is the script that applies to the spell:

 

scn ATLuciferQuestScript

ref Target
short Activate
short DoOnce
short Chapter
short Button
short Reset
float fQuestDelayTime

begin GameMode
if Activate == 0
	return
elseif Target == 0
	set Activate to 0
	return
endif
if Reset == 1
	Target.pickidle
	set Target to 0
	set Chapter to 0
	set Activate to 0
	set Reset to 0
	return
endif
if DoOnce == 0
	set fQuestDelayTime to 0.01
	set DoOnce to 1
endif
if Chapter == 0
	messagebox "Choose thy pose wisely" "I shall have none of it!" "Chains" "Woodworks" "Poles" "Execute" "At ease"
	set Chapter to 1
elseif Chapter == 1
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		set Reset to 1
	elseif Button == 1
		messagebox "Chain poses" "None of it, I say!" "Stand hands behind" "Chained to floor" "Chained to wall" "Kneel hands behind" "Sit hands behind" "Stand hands behind" "Sitting chained to floor" "Stand hands infront" "Chain lift"
		set Chapter to 2
	elseif Button == 2
		messagebox "Woodwork poses" "None of it, I say!" "Chair hands behind" "Chair hands infront" "Chained to table" "Stockade hands behind" "Stockade hands infront" "Pillory kneel" "Pillory stand" "Board to wall"
		set Chapter to 3
	elseif Button == 3
		messagebox "Pole poses" "None of it, I say!" "Chain hands above" "Chain hands behind"  "Chain kneeling" "Chain large pole" "Kneeling pole on shoulders" "Cage sit" "Cage stand"
		set Chapter to 4
	elseif Button == 4
		messagebox "Executions" "None of it, I say!" "Behead" "Crucify" "Hang from gallow" "Hang from pole"
		set Chapter to 5
	elseif Button == 5
		Target.SetFactionRank ATLuciferFaction -1
		if Target.IsSpellTarget ATLuciferAbility == 1
			Target.removespell ATLuciferAbility
		endif
		if Target.GetRestrained == 1
			Target.SetRestrained 0
		endif
		if Target.GetDestroyed == 1
			Target.SetDestroyed 0
		endif
		if Target.GetIsGhost == 1
			Target.SetGhost 0
		endif
		If Target.GetUnconscious == 1
			Target.SetUnconscious 0
		endif
		Target.pickidle
		set Reset to 1
	endif
elseif Chapter == 2
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		set Chapter to 0
	elseif Button == 1
		Target.SetFactionRank ATLuciferFaction 7
	elseif Button == 2
		Target.SetFactionRank ATLuciferFaction 9
	elseif Button == 3
		Target.SetFactionRank ATLuciferFaction 12
	elseif Button == 4
		Target.SetFactionRank ATLuciferFaction 14
	elseif Button == 5
		Target.SetFactionRank ATLuciferFaction 15
	elseif Button == 6
		Target.SetFactionRank ATLuciferFaction 16
	elseif Button == 7
		Target.SetFactionRank ATLuciferFaction 17
	elseif Button == 8
		Target.SetFactionRank ATLuciferFaction 18
	elseif Button == 9
		Target.SetFactionRank ATLuciferFaction 19
	endif
	if Button >= 1 && Button <= 9
		if Target.IsSpellTarget ATLuciferAbility == 0
			Target.addspell ATLuciferAbility
		endif
		Target.SetRestrained 1
		set Reset to 1
		return
	endif
elseif Chapter == 3
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		set Chapter to 0
	elseif Button == 1
		Target.SetFactionRank ATLuciferFaction 2
	elseif Button == 2
		Target.SetFactionRank ATLuciferFaction 3
	elseif Button == 3
		Target.SetFactionRank ATLuciferFaction 8
	elseif Button == 4
		Target.SetFactionRank ATLuciferFaction 10
	elseif Button == 5
		Target.SetFactionRank ATLuciferFaction 11
	elseif Button == 6
		Target.SetFactionRank ATLuciferFaction 23
	elseif Button == 7
		Target.SetFactionRank ATLuciferFaction 24
	elseif Button == 8
		Target.SetFactionRank ATLuciferFaction 30
	endif
	if Button >= 1 && Button <= 8
		if Target.IsSpellTarget ATLuciferAbility == 0
			Target.addspell ATLuciferAbility
		endif
		Target.SetRestrained 1
		set Reset to 1
		return
	endif
elseif Chapter == 4
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		set Chapter to 0
	elseif Button == 1
		Target.SetFactionRank ATLuciferFaction 20
	elseif Button == 2
		Target.SetFactionRank ATLuciferFaction 25
	elseif Button == 3
		Target.SetFactionRank ATLuciferFaction 26
	elseif Button == 4
		Target.SetFactionRank ATLuciferFaction 32
	elseif Button == 5
		Target.SetFactionRank ATLuciferFaction 28
	elseif Button == 6
		Target.SetFactionRank ATLuciferFaction 5
	elseif Button == 7
		Target.SetFactionRank ATLuciferFaction 6
	endif
	if Button >= 1 && Button <= 7
		if Target.IsSpellTarget ATLuciferAbility == 0
			Target.addspell ATLuciferAbility
		endif
		Target.SetRestrained 1
		set Reset to 1
		return
	endif
elseif Chapter == 5
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		set Chapter to 0
	elseif Button == 1
		Target.SetFactionRank ATLuciferFaction 1
	elseif Button == 2
		Target.SetFactionRank ATLuciferFaction 4
	elseif Button == 3
		Target.SetFactionRank ATLuciferFaction 21
	elseif Button == 4
		Target.SetFactionRank ATLuciferFaction 27
	endif
	if Button >= 1 && Button <= 4
		if Target.IsSpellTarget ATLuciferAbility == 0
			Target.addspell ATLuciferAbility
		endif
		Target.SetRestrained 1
		Target.pickidle
		set Reset to 1
		return
	endif
endif
end

 

 

I have no idea if that will be of any help though. Let me know if I can provide any more info to solve this!

Link to comment
Share on other sites

What I meant was this:

 

scn ATLuciferDPAbilityScript

short Activate
short Button
short DoOnce
float Timer

begin OnActivate
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	messagebox "Take the body down?" "Take it down" "Leave it up"
	set Activate to 1
else
	return
endif
end

begin GameMode
if GetFactionRank ATLuciferFaction < 1
	removespell ATLuciferAbility
endif
if IsIdlePlaying == 0
	pickidle 1
endif
if Activate == 1
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		SetActorsAI 1
		SetDestroyed 0
		SetUnconscious 0
		SetRestrained 0
		SetFactionRank ATLuciferFaction -1
		kill
		set Activate to 0
		set DoOnce to 0
		set Timer to 0
		removespell ATLuciferAbility
		Return				; <------ ##### Over here! #####
	elseif Button == 1
		set Activate to 0
	endif
endif
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	if IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 1 && Timer < 2
		SetUnConscious 1
	elseif IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 2
		SetActorsAI 0
		set DoOnce to 1
	elseif DoOnce == 0 && Timer < 2
		set Timer to Timer + GetSecondsPassed
	endif
endif
end

 

:thumbsup:

Link to comment
Share on other sites

Oh well that makes more sense, just looked at the wrong spot. Unfortunately though, I still could not talk to the NPC after resurrecting them from hanging. Is there anymore information I might be able to provide?

 

I am currently trying to contact my friend that wrote this for me, he just hasn't been on the forums recently.

Link to comment
Share on other sites

Just to clarify (and update the "in-use" script), this is what I am looking at right now:

 

scn ATLuciferDPAbilityScript

short Activate
short Button
short DoOnce
float Timer

begin OnActivate
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	messagebox "Take the body down?" "Take it down" "Leave it up"
	set Activate to 1
else
	return
endif
end

begin GameMode
if GetFactionRank ATLuciferFaction < 1
	removespell ATLuciferAbility
endif
if IsIdlePlaying == 0
	pickidle 1
endif
if Activate == 1
	set Button to GetButtonPressed
	if Button == -1
		return
	elseif Button == 0
		SetActorsAI 1
		SetDestroyed 0
		SetUnconscious 0
		SetRestrained 0
		SetFactionRank ATLuciferFaction -1
		kill
		set Activate to 0
		set DoOnce to 0
		set Timer to 0
		removespell ATLuciferAbility
		return
	elseif Button == 1
		set Activate to 0
	endif
endif
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	if IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 1 && Timer < 2
		SetUnConscious 1
	elseif IsIdlePlaying == 1 && DoOnce == 0 && Timer >= 2
		SetActorsAI 0
		set DoOnce to 1
	elseif DoOnce == 0 && Timer < 2
		set Timer to Timer + GetSecondsPassed
	endif
endif
end

 

 

I left the new return command in the script (as it didn't really seem to change anything unfortunately). I'm trying to figure out what portion of the script seems to be lingering and rendering the NPC unable to be able to activate.

 

I also just read this from here: http://cs.elderscrolls.com/index.php/SetDestroyed

SetDestroyed takes an int parameter. A 1 parameter marks the ref as destroyed, a 0 parameter clears the destroyed flag on the ref. This can be used on any door or activator to indicate that it is non-functional. Destroyed doors/activators will no longer give rollover text and cannot be activated. Leveled lists will no longer generate new creatures/ items.

 

Notes:

 

  • When called on an actor, prevents the actor from being activated for conversation, looting, or pick pocketing.

Edited by kingtitan
Link to comment
Share on other sites

Try re-adding the "Activate" command in the OnActivate block as without it, there will definitely be problems interacting with the NPC.


begin OnActivate
if GetFactionRank ATLuciferFaction == 4 || GetFactionRank ATLuciferFaction == 21 || GetFactionRank ATLuciferFaction == 27
	messagebox "Take the body down?" "Take it down" "Leave it up"
	set Activate to 1
else
	Activate		; <-----------------------------------
	return
endif
end

Link to comment
Share on other sites

  • Recently Browsing   0 members

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