Now it may be that there is just something wrong with my script causing this weirdness, although I do use States to prevent multiple threads. Here is the script handling the keypresses:
Spoiler
Scriptname SettlerMainScript extends QuestImport InputImport MathObjectReference[] Property GhostHouses AutoObjectReference[] Property GhostArray AutoObjectReference Property Ghost AutoGhostBuildingExtraData Property GhostScript AutoDoorExtraData Property DoorScript AutoObjectReference Property StorageCell AutoObjectReference DoorExObjectReference DoorInObjectReference NewMarkerActivator Property Marker AutoActor Property NPC AutoReferenceAlias Property DoorAlias AutoReferenceAlias Property NPCAlias AutoBool BuildingInt BuildingIndexInt RefIndexInt DoorIndexFloat AngleStep = 5.0Float MoveStep = 100.0Float xPosFloat yPosFloat zPosFloat zAngleFloat xAngleFloat yAngleFloat xPosSubjectFloat yPosSubjectFloat zPosSubjectFloat zAngleSubjectfloat CalcFloat DistanceInt DoOnceEvent OnInit()RegisterForUpdate(0.2)EndEventEvent OnUpdate()GoToState("Running")if IsKeyPressed(210) if Building == False Building = True GhostScript = Ghost as GhostBuildingExtraData GhostScript.Obstructions = 0 Ghost.MoveTo(Game.GetPlayer(), -1000, 0, 0, False) xPos = Ghost.GetPositionX() yPos = Ghost.GetPositionY() zPos = Ghost.GetPositionZ() xAngle = Ghost.GetAngleX() yAngle = Ghost.GetAngleY() zAngle = Ghost.GetAngleZ() ElseIf Building == True Building = False Ghost.MoveTo(StorageCell) EndIfEndIfIf Building == True if IsKeyPressed(200) Ghost.TranslateTo(xPos, (yPos + MoveStep), zPos, 0, 0, zAngle, 200, 0) yPos += MoveStep Elseif IsKeyPressed(203) Ghost.TranslateTo((xPos - MoveStep), yPos, zPos, 0, 0, zAngle, 200, 0) xPos -= MoveStep Elseif IsKeyPressed(205) Ghost.TranslateTo((xPos + MoveStep), yPos, zPos, 0, 0, zAngle, 200, 0) xPos += MoveStep Elseif IsKeyPressed(208) Ghost.TranslateTo(xPos, (yPos - MoveStep), zPos, 0, 0, zAngle, 200, 0) yPos -= MoveStep Elseif IsKeyPressed(209) Ghost.TranslateTo(xPos, yPos, (zPos - (MoveStep / 2)), 0, 0, zAngle, 200, 0) zPos -= MoveStep Elseif IsKeyPressed(201) Ghost.TranslateTo(xPos, yPos, (zPos + (MoveStep / 2)), 0, 0, zAngle, 200, 0) zPos += MoveStep Elseif IsKeyPressed(51) Ghost.TranslateTo(xPos, yPos, zPos, xAngle, yAngle, (zAngle + AngleStep), 50, 30) zAngle += AngleStep Elseif IsKeyPressed(52) Ghost.TranslateTo(xPos, yPos, zPos, xAngle, yAngle, (zAngle - AngleStep), 50, 30) zAngle -= AngleStep ElseIf IsKeyPressed(78) AngleStep *= 2 MoveStep *= 2 Debug.Notification("Step size: " + AngleStep) ElseIf IsKeyPressed(74) AngleStep *= 0.5 MoveStep *= 0.5 Debug.Notification("Step size: " + AngleStep) ElseIf IsKeyPressed(14) if BuildingIndex < 2 BuildingIndex += 1 Else BuildingIndex = 0 EndIf Ghost.MoveTo(StorageCell) GhostScript = Ghost as GhostBuildingExtraData GhostScript.Obstructions = 0 GhostHouses[BuildingIndex].Disable() GhostHouses[BuildingIndex].MoveTo(Game.GetPlayer(), 0, 0, 0, False) GhostHouses[BuildingIndex].SetPosition(xPos, yPos, zPos) GhostHouses[BuildingIndex].SetAngle(xAngle, yAngle, zAngle) GhostHouses[BuildingIndex].Enable() Ghost = GhostHouses[BuildingIndex] Debug.Notification("Switched to next building: " + BuildingIndex) ElseIf IsKeyPressed(48) GhostScript = Ghost as GhostBuildingExtraData if GhostScript.Obstructions == 0 Ghost.StopTranslation() RefIndex = GhostScript.Used.Find(False) if RefIndex < 0 ;Debug.MessageBox("No more instances available of this building") Else DoorIndex = 0 GhostScript.Used[RefIndex] = True GhostScript.Exterior[RefIndex].MoveTo(Ghost) While (DoorIndex < GhostScript.DoorType.Length) DoorEx = Ghost.PlaceAtMe(GhostScript.DoorType[DoorIndex], 1, True, False) Distance = sqrt(pow(GhostScript.DoorExxPos[DoorIndex], 2) + pow(GhostScript.DoorExyPos[DoorIndex], 2)) Calc = (atan(GhostScript.DoorExxPos[DoorIndex] / GhostScript.DoorExyPos[DoorIndex]) + zAngle) DoorEx.SetPosition((xPos - (sin(Calc) * Distance)), (yPos - (cos(Calc) * Distance)), (zPos + GhostScript.DoorExzPos[DoorIndex])) DoorEx.SetAngle(0, 0, (zAngle + GhostScript.DoorExzAngle[DoorIndex])) DoorIn = GhostScript.NorthMarker[RefIndex].PlaceAtMe(GhostScript.DoorType[DoorIndex], 1, True, False) DoorIn.SetPosition((GhostScript.DoorInxPos[DoorIndex]), (GhostScript.DoorInyPos[DoorIndex]), (GhostScript.DoorInzPos[DoorIndex])) DoorIn.SetAngle(0, 0, (GhostScript.DoorInzAngle[DoorIndex])) DoorScript = DoorIn as DoorExtraData xPosSubject = DoorEx.GetPositionX() - (sin(zAngle + GhostScript.DoorExzAngle[DoorIndex]) * 150) yPosSubject = DoorEx.GetPositionY() - (cos(zAngle + GhostScript.DoorExzAngle[DoorIndex]) * 150) NewMarker = DoorEx.PlaceAtMe(Marker, 1, True, False) NewMarker.SetPosition(xPosSubject, yPosSubject, (zPos + GhostScript.DoorInzPos[DoorIndex])) NewMarker.SetAngle(0, 0, zAngle + (GhostScript.DoorExzAngle[DoorIndex]) + 180) DoorScript.TeleportMarker = NewMarker if DoOnce == 0 NPC.MoveTo(Game.GetPlayer()) DoorAlias.ForceRefTo(NewMarker) NPCAlias.TryToEvaluatePackage() DoOnce = 1 EndIf DoorScript = DoorEx as DoorExtraData xPosSubject = DoorIn.GetPositionX() + (sin(GhostScript.DoorInzAngle[DoorIndex]) * 150) yPosSubject = DoorIn.GetPositionY() + (cos(GhostScript.DoorInzAngle[DoorIndex]) * 150) NewMarker = DoorIn.PlaceAtMe(Marker, 1, True, False) NewMarker.SetPosition(xPosSubject, yPosSubject, (GhostScript.DoorInzPos[DoorIndex])) NewMarker.SetAngle(0, 0, (GhostScript.DoorInzAngle[DoorIndex]) + 180) DoorScript.TeleportMarker = NewMarker DoorIndex += 1 EndWhile NewMarker = GhostScript.Northmarker[RefIndex] NewMarker.SetAngle(0, 0, zAngle) EndIf Else Debug.MessageBox("Can't build due to " + GhostScript.Obstructions + " obstructions") EndIf EndIfEndIfGoToState("")EndEventState RunningEndState
And here is a video of what it does. It makes the intent of the script obvious and also shows some of the problems with the keypresses. When I get a messagebox about obstructions for example it means the script tried to place a second building immediately afterwards.
http://www.youtube.com/watch?v=3LodqREbsaI
If anyone can tell me how I can fix the described problem I would be very grateful.
