Jump to content

Hostile Summon Script Help?


JerisEnigma

Recommended Posts

A while back, I built a small mod that taught a spell to summon a demon, while also adding a hidden perk that would summon a player-hostile version when they were at low health.

 

Since I know next to nothing about scripting, the old version was hacked clumsily together from Avoid Death & Konahrik's Privilege's scripts.
It worked correctly, as far as casting the spells, but the negative summon was never hostile to the player. I learned later that this is because hostile "summons", like from the Atronach Forge, are actually placed via script, rather than conventionally summoned.
This time around, I copied & edited the same scripts, later incorporating bits from Dragonborn's Dremora Merchant script.
Again, the rebuilt AD/KP version works fine as written, just no intended hostility. The newer version is meant to pull the NPC from its cell and fight the player, but while it DOES compile successfully, it doesn't seem to work during testing. Nothing is spawned in, and adding a second set of lines to move the NPC BACK to the cell causes errors that prevent compiling.
I'll post all 3 versions below. Any input would be massively appreciated. <3
Just keep in mind that you're talking to an idiot script-wise, so posting lines of code will get across better than trying to explain that I should closing a function or something :wink:
Working, non-hostile code:
Scriptname _TESTSummonBadEndScript extends ActiveMagicEffect  

actor property selfRef auto hidden
float Property PercentHealth = 100.0 Auto  
float property HPthreshold = 0.20 auto
float property effectChance = 0.90 auto

EVENT OnEffectStart(Actor Target, Actor Caster)
	
	selfRef = caster
	
endEVENT

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked )
; ;	debug.trace(self + " Enter Bleedout");	
	if (selfRef.getActorValuePercentage("Health") < HPthreshold)
		; cast badend spell
		PercentHealth = GetTargetActor().GetAVPercentage("Health")
		If PercentHealth < 0.6
			BadEndSpell.Cast(GetTargetActor())
		EndIf
		if (selfRef.getActorValuePercentage("Health") > HPthreshold)
	EndIf
EndIf

endEvent

Spell Property BadEndSpell  Auto   
Compiled, broken code:
Scriptname _TESTSummonBadEndScript extends ActiveMagicEffect  

actor property selfRef auto hidden
float Property PercentHealth = 100.0 Auto  
float property HPthreshold = 0.20 auto
float property effectChance = 0.90 auto
ObjectReference Property _TESTSummonNPCHostile  Auto  

EVENT OnEffectStart(Actor Target, Actor Caster)
	
	selfRef = caster
	
endEVENT

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked )
; ;	debug.trace(self + " Enter Bleedout");	
	if (selfRef.getActorValuePercentage("Health") < HPthreshold)
		PercentHealth = GetTargetActor().GetAVPercentage("Health")
		If PercentHealth < 0.6
			_TESTSummonNPCHostile.Moveto(game.GetPlayer())
		EndIf
		if (selfRef.getActorValuePercentage("Health") > HPthreshold)
	EndIf
EndIf

endEvent

Final, uncompilable version:
Scriptname _TESTSummonBadEndScript extends ActiveMagicEffect  

actor property selfRef auto hidden
float Property PercentHealth = 100.0 Auto  
float property HPthreshold = 0.20 auto
float property effectChance = 0.90 auto
ObjectReference Property _TESTSummonNPCHostile  Auto  
ObjectReference Property _TESTSummonStorageMarker  Auto  

EVENT OnEffectStart(Actor Target, Actor Caster)
	
	selfRef = caster
	
endEVENT

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked )
; ;	debug.trace(self + " Enter Bleedout");	
	if (selfRef.getActorValuePercentage("Health") < HPthreshold)
		PercentHealth = GetTargetActor().GetAVPercentage("Health")
		If PercentHealth < 0.6
			_TESTSummonNPCHostile.Moveto(game.GetPlayer())
		EndIf
		if (selfRef.getActorValuePercentage("Health") > HPthreshold)
	if (selfRef.getActorValuePercentage("Health") > HPthreshold)
		PercentHealth = GetTargetActor().GetAVPercentage("Health")
		If PercentHealth > 0.6
			_TESTSummonNPCHostile.Moveto(_TESTSummonStorageMarker)

	EndIf
EndIf

endEvent

Edited by JerisEnigma
Link to comment
Share on other sites

  • Recently Browsing   0 members

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