wapeddell1 Posted April 9, 2020 Share Posted April 9, 2020 I'm trying to make it where I spawn a throne but only one throne and not have duplicates. Also, I'm trying to make the throne delete itself after you get up from it. Furniture Property FurnitureBase Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Activator Property SummonFX Auto Activator Property BanishFX Auto GlobalVariable Property SearchDistance Auto Event onEffectStart(actor akcaster, actor aktarget) objectreference oldFurnitureRef = (game.findclosestreferenceoftypefromref(furniturebase, game.getplayer(), (SearchDistance.getvalue() as int))) IF oldFurnitureRef != NONE oldFurnitureRef.placeatme(banishfx) utility.wait(0.5) oldFurnitureRef.disable() oldFurnitureRef.delete() ENDIF ObjectReference FurnitureItem = Game.GetPlayer().placeatme(FurnitureBase, 1) FurnitureItem.moveto(Game.GetPlayer(), FrontDistance * Math.Sin(Game.GetPlayer().GetAngleZ()), FrontDistance * Math.Cos(Game.GetPlayer().GetAngleZ())) FurnitureItem.SetAngle(0.0,0.0,(Game.GetPlayer().GetAngleZ() + AngleOffset)) FurnitureItem.placeatme(SummonFX) EndEvent Event onSit (actor akcaster, actor aktarget) if (FurnitureBase != None) while (FurnitureBase.IsFurnitureInUse()) Utility.wait(5) endwhile FurnitureBase.disable(true) Utility.wait(1) FurnitureBase.delete() ) EndEvent Link to comment Share on other sites More sharing options...
maxarturo Posted April 9, 2020 Share Posted April 9, 2020 (edited) First of all you need 2 scripts for this. - 1 for your summon - 1 for the chair itself Example script for the chair: Auto State WaitingPlayer Event OnActivate(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() GoToState("Busy") Utility.Wait(2.0) ; Do anything you might need GoToState("StandingUp") EndIf EndEvent EndState State StandingUp Event OnActivate(ObjectReference akActionRef) GoToState("Busy") if akActionRef == Game.GetPlayer() Utility.Wait(1.5) Self.Disable() Self.Delete() EndIf ; GoToState("WaitingPlayer") ; just in case you need it to be reusable EndEvent EndState State Busy Event OnActivate(ObjectReference akActionRef) ;Do nothing. EndEvent EndState The script needs to be attached to the furniture. Furnitures like thorns and chairs and equivalents will send '3 Activation Events' so you need those "States" and the "Wait" to make it work correctly. * Do not edit the script, but just add anything else you might need. Also your script above needs a better writing for a lighter and faster execution. Edited April 9, 2020 by maxarturo Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 9, 2020 Share Posted April 9, 2020 Instead of using PlaceAtMe which creates a new instance consider pre-placing the furniture in a new interior isolated cell and using MoveTo to move it back and forth as needed. Link to comment Share on other sites More sharing options...
wapeddell1 Posted April 12, 2020 Author Share Posted April 12, 2020 (edited) I'm trying to make it where I spawn a throne but only one throne and not have duplicates. Also, I'm trying to make the throne delete itself after you get up from it. Furniture Property FurnitureBase Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Activator Property SummonFX Auto Activator Property BanishFX Auto GlobalVariable Property SearchDistance Auto Event onEffectStart(actor akcaster, actor aktarget) objectreference oldFurnitureRef = (game.findclosestreferenceoftypefromref(furniturebase, game.getplayer(), (SearchDistance.getvalue() as int))) IF oldFurnitureRef != NONE oldFurnitureRef.placeatme(banishfx) utility.wait(0.5) oldFurnitureRef.disable() oldFurnitureRef.delete() ENDIF ObjectReference FurnitureItem = Game.GetPlayer().placeatme(FurnitureBase, 1) FurnitureItem.moveto(Game.GetPlayer(), FrontDistance * Math.Sin(Game.GetPlayer().GetAngleZ()), FrontDistance * Math.Cos(Game.GetPlayer().GetAngleZ())) FurnitureItem.SetAngle(0.0,0.0,(Game.GetPlayer().GetAngleZ() + AngleOffset)) FurnitureItem.placeatme(SummonFX) EndEvent Event onSit (actor akcaster, actor aktarget) if (FurnitureBase != None) while (FurnitureBase.IsFurnitureInUse()) Utility.wait(5) endwhile FurnitureBase.disable(true) Utility.wait(1) FurnitureBase.delete() ) EndEvent Thanks I'll give this a try and yes I want it to be reuse able. I was reading your comments in the script and replying to those. Edited April 12, 2020 by wapeddell1 Link to comment Share on other sites More sharing options...
maxarturo Posted April 13, 2020 Share Posted April 13, 2020 The state "GoToState("WaitingPlayer")" is mainly for a static Throne/Chair, a throne that it won't be moved or disable-delete. If by "I want it to be reuse able" you mean summon the same throne, having only 1 object to spawn, then i'll suggest to go with what IsharaMeradin suggested. In this case the throne's script needs a slightly different approach. Link to comment Share on other sites More sharing options...
wapeddell1 Posted April 13, 2020 Author Share Posted April 13, 2020 I'm trying to make it where I spawn a throne but only one throne and not have duplicates. Also, I'm trying to make the throne delete itself after you get up from it. Furniture Property FurnitureBase Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Activator Property SummonFX Auto Activator Property BanishFX Auto GlobalVariable Property SearchDistance Auto Event onEffectStart(actor akcaster, actor aktarget) objectreference oldFurnitureRef = (game.findclosestreferenceoftypefromref(furniturebase, game.getplayer(), (SearchDistance.getvalue() as int))) IF oldFurnitureRef != NONE oldFurnitureRef.placeatme(banishfx) utility.wait(0.5) oldFurnitureRef.disable() oldFurnitureRef.delete() ENDIF ObjectReference FurnitureItem = Game.GetPlayer().placeatme(FurnitureBase, 1) FurnitureItem.moveto(Game.GetPlayer(), FrontDistance * Math.Sin(Game.GetPlayer().GetAngleZ()), FrontDistance * Math.Cos(Game.GetPlayer().GetAngleZ())) FurnitureItem.SetAngle(0.0,0.0,(Game.GetPlayer().GetAngleZ() + AngleOffset)) FurnitureItem.placeatme(SummonFX) EndEvent Event onSit (actor akcaster, actor aktarget) if (FurnitureBase != None) while (FurnitureBase.IsFurnitureInUse()) Utility.wait(5) endwhile FurnitureBase.disable(true) Utility.wait(1) FurnitureBase.delete() ) EndEvent Thank you so much for this I will credit you in my creation of my mod. Is there a way to limit to spawning only on chair? Link to comment Share on other sites More sharing options...
wapeddell1 Posted April 13, 2020 Author Share Posted April 13, 2020 I'm trying to make it where I spawn a throne but only one throne and not have duplicates. Also, I'm trying to make the throne delete itself after you get up from it. Furniture Property FurnitureBase Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Activator Property SummonFX Auto Activator Property BanishFX Auto GlobalVariable Property SearchDistance Auto Event onEffectStart(actor akcaster, actor aktarget) objectreference oldFurnitureRef = (game.findclosestreferenceoftypefromref(furniturebase, game.getplayer(), (SearchDistance.getvalue() as int))) IF oldFurnitureRef != NONE oldFurnitureRef.placeatme(banishfx) utility.wait(0.5) oldFurnitureRef.disable() oldFurnitureRef.delete() ENDIF ObjectReference FurnitureItem = Game.GetPlayer().placeatme(FurnitureBase, 1) FurnitureItem.moveto(Game.GetPlayer(), FrontDistance * Math.Sin(Game.GetPlayer().GetAngleZ()), FrontDistance * Math.Cos(Game.GetPlayer().GetAngleZ())) FurnitureItem.SetAngle(0.0,0.0,(Game.GetPlayer().GetAngleZ() + AngleOffset)) FurnitureItem.placeatme(SummonFX) EndEvent Event onSit (actor akcaster, actor aktarget) if (FurnitureBase != None) while (FurnitureBase.IsFurnitureInUse()) Utility.wait(5) endwhile FurnitureBase.disable(true) Utility.wait(1) FurnitureBase.delete() ) EndEvent Thanks I'll give this a try and yes I want it to be reuse able. I was reading your comments in the script and replying to those. Yeah I tried that but when I spawn in the chair nothing appears. I placed it in a cell. I used a marker to return it to. I also tried to reverse engineer conjure chest mod for the throne but it just doesn't appear in game when I use the spell. Link to comment Share on other sites More sharing options...
wapeddell1 Posted April 13, 2020 Author Share Posted April 13, 2020 This is the script when I try it the way IsharaMeradin say. This doesn't spawn anything in game. Scriptname summonspawnthronespell extends activemagiceffect ObjectReference Property throne Auto Activator Property SummonFX Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Event onEffectStart(Actor akCaster, Actor akTarget) throne.moveto(Game.GetPlayer(), FrontDistance * Math.Sin(Game.GetPlayer().GetAngleZ()), FrontDistance * Math.Cos(Game.GetPlayer().GetAngleZ())) throne.SetAngle(0.0,0.0,(Game.GetPlayer().GetAngleZ() + AngleOffset)) throne.placeatme(SummonFX) EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 13, 2020 Share Posted April 13, 2020 May not solve the problem but who knows. I suggest moving the math outside of the function call and passing in only the final value. Furthermore to speed things up store the player data in a local variable and use that instead of repeatedly calling GetPlayer(). See included script code. You may also wish to test without specifying any offsets. If it spawns literally on the player, then something may be off with the calculations. Scriptname summonspawnthronespell extends activemagiceffect ObjectReference Property throne Auto Activator Property SummonFX Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Event onEffectStart(Actor akCaster, Actor akTarget) Actor PlayerRef = Game.GetPlayer() ; call once and store - speeds up rest of script Float myXoffset = FrontDistance * Math.Sin(PlayerRef.GetAngleZ()) Float myYoffset = FrontDistance * Math.Cos(PlayerRef.GetAngleZ()) Float myZangle = (PlayerRef.GetAngleZ() + AngleOffset) throne.moveto(PlayerRef,myXoffset ,myYoffset) throne.SetAngle(0.0,0.0,myZangle) throne.placeatme(SummonFX) EndEvent Once you have the throne moving to location, you can then use a player alias script with the OnGetUp event to move the throne back to its starting location. If you do not want it to be a long running quest just for monitoring when the player gets up, have the script that moves the throne start the quest. Have the quest stopped by the alias script after you've done everything needed to move the throne back. Taking a step back, lets ask a question or two:Are you wanting a throne that will appear and disappear from a specific location?Are you wanting a throne that can appear anywhere at the player's choice? Link to comment Share on other sites More sharing options...
wapeddell1 Posted April 13, 2020 Author Share Posted April 13, 2020 (edited) May not solve the problem but who knows. I suggest moving the math outside of the function call and passing in only the final value. Furthermore to speed things up store the player data in a local variable and use that instead of repeatedly calling GetPlayer(). See included script code. You may also wish to test without specifying any offsets. If it spawns literally on the player, then something may be off with the calculations. Scriptname summonspawnthronespell extends activemagiceffect ObjectReference Property throne Auto Activator Property SummonFX Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Event onEffectStart(Actor akCaster, Actor akTarget) Actor PlayerRef = Game.GetPlayer() ; call once and store - speeds up rest of script Float myXoffset = FrontDistance * Math.Sin(PlayerRef.GetAngleZ()) Float myYoffset = FrontDistance * Math.Cos(PlayerRef.GetAngleZ()) Float myZangle = (PlayerRef.GetAngleZ() + AngleOffset) throne.moveto(PlayerRef,myXoffset ,myYoffset) throne.SetAngle(0.0,0.0,myZangle) throne.placeatme(SummonFX) EndEvent Once you have the throne moving to location, you can then use a player alias script with the OnGetUp event to move the throne back to its starting location. If you do not want it to be a long running quest just for monitoring when the player gets up, have the script that moves the throne start the quest. Have the quest stopped by the alias script after you've done everything needed to move the throne back. Taking a step back, lets ask a question or two:Are you wanting a throne that will appear and disappear from a specific location?Are you wanting a throne that can appear anywhere at the player's choice?That doesn't work either. When I use Object Reference the game just doesn't load the chair. When I use the code below. I'm able to spawn the chair. I want the chair to appear any where at players choice without duplicates, and it deletes when they get up. Things that work with the script below is that the chair does indeed spawn anywhere and with the aid of maxarturo script the chair deletes when you get up. The main issue is that the chair keeps making duplicates rather than delete when recasting the spell. Scriptname summonspawnthronespell extends activemagiceffect Furniture Property throne Auto Float Property FrontDistance Auto Float Property AngleOffset Auto Activator Property SummonFX Auto Activator Property BanishFX Auto Event onEffectStart(actor akcaster, actor aktarget) ObjectReference FurnitureItem = Game.GetPlayer().placeatme(throne, 1) FurnitureItem.moveto(Game.GetPlayer(), FrontDistance * Math.Sin(Game.GetPlayer().GetAngleZ()), FrontDistance * Math.Cos(Game.GetPlayer().GetAngleZ())) FurnitureItem.SetAngle(0.0,0.0,(Game.GetPlayer().GetAngleZ() + AngleOffset)) FurnitureItem.placeatme(SummonFX) EndEvent Edited April 13, 2020 by wapeddell1 Link to comment Share on other sites More sharing options...
Recommended Posts