Trigger Box to Detect Player Shout

Post » Mon Nov 19, 2012 10:36 pm

At a certain stage of my quest, the player must insert two ingredients (an amulet and a gem) inside a container and then use Unrelenting Force shout on the container.

At that point, (1) the ingredients should be removed from the container (2) a new enchanted amulet should be added to the container and (3) the quest stage should be updated.

I used the http://pastebin.com/raw.php?i=YmUH7DYx as a base for the following custom script, which I've attached to a trigger box surrounding the container: http://pastebin.com/raw.php?i=ucww4Dj8
Spoiler

Scriptname ST_DovahMirShoutTriggerScript extends ObjectReference {script to detect hit by Unrelenting Force}; spells that can trigger this (Unrelenting Force 1, 2 or 3)Spell property triggerSpell1 auto		Spell property triggerSpell2 auto		Spell property triggerSpell3 auto		;ContainerObjectReference Property MyChest Auto;Quest ST_DovahMir01 Quest Property MyQuest1  Auto;Amulet of TalosArmor Property AmuletofTalos  Auto  ;Aetherium PieceMiscObject Property Aetherium  Auto  ;Amulet of Dovah MirArmor Property DovahMir Auto;Quest ST_DovahMirRepeatableQuest Property myQuest2  Auto  ;************************************auto State Waiting		Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)		Spell akSpell = akSource as Spell 		Debug.Notification("shout trigger event started") 		if akSpell			if(MyChest.GetItemCount(AmuletofTalos) >= 1 && MyChest.GetItemCount(Aetherium) >= 1 )			Debug.Notification("Chest Has at least 1 Amulet of Talos & 1 Aetherium Piece")				if (triggerSpell1 && akSpell == triggerSpell1) || (triggerSpell2 && akSpell == triggerSpell2) || (triggerSpell3 && akSpell == triggerSpell3)					MyChest.RemoveItem(AmuletofTalos, 1) && MyChest.RemoveItem(Aetherium, 1)					Debug.Notification("amulet and aetherium removed from chest")					MyChest.AddItem(DovahMir, 1)					Debug.Notification("dovah mir added to chest")					if (MyQuest1.GetStage() > 40)					Debug.Notification("DovahMir01 stage is greater than 40")						MyQuest1.setstage(70)						Debug.Notification("Shout trigger script set non-repeatable stage to 70")						; disable myself						;Disable()						;Debug.Notification("Trigger box disabled") 					endif					if (MyQuest2.GetStage() > 20)					Debug.Notification("DovahMirRepeatable stage is greater than 20")						MyQuest2.SetStage(40)						Debug.Notification("Shout trigger script set repeatable quest stage to 40")						; disable myself						;Disable()						;Debug.Notification("Trigger box disabled") 					endif				endif			endif		endif	endEventendState;************************************
Everything else in the quest seems to be working except this trigger box. Nothing happens when I shout at it, regardless of whether the items have been inserted.

Any suggestions for improving the script, or perhaps a better way to test this to figure out the problem?
User avatar
Alyesha Neufeld
 
Posts: 3421
Joined: Fri Jan 19, 2007 10:45 am

Post » Mon Nov 19, 2012 7:32 pm

Have you filled in any properties needed properly?

Although you've already started, I'd have done an OnHit script on the chest itself. I find them more reliable.
User avatar
adame
 
Posts: 3454
Joined: Wed Aug 29, 2007 2:57 am

Post » Mon Nov 19, 2012 4:49 pm

Have you filled in any properties needed properly?

Although you've already started, I'd have done an OnHit script on the chest itself. I find them more reliable.

Oh, I wasn't aware that statics could detect OnHit?

Yes, I've double and triple checked the properties.

Is it possible the script is not detecting the items inserted into the container because the items I'm using are quest aliases? In the script I did not use the quest alias version for these items, because there are two different quests (one repeatable quest and one non-repeatable quest).

I was considering that perhaps I should change the script to use the aliases instead of the base object FormID, but I'd like to make it possible for players to use console commands to cheat if necessary, even if the quest isn't running.
User avatar
Alexander Horton
 
Posts: 3318
Joined: Thu Oct 11, 2007 9:19 pm

Post » Mon Nov 19, 2012 10:39 pm

Statics can't mate but other objects can, like containers. I'm sure of it anyway :)

I'd have made the chest an alias, and added the script to the alias itself.

It shouldn't matter if your condition is base objects or aliases, they are the same thing for condition purposes. Im a bit stumped tbh :shrug:
User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Tue Nov 20, 2012 8:20 am

Statics can't mate but other objects can, like containers. I'm sure of it anyway :smile:

I'd have made the chest an alias, and added the script to the alias itself.

It shouldn't matter if your condition is base objects or aliases, they are the same thing for condition purposes. Im a bit stumped tbh :shrug:

OK I will try attaching the script to the container quest alias instead.

However, there is the non-repeatable quest ST_DovahMir01 and then a repeatable quest ST_DovahMirRepeatable.

What exactly would I need to do when setting up the alias for the first quest, to make sure it can be released when that quest is completed and made available for use as an alias in the repeatable quest?
User avatar
Stephanie Valentine
 
Posts: 3281
Joined: Wed Jun 28, 2006 2:09 pm

Post » Tue Nov 20, 2012 4:08 am

Always make sure you add:

Stop()

To all your final quest stages. This ensures the quests stops and all aliases are cleared.

To make the script transferable use GetOwningQuest() in it, rather than MyQuest. That way you can use the same script for the chest alias in each quest.
User avatar
Emily Graham
 
Posts: 3447
Joined: Sat Jul 22, 2006 11:34 am

Post » Mon Nov 19, 2012 6:40 pm

Always make sure you add:

Stop()

To all your final quest stages. This ensures the quests stops and all aliases are cleared.

To make the script transferable use GetOwningQuest() in it, rather than MyQuest. That way you can use the same script for the chest alias in each quest.

Oh, thanks, that sounds like a great solution!

One question - I think I still need to use MyQuest1 and MyQuest2 as properties for the setstage function, no? (Because the stages to set and the minimum stage will be different depending on which quest is running.)

EDIT: nvm, I think I understand, the script will actually be used on the quest alias, so there is no need to use the quest as a property
User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Mon Nov 19, 2012 11:17 pm



Oh, thanks, that sounds like a great solution!

One question - I think I still need to use MyQuest1 and MyQuest2 as properties for the setstage function, no? (Because the stages to set and the minimum stage will be different depending on which quest is running.)

EDIT: nvm, I think I understand, the script will actually be used on the quest alias, so there is no need to use the quest as a property

Well you can do that, and just use the owning quest as the property for each quest (the script can be used anywhere else with different props). It just saves you the extra work of setting the property every time :)
User avatar
Jhenna lee Lizama
 
Posts: 3344
Joined: Wed Jun 06, 2007 5:39 am

Post » Mon Nov 19, 2012 10:52 pm

OK, I tried putting the script directly on the container reference instead of a trigger box.

The very first line in the script should result in a debug notification ("shout trigger event started") if any spell at all is cast at the container. It didn't work with Unrelenting Force, so I did some testing, and the result is very strange

- Unrelenting Force, Dismay, Disarm, Frost Breath, Fire Breath, any directional shout does not result in the debug notification
- Area of Effect shouts with some sort of explosion on the magic effect triggered the debug notification, including Aura Whisper and my modified area of effect version of Ice Form, which uses an explosion
- Any destruction spell works, including flames, fireball, ice spike, icy spear, sparks, etc.

Any idea why Unrelenting Force does not trigger the debug notification, and what I need to do to fix this part of the script?
->specifically, it is this line which is not working with Unrelenting Force, but works with any destruction spell:
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)		Spell akSpell = akSource as Spell		Debug.Notification("shout trigger event started")

Here is the complete version of the script I was testing last night, this script is attached to the container: http://pastebin.com/raw.php?i=cwDeNk3d

Properties are as follows:

Spoiler


Spell property triggerSpell1 = VoiceUnrelentingForce1
Spell property triggerSpell2 = VoiceUnrelentingForce2
Spell property triggerSpell3 = VoiceUnrelentingForce1

ObjectReference Property MyChest = the reference for the container on which the script is attached

Quest Property MyQuest1 = non-repeatable quest

Quest Property myQuest2 = repeatable quest

Armor Property AmuletofTalos = base formID for markarthfreeformTalosAmulet

MiscObject Property Aetherium = base formID for a misc object my mod adds

Armor Property DovahMir = base formID for an amulet my mod adds

User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am

Post » Mon Nov 19, 2012 6:14 pm

Maybe it would work with Magic Effect Start :shrug: That's what I use in my Training Dummies mod.

Example here:

Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)if akCaster == Player && akEffect.HasKeyword(MagicDamageFire)       Game.AdvanceSkill("Destruction", 3.0)           Debug.Notification("Fire")EndEvent
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm


Return to V - Skyrim