samv96UK Posted August 14, 2012 Share Posted August 14, 2012 Hi everyone, I am trying to create part of a quest, in which the player has to shoot an arrow at a target, which will advance the stage. I added a script to the target, and added the properties for: the quest, the player, a hunting bow and iron arrows. I then put this script into the source: Event OnHit(ObjectReference Player, Form HuntingBow, Projectile IronArrow) ArcheryQuest.SetStage(20) EndEvent but I get this error Starting 1 compile threads for 1 files...Compiling "RochebereArcheryTarget"...c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RochebereArcheryTarget.psc(13,0): the parameter types of function onhit in the empty state on script rocheberearcherytarget do not match the parent script objectreferenceNo output generated for RochebereArcheryTarget, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on RochebereArcheryTarget Any ideas on what I'm doing wrong? Thanks Link to comment Share on other sites More sharing options...
J3X Posted August 14, 2012 Share Posted August 14, 2012 (edited) Incorrect usage of OnHit. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akAggressor == game.GetPlayer() && akSource == HuntingBow && akProjectile == IronArrow) ArcheryQuest.SetStage(20) End If EndEvent Edited August 14, 2012 by J3X Link to comment Share on other sites More sharing options...
samv96UK Posted August 14, 2012 Author Share Posted August 14, 2012 Incorrect usage of OnHit. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akAggressor == game.GetPlayer() && akSource == HuntingBow && akProjectile == IronArrow) ArcheryQuest.SetStage(20) End If EndEvent Ah, thanks. I'll give you're code a go now then. Link to comment Share on other sites More sharing options...
samv96UK Posted August 14, 2012 Author Share Posted August 14, 2012 Incorrect usage of OnHit. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akAggressor == game.GetPlayer() && akSource == HuntingBow && akProjectile == IronArrow) ArcheryQuest.SetStage(20) End If EndEvent Ah, thanks. I'll give you're code a go now then. Unfortunately, whenever I try to save the script I get 3 errors: no viable alternative at input 'End' no viable alternative at input '\\r\\n' mismatched input 'EndEvent' expecting ENDIF Just to conform, I'm trying to attach this script to a static object. Is it supposed to work on them? Link to comment Share on other sites More sharing options...
samv96UK Posted August 14, 2012 Author Share Posted August 14, 2012 Never mind, Fixed it. Now I've just got to check that it works as I want it to. :thumbsup: Link to comment Share on other sites More sharing options...
burkemi5 Posted January 5, 2013 Share Posted January 5, 2013 Never mind, Fixed it. Now I've just got to check that it works as I want it to. :thumbsup: Were you able to get your OnHit to work? I am doing something very similar to you and the game isn't recognizing the projectile I am using. Link to comment Share on other sites More sharing options...
Hangman4358 Posted January 6, 2013 Share Posted January 6, 2013 I am actually also having problems. I am trying to get onhit to work when an object is hit by magic spells but it is not working. and I find the documentation for onhit to be really lacking. Link to comment Share on other sites More sharing options...
bloomingdedalus Posted January 6, 2013 Share Posted January 6, 2013 Here's some working "OnHit()" Scripts I've written, the first is a spell, the second is anything: Scriptname ToRHall3CrystalHit1 extends ObjectReference ObjectReference Property pTrapLinkerA Auto ObjectReference Property pTrapLinkerB Auto Projectile Property pShockBoltAim Auto bool Property pToggleState = False Auto Event OnHit(objectReference akAggressor, Form akWeapon, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akProjectile == pShockBoltAim) if (akaggressor !=game.getplayer()) ;debug.notification("Yep, you hit it") endif ;if akaggressor != game.getplayer() if (pToggleState == False) pTrapLinkerA.Activate(self) else pTrapLinkerB.Activate(self) endif ;endif endif endevent Event OnActivate(ObjectReference akReference) if (akReference != game.GetPlayer()) if pToggleState == True pToggleState = False else pToggleState = True endif ;debug.notification("Toggled" + pToggleState) endif endevent Scriptname ToRTrapPressurePlateDwe extends ObjectReference ObjectReference Property myTriggeree Auto ObjectReference Property pSconceOn Auto ObjectReference Property pSconceOff Auto ObjectReference Property pLight Auto bool Property pKeepTrack = False Auto Hidden event onload() Gotostate("Inactive") endevent event onreset() Gotostate("Inactive") endevent Auto State Inactive event onbeginstate() if pKeepTrack == True toggle() endif ;debug.notification("Entering Inactive") endevent event onhit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if akAggressor == game.GetPlayer() gotostate("Activated") endif endevent event onupdate() endevent endstate State Activated event onbeginstate() ;debug.notification("Entering Active") playAnimation("Down") if pKeepTrack == False toggle() endif pSconceOff.Disable() pSconceOn.Enable() pLight.Enable() registerforsingleupdate(5.0) endevent event onupdate() pSconceOff.Enable() pSconceOn.Disable() pLight.Disable() if pKeepTrack == True toggle() endif playAnimation("Up") gotostate("Inactive") endevent event onhit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) endevent endstate event onhit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) ;playAnimation("Down") ;myTriggeree.activate(Self as objectreference) ;pSconceOff.Disable() ;pSconceOn.Enable() ;pLight.Enable() ;utility.wait(8.0) ;pSconceOff.Enable() ;pSconceOn.Disable() ;pLight.Disable() ;mytriggeree.activate(self as objectreference) ;playAnimation("Up") endevent event OnUpdate() endevent function toggle() mytriggeree.activate(self as objectreference) if pKeepTrack == True pKeepTrack = False else pKeepTrack = True endif endfunction Link to comment Share on other sites More sharing options...
bloomingdedalus Posted January 6, 2013 Share Posted January 6, 2013 (edited) Incorrect usage of OnHit. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akAggressor == game.GetPlayer() && akSource == HuntingBow && akProjectile == IronArrow) ArcheryQuest.SetStage(20) End If EndEvent Ah, thanks. I'll give you're code a go now then. The problem with this code is a basic syntax: You have "End if" when it should be "endif" Additionally, you have to be sure you defined the properties "HuntingBow" and "IronArrow" as objectreferences first. I'm not sure these are properties. The convention used in the game's scripts is to assign properties by just adding a lowercase "p" in front of them. For example: "Objectreference Property pHuntingBow Auto" Assuming there's a base object called "HuntingBow" exactly, when you open up the properties pane of your script and hit "auto-fill" it will automatically fill "pHuntingBow" with the base object "HuntingBow" The correct form of this code would be, fully: scriptname myonhitscript extends objectreference Objectreference Property pHuntingBow Auto Objectreference Property pIronArrow Auto Quest Property pArcheryQuest Auto EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akAggressor == game.GetPlayer() && akSource == pHuntingBow && akProjectile == pIronArrow) pArcheryQuest.SetStage(20) EndIf ENDEVENT If this is a referencescript, you probably wouldn't have to use the quest property - however - I usually put onhit scripts directly on objects, still being rather frustrated with referencealias functionality. Edited January 6, 2013 by bloomingdedalus Link to comment Share on other sites More sharing options...
steve40 Posted January 6, 2013 Share Posted January 6, 2013 This script should be useful for debugging OnHit(): ScriptName _testOnHit extends Actor Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) If (akSource as Spell) Debug.Notification("We were hit by a Spell") ElseIf (akSource as Weapon) Debug.Notification("We were hit by a Weapon") ElseIf (akSource as Explosion) Debug.Notification("We were hit by an Explosion") ElseIf (akSource as Enchantment) Debug.Notification("We were hit by an Enchantment") ElseIf (akSource as Potion) Debug.Notification("We were hit by a Potion or Food") ElseIf (akSource as Ingredient) Debug.Notification("We were hit by an Ingredient") EndIf If akProjectile != None Debug.Notification("We were hit by a Projectile") EndIf If abPowerAttack == true Debug.Notification("It was a power attack") EndIf If abSneakAttack == true Debug.Notification("It was a sneak attack") EndIf If abBashAttack == true Debug.Notification("It was a bash attack") EndIf If abHitBlocked == true Debug.Notification("The hit was blocked") EndIf EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts