Jump to content

[LE] PathToReference


Elias555

Recommended Posts

I do though. It needs to be activateable at any point in the descent. Even if I make a swap when it gets to the position, that will cause the orientation(I did add true at the end ofEndPoint) to change and the swap will be visible.

 

Edit:Something strange is going on. I CAN activate the object but the activation is not where it was placed or ends up, it's in the initial MoveTo position.

Edited by Elias555
Link to comment
Share on other sites

Not sure what you mean. This is my entire code. I still have to clean things up at the end.

Activator Property MyActivator Auto  
Activator Property xMarkerActivator Auto  
Potion Property Stew Auto  

Event OnEffectStart(Actor akTarget, Actor akCaster)


	ObjectReference EndPoint = akCaster.Placeatme(xMarkerActivator)
	EndPoint.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() - 50.0, true) 
	ObjectReference MyStew = akCaster.Placeatme(MyActivator)
	MyStew.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() + 335.0, true) 

	Utility.Wait(0.5)
	MyStew.TranslateToRef(EndPoint, 45)

EndEvent

Can I use Event OnTranslationComplete() to make a MoveTo or something from another event?

Edited by Elias555
Link to comment
Share on other sites

ObjectReference EndPoint = akCaster.Placeatme(xMarkerActivator)

EndPoint.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() - 50.0, true)

EndPoint.SetPosition(120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() - 50.0)

ObjectReference MyStew = akCaster.Placeatme(MyActivator)

MyStew.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() + 335.0, true)

MyStew.SetPosition(120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() + 335.0)

Utility.Wait(0.5)

MyStew.TranslateToRef(EndPoint, 45)


Not sure if that is 100% right as far as where they are with all that realtime math in the xyz ... I just know you need to use SetPosition() with TranslateToRef().

The SetPosition() is NOT moving anything it is for the TranslateToRef() so you don't get Something strange is going on
Link to comment
Share on other sites

I did try something like that during my testing but using setposition didn't place anything as far as I could see. I tried using getposXYZ and that didn't work either. But here's what worked.

Hopefully someone will find this useful one day.

Scriptname _AceTestScript extends ActiveMagicEffect  


Activator Property MyActivator Auto  
Activator Property xMarkerActivator Auto  
Activator Property RealStew Auto  
Explosion Property MyExplosion Auto

ObjectReference EndPoint
ObjectReference MyStew
ObjectReference NewStew

Event OnEffectStart(Actor akTarget, Actor akCaster)


    EndPoint = akCaster.Placeatme(xMarkerActivator)
    EndPoint.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() - 50.0)
    EndPoint.SetAngle(0.0, 0.0, 0.0)
    MyStew = akCaster.Placeatme(MyActivator)
    MyStew.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() + 335.0)
    MyStew.SetAngle(0.0, 0.0, 0.0)
    Utility.Wait(0.5)
    MyStew.TranslateToRef(EndPoint, 165)

    RegisterForSingleUpdate(0.3)

EndEvent

Event OnUpdate()

    If MyStew.GetPositionZ() == EndPoint.GetPositionZ()  
    
        NewStew = EndPoint.Placeatme(RealStew)
        Utility.Wait(0.5)
        MyStew.Disable()
        MyStew.Delete()
        EndPoint.Disable()
        EndPoint.Delete()

    ElseIf MyStew.GetPositionZ() != EndPoint.GetPositionZ()  
    
        RegisterForSingleUpdate(0.3)

    EndIf

EndEvent


Event OnEffectFinish(Actor akTarget, Actor akCaster)

    NewStew.PlaceAtMe(MyExplosion)
    Utility.Wait(0.2)
    NewStew.Disable()
    NewStew.Delete()
    MyStew.Disable()
    MyStew.Delete()
    EndPoint.Disable()
    EndPoint.Delete()

EndEvent

Sometimes MyStew doesn't get disabled and NewStew isn't created. Not sure why though. Everything else is fine.

Link to comment
Share on other sites

So it communicates the position to TranslateRef? I see.

I tried your code above and once again nothing was visible.

 

Edit: Made a few changes and this placed it and moved correctly but once again the 'activator' was in the position of moveto and not with the nif.



Event OnEffectStart(Actor akTarget, Actor akCaster)


ObjectReference EndPoint = akCaster.Placeatme(xMarkerActivator)
EndPoint.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() - 50.0, true)

ObjectReference MyStew = akCaster.Placeatme(MyActivator)
MyStew.SetPosition(120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() + 335.0) 
MyStew.MoveTo(akCaster, 120.0 * Math.Sin(akCaster.GetAngleZ()), 120.0 * Math.Cos(akCaster.GetAngleZ()), akCaster.GetHeight() + 335.0, true) 
Utility.Wait(0.5)
MyStew.TranslateToRef(EndPoint, 45)

EndEvent
Edited by Elias555
Link to comment
Share on other sites

Ya I didn't think that would work just showing you how you use it. The 1st example I posted works fine with one of my mods.

But I did know my coordinates and wasn't using math to figure them out in realtime. It would go under the moveto call.

Also I'm not testing code I post more just pointing at something that worked for me.

Link to comment
Share on other sites

No idea, what are you doing here exactly.

  Activator PROPERTY FakeStewForm auto    ; your created ".nif" as floating stew
  Static    PROPERTY xMarkerForm  auto    ; baseobject of xMarker
  Explosion PROPERTY theExplosion auto    ; an explosion you like to see
  Potion    PROPERTY Stew         auto    ; baseobject of stew    

  objectReference endMarker
  objectReference myStew
  objectReference realStew

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
    Debug.Trace("OnEffectStart() - target = " +akTarget+ ", caster = " +akCaster+ "  " +self)        ; info only
    myF_PlaceObjects(akCaster)

    Utility.Wait(0.5)
    myStew.TranslateToRef(endMarker, 45.0, 0.0)        ; 165.0  afSpeed=45.0, afMaxRotationSpeed=0.0
ENDEVENT

;----------------------------------------
FUNCTION myF_PlaceObjects(Actor akCaster)  ; moveTo
;----------------------------------------
    float fz = akCaster.GetHeight()                    ; store it
    float aZ = akCaster.GetAngleZ()                    ; store it

    float fx = Math.Sin(aZ) * 120.0
    float fy = Math.Cos(aZ) * 120.0

    endMarker = akCaster.PlaceAtMe(xMarkerForm, 1, False, TRUE)      ; create new xmarker object (disabled)
    endMarker.MoveTo(akCaster, fx, fy, fz - 50.0)

    myStew = akCaster.PlaceAtMe(FakeStewForm)                        ; create new stew object
    myStew.MoveTo(akCaster, fx, fy, fz + 335.0)
ENDFUNCTION

;----------------------------------------
FUNCTION myF_PlaceObjects2(Actor akCaster)  ; setPos alternative code
;----------------------------------------
    float fz = akCaster.GetHeight()                    ; store it
    float aZ = akCaster.GetAngleZ()                    ; store it

    float fx = Math.Sin(aZ) * 120.0
    float fy = Math.Cos(aZ) * 120.0

    fx+= akCaster.GetPositionX()
    fy+= akCaster.GetPositionY()
    fz+= akCaster.GetPositionZ()

    endMarker = akCaster.PlaceAtMe(xMarkerForm, 1, False, TRUE)      ; create new xmarker object
    endMarker.SetPosition(fx, fy, fz - 50.0)
    endMarker.SetAngle(0, 0, aZ)

    myStew = akCaster.PlaceAtMe(FakeStewForm)                        ; create new stew object
    myStew.SetPosition(fx, fy, fz + 335.0)
    myStew.SetAngle(0, 0, aZ)
ENDFUNCTION

links to wiki: https://www.creationkit.com/index.php?title=PlaceAtMe_-_ObjectReference , https://www.creationkit.com/index.php?title=TranslateToRef_-_ObjectReference

 

and just for safety:

    myStew.Disable()
    myStew.Delete()
    myStew = None

there exist two events, you are should looking for

EVENT OnTranslationFailed()  ; received when translation is aborted (from a call to StopTranslateTo)
    myF_CleanUp()
ENDEVENT

EVENT OnTranslationComplete() ; received when translation is complete (from a call to TranslateTo)
; myStew received the endMarker

    myF_Update()         ; update fakeStew by realStew
    myF_CleanUp()        ; cleaning all Refs    
ENDEVENT

The problem is, you have to create surely a second script of type objectReference which is attached to object myStew because I think both events won't be triggered within your ActiveMagicEffect script.

Edited by ReDragon2013
Link to comment
Share on other sites

That had the same problem as the updated script from page one but I appreciate the effort. The script above(comment 15) works well with 1 exception. When the player is standing in the way of the fake activator it doesn't get swapped with the real activator. Not sure how to fix that other than preventing the player from moving which I don't want to do.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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