fg109 Posted April 23, 2012 Author Share Posted April 23, 2012 @DarkPhoenixxy The "Self" keyword refers to whatever object/effect/quest/etc that the script is placed on. Any function called without specifying an object is implicitly called on self. OpenInventory() is a function of the Actor script, so if your script extends ObjectReference instead of Actor for example, you can not use it like that. If you want to use it in your script without changing the script to extend Actor, you can use (Self as Actor).OpenInventory() @phenderix Scriptname Example extends ActiveMagicEffect Float property DamageMin auto Float property DamageMax auto Event OnEffectStart(Actor akTarget, Actor akCaster) Game.GetPlayer().DamageAV("Health", Utility.RandomFloat(DamageMin, DamageMax)) EndEvent Link to comment Share on other sites More sharing options...
DarkPhoenixxy Posted April 23, 2012 Share Posted April 23, 2012 (edited) Thanks!! I thought that i set something wrong, thats why it did not worked. Edited April 23, 2012 by DarkPhoenixxy Link to comment Share on other sites More sharing options...
TheMan21 Posted April 23, 2012 Share Posted April 23, 2012 Hey, maybe you can help me!I tried to make a fun script that will shake the camera a bit when the player Jumps (or just falls) and lands. I just dont know how I can let the script point to the player, because the player is not in the CK object window. I thought that I can put something like "blabla.IsPlayer" ,but this variable does not exists I think. Thats my script so far: (its my first with papyrus) Scriptname shaketestscript extends ObjectReference Function SomeFunction() RegisterForAnimationEvent(self, "JumpLand") EndFunction Event OnAnimationEvent(ObjectReference akSource, string asEventName) if (akSource == self) && (asEventName == "RampRumble") Debug.Trace("Kamera rüttelt! Yay!") endIf endEvent Is this code completely wrong (It compiled successfull)? If yes pls tell me how i can make it right! I just found the orgiginal giant shake script too, its called "giantActorSCRIPT.psc" scriptname giantActorSCRIPT extends actor import objectReference EVENT onLoad() ; call reg function inside if statement. If the event isn't found in the graph, function returns a false if (!RegisterForAnimationEvent(self, "giantStompEffect")) ; debug.trace(self + "could not register for giantStompEffect") else ; debug.trace( self + " registered for animation event") endif endEvent EVENT onAnimationEvent(objectReference deliverator, string eventName) if eventName == "giantStompEffect" ; ;Debug.Trace(self + " Got " + eventName + " from " + deliverator) ; stagger nearby actors and apply some controller/screen shake if the player is nearby KnockAreaEffect(0.5, 2*getLength()) rampRumble() endif endEVENT Link to comment Share on other sites More sharing options...
phenderix Posted April 23, 2012 Share Posted April 23, 2012 Thanks a lot!Will give you credit once I incorporate it :) Link to comment Share on other sites More sharing options...
ulera Posted April 23, 2012 Share Posted April 23, 2012 Honestly... a nest of bees would not have perfect simultaneous fire IRL so that would be fine... if you send me the script I'd be happy to play around with it. Link to comment Share on other sites More sharing options...
yellowpaint Posted April 24, 2012 Share Posted April 24, 2012 I think low difficultypapyrus won't compile My link Link to comment Share on other sites More sharing options...
fg109 Posted April 24, 2012 Author Share Posted April 24, 2012 @TheMan21 The player is found as "Player" under "Actor" under "Actors" in the object window. I don't recommend attaching a script to him though. Instead, consider using a reference alias or magic effect script. Function SomeFunction() RegisterForAnimationEvent(Game.GetPlayer(), "JumpLandEnd") EndFunction Event OnAnimationEvent(ObjectReference akSource, string asEventName) RampRumble() endEvent @ulera I've tried to use the Fire function with the player, but that results in some very poor range and angled shots. Instead, you would need to fire them from some other source. I came up with two scripts (because for some reason the object reference script just couldn't receive any animation events): Scriptname CustomBowScript extends ObjectReference Ammo Property RequiredAmmo Auto Spell Property CustomAbility Auto Event OnEquipped(Actor akActor) if (akActor.GetItemCount(RequiredAmmo)) akActor.EquipItem(RequiredAmmo) akActor.AddSpell(CustomAbility, False) else akActor.UnequipItem(GetBaseObject()) Debug.Messagebox("You do not have the required ammo for this weapon.") endif EndEvent Event OnUnequipped(Actor akActor) akActor.RemoveSpell(CustomAbility) EndEvent Scriptname CustomAbilityScript extends ActiveMagicEffect Activator Property DummyObject Auto Ammo Property RequiredAmmo Auto Int Property MaxRoundsPerShot Auto Weapon Property CustomBow Auto ObjectReference[] SourceNodes Event OnEffectStart(Actor akTarget, Actor akCaster) RegisterForAnimationEvent(akTarget, "BowDraw") RegisterForAnimationEvent(akTarget, "ArrowRelease") EndEvent Event OnAnimationEvent(ObjectReference akSource, String asEventName) Actor akActor = akSource as Actor int AmmoCount = akActor.GetItemCount(RequiredAmmo) if (AmmoCount == 0) akActor.UnequipItem(CustomBow) Debug.Messagebox("You do not have the required ammo for this weapon.") Return elseif !(akActor.IsEquipped(RequiredAmmo)) akActor.EquipItem(RequiredAmmo) endif if (asEventName == "BowDraw") Return endif if (AmmoCount > MaxRoundsPerShot) SetUpShot(akActor, MaxRoundsPerShot) else SetUpShot(akActor, AmmoCount) endif ShootRounds(akActor) EndEvent Function SetUpShot(Actor akActor, Int Rounds) SourceNodes = new ObjectReference[128] SourceNodes[0] = akActor.PlaceAtMe(DummyObject) SourceNodes[0].MoveTo(akActor, 32 * Math.Sin(akActor.GetAngleZ()), 32 * Math.Cos(akActor.GetAngleZ()), 0.75 * akActor.GetHeight()) SourceNodes[0].SetAngle(akActor.GetAngleX() - 3.5, 0, akActor.GetAngleZ()) int index = 1 while (index < Rounds) SourceNodes[index] = SourceNodes[0].PlaceAtMe(DummyObject) SourceNodes[index].MoveTo(SourceNodes[0], Utility.RandomInt(-16, 16), Utility.RandomInt(-16, 16), Utility.RandomInt(-16, 16)) index += 1 endwhile akActor.RemoveItem(RequiredAmmo, Rounds, True) EndFunction Function ShootRounds(Actor akActor) int index = 0 while (SourceNodes[index]) CustomBow.Fire(SourceNodes[index], RequiredAmmo) SourceNodes[index].Disable() SourceNodes[index].Delete() SourceNodes[index] = none index += 1 endwhile EndFunction However, there is a noticeable pause between the player firing an arrow and the scripted arrows actually appearing. @YellowPaint I have no idea what's going on without taking a look at the script. Link to comment Share on other sites More sharing options...
ulera Posted April 24, 2012 Share Posted April 24, 2012 Thanks man! Link to comment Share on other sites More sharing options...
DarkPhoenixxy Posted April 24, 2012 Share Posted April 24, 2012 (edited) :)I was trying to make check for the certain item added to inventory, but this: MiscObject Property HorseSaddleItem auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Debug.MessageBox("Item Added") if akBaseItem == HorseSaddleItem Debug.MessageBox("Working") endif EndEventnever shown "Working" message :(Any idea how to fix it? Edited April 24, 2012 by DarkPhoenixxy Link to comment Share on other sites More sharing options...
fg109 Posted April 24, 2012 Author Share Posted April 24, 2012 Did you actually set the property of HorseSaddleItem to point at the HorseSaddleItem in the CK? Link to comment Share on other sites More sharing options...
Recommended Posts