Jump to content

I'm having trouble with this script


Recommended Posts

In the mod I am working on you are being followed by an npc. Once you reach a certain point in the dungeon she betrays you and stabs you in the back from behind. I wanted to simulate that by causing a sudden and dramatic drop in the players health as well as a message box explaining what happened followed by a short conversation with the npc and then an actual fight.

 

I've been looking over a lot of the scripts for traps and trying to adapt them to a trigger box. So far I haven't been able to get it to do anything no matter what I do. This is a script from a trap that is self activated, the only difference is the OnTrigger since it's on a trigger box. It seems to work fine with the actual trap of course, but fails to function in anyway at all on a trigger box.

 

What am I doing wrong?

 

 

 
Scn AAs2hlidAntoinettaBackStapScript

short  init
float fTrapDamage
float fLevelledDamage
float fTrapPushBack
float fTrapMinVelocity
short bTrapContinuous

begin OnTrigger

if init == 0

	; set up the damage values
	set fTrapDamage to 15
	set fLevelledDamage to 1.5
	set fTrapPushBack to 0
	set fTrapMinVelocity to 20
	set bTrapContinuous to 0

	set init to 1

endif

end

 

Link to comment
Share on other sites

Your script looks like a triggerbox script that would be parented to a trap. Your script does not cast any spells or modify the players stats, so it doesn't do anything. The only commands it issues are related to how the trap it is to be parented to will behave.

 

Your trigger box would be great for setting a quest stage or delivering a message.

 

 

Scn AAs2hlidAntoinettaBackStapScript

Short DoOnce

Begin OnTrigger Player

    Message "You have been betrayed and stabbed in the back!"
    SetStage  AABetrayed 10

End

 

The quest stage could change the AI of the NPC. The message could be put in a quest update or a messagebox instead of doing it this way.

 

Doing the damage to the player is the more tricky part. It does not seem to be safe to use ModAV Health or SetAV Health in scripts because those can make permanent changes which would later have to be undone by script. A better bet would probably be to use a damage health spell. You could even name it whatever you wanted like "Knife in the Back."

 

You might even have the character who is supposedly stabbing you in the back cast the spell herself using the system used by the Court Healer in Shivering Isles for heal spells. The trigger box could set the variable triggering the spell-casting by the NPC. One problem with this might be that you would chance to be looking at the NPC during the dastardly deed and see her casting a spell rather than wielding a knife.

 

One possibility would adding the spell to the player as a harmful ability, and then having a timer remove it again. The damage would have to be slow enough that you could survive this long enough for the script to run and do its removal job.

 

One possibility would be to use

 

AABetrayerNPC.StartCombat Player

 

You could somehow get the NPC to do a lot of damage in the first blow with something like an enchanted knife, a poison, or a knife with insanely high stats. Then you could use the StopCombat command and have your conversation.

 

Or you could continue on with your earlier approach and find a trap to do the damage. Perhaps you could have a script tell a nearby object to cast a ranged damage health spell at the player at the appropriate time. I have made things like chests and doors and apples cast spells before.

 

I am sure you will find some way to do what you are trying to do.

Edited by David Brasher
Link to comment
Share on other sites

Thanks for the help, you gave me some good ideas. I suppose I don't quite understand how traps work then. I made a trap in my last mod, "Edgars Little secrect", and adjusted the various things in the script that I first posted in order to change it's damage. Because of my previous experience with this I assumed that it was the script dealing the damage. It seem you are right that the script just modifies the damage of the trap, and that is why my trigger box does nothing. It can not deal damage anyways.

 

I think I would prefer the spell casting idea, though I am worried about the player being able to absorb or reflect the damage. I'm also worried about not being able to "level" the damage taken by the player. I want the damage to be a good portion of the players health regardless of level. That is what is still appealing about the trap script. Im not certain yet if I can do the same with a spell.

 

Anyways, thanks for the help. It gave me another direction to pursue

Link to comment
Share on other sites

If you don't mind making your mod OBSE dependent, you can try using ModAV2. It doesn't have the complications of SetAV or ModAV.

 

Or if you'd rather not use OBSE, I guess you'll have to use spells as what has been suggested. Maybe something like this?

 

 

scn example

short initialize
short dialogue
short phealth

Begin GameMode

if (initialize == 0) && (GetDistance Player < 50)
	set initialize to 1
	set phealth to (0.25 * Player.GetAV Health)
	TriggerHitShader 5
	Player.AddSpell "some constant damage health ability"
	Antoinetta.StartConversation Player, BetrayalTopic
endif

if (initialize == 1)
	if (GetAVHealth <= phealth)
		Player.RemoveSpell "some constant damage health ability"
		set initialize to 2
	endif
endif

if (dialogue == 1)
	Antoinetta.ModDisposition Player -100
	Antoinetta.StartCombat Player
	set dialogue to 2
endif

End

Begin MenuMode 1009

if (initialize > 0) && (dialogue == 0)
	set dialogue to 1
endif

End

 

 

(I've never used a trigger box before, so that's what I'd use for a script attached to an X marker.)

Link to comment
Share on other sites

Thanks, fg109. I am not opposed to using obse. It's just so hard to find the commands you want sometimes when you have such a large list in the vanilla cs and then begin adding on more from things like obse. I will look in to what you suggested!

 

edit: I am probably going to use something very similar to that script. As a result, your name will be among the credits list.

Link to comment
Share on other sites

If anyone is interested, this is the final script I developed. It only includes the damage portion, I haven't put in the messages or anything to start the conversation yet. It uses two functions from obse to accomplish exactly what I was looking for.

 

Thanks to everyone who helped out!

 

 

Scn AAs2hlidAntoinettaBackStabScript

short backstab
short phealth 
Short DoOnce

Begin GameMode
;This sets up a percent of the players health that will be damaged, that way it is proportional to the ammount of health you have, no matter your level
If (Player.GetInCell AAs2hlidSewrsChaseEnd == 1) && (DoOnce == 0)
		set phealth to (-0.33 * Player.GetAVC 8) 
		Set DoOnce to 1
EndIf

End

Begin OnTrigger Player
;This actually does whatever damage phealth is set to by the script above
if (backstab == 0) && (GetStage AAs2hlidAssassinQueenQuest == 36)
	set backstab to 1 
	TriggerHitShader 5 
	Player.ModActorValueC 8, Phealth
EndIf

End 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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