Jump to content

Scripting Problem


kieranfoy

Recommended Posts

Right, so I'm makiing an epic dungeon with a fancy scripted sword at the end as a reward, and I've gotten a script together that I know should work.

 

Most of it does, but the bit that specifies that the player not be affected by the enchantment (suck to have it reflected, and your own head chopped off) seems to be buggy. The CS keeps saying 'unknown variable 'target', when I've seen this bit of scripting work in other mods.

 

The script is this:

 

scriptname 1reaper

 

 

 

begin scripteffectstart

set Target to getself

If GetRandomPercent > 95

If Target != Player ;

if isSpellTarget 11reaperdecap == GetIsPlayableRace

triggerhitshader 10

additem reaperhead 1

equipitem reaperhead

player.additem headcutreaper 1

pickidle

playsound PHYDamageFlesh

playsound ENDDagonRoarDeath01

ForceAV Health 0

message "Reaper has claimed another soul!"

endif

endif

endif

end

 

 

 

 

Although the Nexus kinda screws it up. If someone could help me unbug the script, I'd be very grateful; not to mentin you'd get credit for your help and a kudo.

 

Also: please do not steal this script. Not sure if I can stop you, but I worked very hard on it, and it's my first scipt ever, so please, respect that.

 

Thank you for paying attention.

Link to comment
Share on other sites

You need to declare a variable before you can use it:

 

scriptname 1reaper

Ref Target


begin scripteffectstart
set Target to getself
If GetRandomPercent > 95
	If Target != Player
		if isSpellTarget 11reaperdecap == 1 && Target.GetIsPlayableRace == 1
			triggerhitshader 10
			additem reaperhead 1
			equipitem reaperhead
			player.additem headcutreaper 1
			pickidle
			playsound PHYDamageFlesh
			playsound ENDDagonRoarDeath01
			Target.kill
			message "Reaper has claimed another soul!"
		endif
	endif
endif
end

 

I also changed "if isSpellTarget 11reaperdecap == GetIsPlayableRace" to "if isSpellTarget 11reaperdecap == 1 && Target.GetIsPlayableRace == 1", because that function returns a boolean (0 or 1). (Though having a function return another function makes no sense either. :P )

 

And instead of setting the actors health to 0, use "kill". It's more reliable.

 

I may have missed something as I'm not 100% what exactly you're trying to accomplish. Is it supposed to affect every actor but not the PC, or something entirely different?

 

[EDIT]Also, starting your script's name with a number can cause problems, so it's best to avoid doing that.

Link to comment
Share on other sites

Oh, thank you.

 

It's supposed to affect every NPC except your character, becuase that would make the fight I intend even trickier than normal.

 

It literally has the sword in question decapitate the enemy, chopping off their head (actually, equipping an invisible piece of headgear) and adding an item called 'Victim's Severed Head' to your inventory.

Link to comment
Share on other sites

Ah, I see.

scriptname reaper1

Ref Target


begin scripteffectstart

set Target to getself
If GetRandomPercent > 95
If Target != Player
	If Target.GetIsPlayableRace == 1
		triggerhitshader 10
		additem reaperhead 1
		equipitem reaperhead
		player.additem headcutreaper 1
		playsound PHYDamageFlesh
		playsound ENDDagonRoarDeath01
		Target.kill
		message "Reaper has claimed another soul!"
	endif
endif
endif
end

 

I removed IsSpelltarget because it isn't necessary here, and I removed PickIdle because it's pointless as the target will be killed within the same frame.

 

If it doesn't work like it should, tell me.

 

[EDIT]One more thing, while the GetIsPlayableRace call is necessary to make sure it doesn't run if hitting a creature, it won't work if the NPC's race is unplayable, which will prevent it from working on Dremora, for example.

Link to comment
Share on other sites

Ah, I see.

 

I removed IsSpelltarget because it isn't necessary here, and I removed PickIdle because it's pointless as the target will be killed within the same frame.

 

If it doesn't work like it should, tell me.

 

[EDIT]One more thing, while the GetIsPlayableRace is necessary to make sure it doesn't run if hitting a creature, it won't work if the NPC's race is unplayable, which will prevent it from working on Dremora, for example.

Ah, thank you. Yes, this looks far more professional. I'll jump on into the game, and have whirl.

 

And, yeah, I know, but I know of no other way to keep from decapitating rats. Anyway, a lot of people have playable Dremora mods, and in my experience with this script's predecessots, it will work even if the raceis made playable by a different ESP.

Link to comment
Share on other sites

If you don't mind, I think I will improve the script even further:

ScriptName reaper1

Ref Target

begin ScriptEffectStart

If GetRandomPercent <= 95
Return
Else
set Target to GetSelf
If Target == Player
	Return
Else
	If Target.GetIsCreature == 1
		Return
	Else
		TriggerHitShader 10
		AddItem reaperhead 1
		EquipItem reaperhead
		Player.AddItem headcutreaper 1
		PlaySound PHYDamageFlesh
		PlaySound ENDDagonRoarDeath01
		Target.Kill Player
		message "Reaper has claimed another soul!"
	endif
endif
endif

end

 

Basically, I replaced GetIsPlayableRace with GetIsCreature so that even unplayable races can have their heads severed. Besides that, I added a few Return commands so that the script doesn't do unnecessary processing if an If condition returns false. I also modified the Kill command slightly so that the player becomes responsible for the actor's death. And lastly, I also capitalised some words to make it easier on the eyes.

Link to comment
Share on other sites

If you don't mind, I think I will improve the script even further:

Thanks, but the getisplayablerace was there for a reason. You see, even if it kills a creature, it won't be able to make their head vanish, which was the whole point.

 

Thanks for the other bits, though.

Link to comment
Share on other sites

My script improvement isn't going to let your sword decapitate creatures, it will let you decapitate anything EXCEPT creatures.

 

		If Target.GetIsCreature == 1
		Return
	Else
		...

means that if the target is a creature, the script is ignored.

 

In other words, it will decapitate playable (argonian, khajiit, imperial, elf, etc) and non-playable (dremora, etc) races as opposed to the previous script which only decapitates playable races.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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