Oblis Posted September 17, 2012 Share Posted September 17, 2012 (edited) I have created the following script for an object.The object is already in the game world. I want to move a marker always where the item is.The item is moving all the time, and I want the marker to follow it.Every day at 23 to 00 the game will check once the position of the item and the marker will move there.The ref of the marker is: NPC01StartingPoint Unfortunatelly the marker is not moving to the object.Can anyone see the mistake in code?Thanks scriptname NPCScullScript float Time ref Object short DoOnceTimeZone12 Begin GameMode Set Object to GetSelf Set Time to GameHour If (Time > 00) && (Time < 23) set DoOnceTimeZone12 to 0 Endif if (Time > 23) && (Time < 23.99) if DoOnceTimeZone12 == 0 NPC01StartingPoint.MoveTo Object 1,1,1 Set DoOnceTimeZone12 to 1 Endif Endif End Edited September 17, 2012 by Oblis Link to comment Share on other sites More sharing options...
Maskar Posted September 17, 2012 Share Posted September 17, 2012 MoveTo is a bit of a funny function. Chances are it has moved, but you simply can't see it. Using disable/enable should help. Link to comment Share on other sites More sharing options...
Lanceor Posted September 17, 2012 Share Posted September 17, 2012 (edited) MoveTo is a bit of a funny function. It is extremely processor intensive, preventing any other script from running that frame. You could also use a similar function called SetPos, but if called every frame, it stops working after a while. The only way to fix it is to move it to another cell and then move it back. A workaround was developed for various glowing weapon mods (which basically move a light around) by using SetPos and using a frame counter to add in an occasional MoveTo. set FrameCount to FrameCount - 1 if FrameCount == 1 NPC01StartingPoint.PositionCell 0 0 0 0 SomeDummyCell ;<----- Note: This has been edited. endif if FrameCount <= 0 set FrameCount to 7 NPC01StartingPoint.MoveTo Object endif Set ObjectPositionX to Object.GetPos X Set ObjectPositionY to Object.GetPos Y Set ObjectPositionZ to Object.GetPos Z NPC01StartingPoint.SetPos X ObjectPositionX NPC01StartingPoint.SetPos Y ObjectPositionY NPC01StartingPoint.SetPos Z ObjectPositionZ Edited September 18, 2012 by Lanceor Link to comment Share on other sites More sharing options...
Oblis Posted September 18, 2012 Author Share Posted September 18, 2012 Thanks Link to comment Share on other sites More sharing options...
Lanceor Posted September 18, 2012 Share Posted September 18, 2012 Oops, I made a mistake in the code. Check the edit before implementing it. :) Link to comment Share on other sites More sharing options...
ziitch Posted September 18, 2012 Share Posted September 18, 2012 Hmm... If it's a one-time event, wouldn't placeatme work just fine? Link to comment Share on other sites More sharing options...
Oblis Posted September 19, 2012 Author Share Posted September 19, 2012 (edited) PlaceAtMe will generate copies of the item. MoveTo will just move the excisting object. Can you explain what this does? set FrameCount to FrameCount - 1 if FrameCount == 1 NPC01StartingPoint.PositionCell 0 0 0 0 SomeDummyCell ;<----- Note: This has been edited. endif So I created the object with the following code that works fine: scriptname NPCScullScript float ObjectPositionX float ObjectPositionY float ObjectPositionZ float NPC01StartingPointPositionOldX float NPC01StartingPointPositionOldY float NPC01StartingPointPositionOldZ float NPC01StartingPointPositionNewX float NPC01StartingPointPositionNewY float NPC01StartingPointPositionNewZ Begin OnDrop Player Set ObjectPositionX to Player.GetPos X Set ObjectPositionY to Player.GetPos Y Set ObjectPositionZ to Player.GetPos Z Set NPC01StartingPointPositionOldX to NPC01StartingPoint.GetPos X Set NPC01StartingPointPositionOldY to NPC01StartingPoint.GetPos Y Set NPC01StartingPointPositionOldZ to NPC01StartingPoint.GetPos Z NPC01StartingPoint.SetPos X ObjectPositionX NPC01StartingPoint.SetPos Y ObjectPositionY NPC01StartingPoint.SetPos Z ObjectPositionZ Set NPC01StartingPointPositionNewX to NPC01StartingPoint.GetPos X Set NPC01StartingPointPositionNewY to NPC01StartingPoint.GetPos Y Set NPC01StartingPointPositionNewZ to NPC01StartingPoint.GetPos Z PrintToConsole "NPC01StartingPosition Moved from %.2f, %.2f, %.2f to %.2f, %.2f, %.2f" NPC01StartingPointPositionOldX NPC01StartingPointPositionOldY NPC01StartingPointPositionOldZ NPC01StartingPointPositionNewX NPC01StartingPointPositionNewY NPC01StartingPointPositionNewZ End When I drop the scull, the Set NPC01StartingPoint marker is moving too. Then I added the following lines to my NPC to make him spawn to the NPC01StartingPoint at a specific time if (Time > 23) && (Time < 23.99) if DoOnceTimeZone13 == 0 set DoOnceTimeZone12 to 0 set DoOnceTimeZone13 to 1 set DoOnceTimeZone01 to 0 ;NPC.AddScriptPackage NPCRelocatingNPC01Position Set NPC01StartingPointPositionX to NPC01StartingPoint.GetPos X Set NPC01StartingPointPositionY to NPC01StartingPoint.GetPos Y Set NPC01StartingPointPositionZ to NPC01StartingPoint.GetPos Z NPC.SetPos X NPC01StartingPointPositionX NPC.SetPos Y NPC01StartingPointPositionY NPC.SetPos Z NPC01StartingPointPositionZ endif endif And this works strange.He will spawn to a different position in the starting cell.But if i will move the NPC01StartingPoint outside of the interior cell he will do nothing. Also If I make a TRAVEL package to NPC01StartingPoint where this is outside, the NPC is trying to pass through the walls!What an idiot! Edited September 19, 2012 by Oblis Link to comment Share on other sites More sharing options...
Lanceor Posted September 19, 2012 Share Posted September 19, 2012 MY BIGGEST APOLOGIES! I re-read your first script and realised that you wanted to move NPC01StartingPoint just once, not continuously for an hour. That long code that I wrote doesn't apply in that case. Your code in either of your posts is seems to be on the right track, but we have to take a few scripting quirks into account. Were you in the same cell as "object" when the MoveTo was fired? Moving items in other cells seldom works regardless of how it's done.SetPos can only move items within the same cell.Objects that aren't usually movable, such as XMarkers or XMarkerHeadings will often confuse the game if moved to a different cell. You may need to use a "marker rat". Basically, it's a tiny, invisible creature with 0 speed that you use in place of an XMarker. Can I also clarify what you want to do? You have a skull that you can carry around or drop anywhere.At 11pm, the Skull marks the spot where the NPC should appear.You want the skull to mark the spot, and the NPC to move to the spot, even if one or both are in a different cell. Link to comment Share on other sites More sharing options...
Oblis Posted September 19, 2012 Author Share Posted September 19, 2012 (edited) No Need for apologies. Its ok hehehe Were you in the same cell as "object" when the MoveTo was fired? Moving items in other cells seldom works regardless of how it's done.Sorry I dont understant. SetPos can only move items within the same cell.And why if I drop the scull outside it seems to get the new X,Y,Z and appears me the new point?It stores the X,Y,Z of the new point. I dont think this is true. Maybe you are mistaken with PositionCell Objects that aren't usually movable, such as XMarkers or XMarkerHeadings will often confuse the game if moved to a different cell. You may need to use a "marker rat". Basically, it's a tiny, invisible creature with 0 speed that you use in place of an XMarker.You think I shall make this way and not with marker? Because marker is an object too. I dont know.The marker seem to be moved to the new poisition. The npc refuces to go there. Can I also clarify what you want to do?I have a scull that when the player drops it somewhere it will mark the point (the player is) and move the marker there.Then, every day between 23 and 00 the npc will check once, and teleport himself at the new position (where the marker is). Edited September 19, 2012 by Oblis Link to comment Share on other sites More sharing options...
Oblis Posted September 19, 2012 Author Share Posted September 19, 2012 Actually I beleieve that when the machine set the new X,Y,Z it set them for the void of the current cell.I mean that if the marker is at 0,0,0 in "MyDummyCell" and I throw the scull outside and it gets 10,10,10 for example, the machine will understand this as 10,10,10 in "MyDummyCell" somewhere outside the wall but in the same cell.The thing is to make the machine that i want it, to change cells and go there. Link to comment Share on other sites More sharing options...
Recommended Posts