ChosenName Posted October 11, 2020 Share Posted October 11, 2020 I'm trying to spawn a health potion using a magic effect, so I've create the effect and attached the following script to it Scriptname SummonHealthPotion extends ActiveMagicEffect {Script to summon a health potion at the player's location} Potion Property healthPotion Auto {The potion summoned by the spell} Event OnEffectStart(Actor AkTarget, Actor akCaster) akCaster.PlaceAtMe(healthPotion) EndEvent I then updated the property of the script to attach healthPotion to the proper game object. This compiles fine but doesn't do anything when I cast the spell. Upon reading it seems PlaceAtMe takes a Form parameter and not an object reference, so I tried the following change Scriptname SummonHealthPotion extends ActiveMagicEffect {Script to summon a health potion at the player's location} Potion Property healthPotion Auto {The potion summoned by the spell} Event OnEffectStart(Actor AkTarget, Actor akCaster) akCaster.PlaceAtMe(healthPotion.GetBaseObject()) EndEvent But then it tells meGetBaseObject is not a function or does not exist Do you know what I'm doing wrong? Thank you :) Link to comment Share on other sites More sharing options...
dylbill Posted October 11, 2020 Share Posted October 11, 2020 It looks like your top script should be working. Doubly make sure the property is set and you save your mod after. That will also place the potion right at your feet. If you want to place the potion in front of you, you can do this: Potion Property healthPotion Auto {The potion summoned by the spell} Event OnEffectStart(Actor AkTarget, Actor akCaster) ObjectReference PotionRef = akCaster.PlaceAtMe(healthPotion) float A = akCaster.GetAngleZ() Float YDist = Math.Sin(A) Float XDist = math.Cos(A) YDist *= 100 XDist *= 100 PotionRef.MoveTo(akCaster, YDist, XDist, 10.0, False) ;moves potion 100 units in front of caster EndEventdecrease or increase the *= 100 to move it closer or farther away. Link to comment Share on other sites More sharing options...
ChosenName Posted October 11, 2020 Author Share Posted October 11, 2020 Hey thanks for the quick response. At the feet is fine for now but thanks for the moving code, I might implement that once it's working. Here's what I have for the health potion property. It seems correct to me so I'm not sure why nothing spawns Link to comment Share on other sites More sharing options...
dylbill Posted October 11, 2020 Share Posted October 11, 2020 Hmmm, I dunno then. That looks all good to me. Try putting a notification in to make sure the script is firing: Event OnEffectStart(Actor AkTarget, Actor akCaster) akCaster.PlaceAtMe(healthPotion) Debug.Notification("Potion Placed") EndEvent Link to comment Share on other sites More sharing options...
ChosenName Posted October 12, 2020 Author Share Posted October 12, 2020 Good call! There's no notification so now I know the script is not firing. Now I have to figure out why. Thanks for the help I really appreciate it! Link to comment Share on other sites More sharing options...
ChosenName Posted October 12, 2020 Author Share Posted October 12, 2020 I got it working! I changed the Delivery of both the effect and spell from "Target Location" to "Self". Not sure why that works but I won't question it for now. Thanks again dylbill! Link to comment Share on other sites More sharing options...
foamyesque Posted October 12, 2020 Share Posted October 12, 2020 Good call! There's no notification so now I know the script is not firing. Now I have to figure out why. Thanks for the help I really appreciate it! Magic effects will only trigger OnEffectStart() events if they are applied to an actor, I believe. Link to comment Share on other sites More sharing options...
dylbill Posted October 12, 2020 Share Posted October 12, 2020 Good call! There's no notification so now I know the script is not firing. Now I have to figure out why. Thanks for the help I really appreciate it! Magic effects will only trigger OnEffectStart() events if they are applied to an actor, I believe. Yes I think that's correct. Glad you got it working! Link to comment Share on other sites More sharing options...
ChosenName Posted October 12, 2020 Author Share Posted October 12, 2020 (edited) Oh I see, that would explain why switching it to Self worked! Is there a less restrictive starting event I can use - something like OnEffectTriggered? Or perhaps something more related to location-targeted spells, like OnEffectStart(Location a, ...)? I'm not seeing such an event in the ActiveMagicEffect reference. Edited October 12, 2020 by ChosenName Link to comment Share on other sites More sharing options...
NexusComa2 Posted October 12, 2020 Share Posted October 12, 2020 That little trick of the notification telling you if something is working in your script or not is a great way to debug coding problems.A sound can be used this way also (some languages that's all you get). This is one of them little coding debug tricks no one ever mentions. Link to comment Share on other sites More sharing options...
Recommended Posts