kazan Posted May 9, 2012 Share Posted May 9, 2012 Hey guys, I'm fairly new to modding and I've got an issue with a script. I made my own activator from a static (a skull from a skeleton) and now I want to make a script which rotates it 180deg so it's facing away from the player. Do I have to edit the mesh (which I wouldn't for the life of me know how to :D)Or is this scriptable?I know this is probably the most moronic script ever but hey here's what I got: Scriptname rotate extends ObjectReference Function SetAngle(float afXAngle, float afYAngle, float afZAngle) native Event OnActivate(ObjectReference akActionRef) skull.SetAngle(180.0, 0.0, 0.0) endevent endFunction Link to comment Share on other sites More sharing options...
steve40 Posted May 9, 2012 Share Posted May 9, 2012 Editing the mesh won't achieve this effect. Your script won't work as it is. Firstly, you don't put event blocks inside of a function. If anything it would be the other way around. You can delete the "function" and "endfunction" lines, they aren't necessary. Also, it should be "self.SetAngle" not "skull.SetAngle" as the script will be attached directly to the skull form. I'd also suggest using a more unique name for your script: Scriptname kazanRotateSkull extends ObjectReference Event OnActivate(ObjectReference akActionRef) self.SetAngle(180.0, 0.0, 0.0) EndEvent I'm not sure that setting the z-angle to 180 degrees will make the skull rotate *by* 180 degrees, I think it will rotate the skull to the *coordinate* of 180 degrees. So I suspect that you will need to determine which direction the player is facing, and also determine which direction the skull is facing when the player activates it, and then you would need to calculate the coordinate that would have the skull facing away from the player. I suppose also that you actually want to rotate the skull slowly, rather than it "pop" into a position facing away from the player? So you would need to use a "while" loop to repeatedly set the angle, incrementing it by a few degrees every iteration to make it look like the skull is turning around. Possibly a better way might be to use the "SplineTranslateTo" function to rotate the skull. You would need to determine the skull's coordinates and then use this function to "move" the skull to exactly the same position except with the afAngleZ changed by 180 degrees, and you would use a small number for afMaxRotationSpeed so that the skull turns slowly. That way only 1 function call would be needed and you wouldn't need to do the trick with the "while" loop that I suggested before. Anyway, try the corrected script above attached to your skull form and see if it works, but I think it will need some refinement. Link to comment Share on other sites More sharing options...
kazan Posted May 9, 2012 Author Share Posted May 9, 2012 Thanks for the reply, I gues I was making it more complicated than needed (nothing new there :D).You are correct regarding the way it rotates. But since I'm not bothing with minimap etc, I decided to rotate my entire dungeon -90 so the script works properly. Seeing my first scripting debacle, I'm gonna stay clear of letting it rotate slowly for now. I'll finish making this maze like dungeon and then check how to achieve this. Link to comment Share on other sites More sharing options...
fg109 Posted May 9, 2012 Share Posted May 9, 2012 Scriptname kazanRotateSkull extends ObjectReference Auto State Waiting Event OnActivate(ObjectReference akActionRef) GoToState("Busy") SetMotionType(4) TranslateTo(X, Y, Z, 0, 0, akActionRef.GetAngleZ(), 1024.0, 15.0) EndEvent EndState State Busy Event OnTranslationComplete() GoToState("Waiting") EndEvent EndState This is assuming that the orientation of the skull is the same as the player. (EG if the player and the skull have the same Z angle, they are facing the same direction) Link to comment Share on other sites More sharing options...
kazan Posted May 9, 2012 Author Share Posted May 9, 2012 (edited) That's an amasing script you wrote fg109, sadly I hardly understand it (i adjusted the speed to my liking and that's my limit).I'm actually not looking for a script to turn the skull the same way as the player, I just want it to look the otherway on activation. That being said, this isn't all I want to do, I want to give players a choice, "turn the skull" and "don't turn the skull" and link the choice to the rotation and the activation of a trap.The skull turns (again tyvm) and the door activates, however the door doesn't wait untill the "turn the skull" choice it simply triggers the trap. How do I link the choice of the messagebox to the activation of the skull? Scriptname atestSkullText extends ObjectReference Message property box1 auto {Are you sure you want to dishonor the dead? Y/N} Message property box2 auto {Fool! Leave my remains alone!} Message property box3 auto {Stop it or I will kill you} Message property box4 auto {Now you die!} int count Event OnActivate(ObjectReference akActionRef) if count ==4 count = 1 else count = count + 1 endif GetMessage(count).Show() endEvent Message function GetMessage(int currentCount) Message chosenMessage if currentCount == 1 chosenMessage = box1 if index == 0 self.SetAngle(0.0, 0.0, -90.0) else endif elseif currentCount == 2 chosenMessage = box2 self.SetAngle(0.0, 0.0, 90.0) elseif currentCount == 3 chosenMessage = box3 self.SetAngle(0.0, 0.0, -90.0) elseif currentcount ==4 chosenMessage = box4 self.SetAngle(0.0, 0.0, 90.0) endif Return chosenMessage endFunction Edited May 9, 2012 by kazan Link to comment Share on other sites More sharing options...
fg109 Posted May 9, 2012 Share Posted May 9, 2012 Your post is very confusing. Please list step by step what you want to happen. Link to comment Share on other sites More sharing options...
kazan Posted May 9, 2012 Author Share Posted May 9, 2012 Alright here goesStep 0. Player enters room, skull is idleStep 1. Skull is activatedStep 2. A messagebox pops up, with a yes or no relationStep 3. Player clicks yes => rotate skull 180degrees + trap is activated; Player clicks no => close messagebox, nothing happens The rest is basicly a continuation of step 3. I want the skull to not do anything untill the player clicks yes in the messagebox. Link to comment Share on other sites More sharing options...
fg109 Posted May 9, 2012 Share Posted May 9, 2012 I'm going to assume that the skull is the activate parent of your trap, and that's how your trap is triggered. Scriptname atestSkullText extends ObjectReference Message property box1 auto {Are you sure you want to dishonor the dead? Y/N} Message property box2 auto {Fool! Leave my remains alone!} Message property box3 auto {Stop it or I will kill you} Message property box4 auto {Now you die!} Function TurnSkull(Float Angle = 180.0, Float Speed = 180.0) ;Angle = how many degrees to turn it clockwise (default 180) ;Speed = how fast to turn it in degrees per second (default 180) Angle += GetAngleZ() if (Angle > 180) Angle -= 360 elseif (Angle < -180) Angle += 360 endif TranslateTo(X, Y, Z, 0, 0, Angle, 1024.0, Speed) EndFunction Event OnCellAttach() StopTranslation() BlockActivation() SetMotionType(4) MoveToMyEditorLocation() GoToState("Waiting") EndEvent State Waiting Event OnActivate(ObjectReference akActionRef) int choice = box1.Show() if (choice == 0) ;the first choice GoToState("Busy") TurnSkull() Activate(akActionRef, True) endif EndEvent EndState State Busy Event OnActivate(ObjectReference akActionRef) Debug.Notification("Still busy turning.") EndEvent Event OnTranslationComplete() GoToState("Waiting") EndEvent EndState Link to comment Share on other sites More sharing options...
steve40 Posted May 10, 2012 Share Posted May 10, 2012 Ah, I didn't realize that there was a simple "TranslateTo" function available, that's good to know.That script looks pretty tight. Possibly you might want to reset the skull back to its original position after it has fired, especially if the trap can be activated more than once.Also, you might want to show the box2, box3 and box4 messages during the activation, otherwise they are simply redundant. Kazan, a further embellishment would be to replace the box2, box3 and box4 messages with voice recordings. Something you can consider later when you get more comfortable with scripting, etc. Link to comment Share on other sites More sharing options...
kazan Posted May 10, 2012 Author Share Posted May 10, 2012 Ty millions for all the help. I figured out how to make the boxes pop up for following activations of the skull.I was planning on integrating voice recordings but for now I'm going to mess around with the "traps" I'm not sure of wether I should kill the player if he activates the skull a 4th time or to reward him/open another door. I'm making a giant dungeon including 3rooms before you get to the treasure. A survive X amount of waves room, a puzzleroom (hence the traps) and a 4story maze.The waves room starts easy with mudcrabs/skeevers and ends with dragons.The puzzleroom has a giant vertical shaft with a couple of levers, hit the right lever and go to the next room, fail and you fall further down the shaft (if you manage to fall all the way down there are 6levers of which 1opens the door and 4 activate lethal traps haven't figured out what to do with the last lever yet :D) The maze is probably the most anoying part though, it has all sorts of weirdstuff (doors that show you a hall that goes left but when you get there the hall goes right, etc) I think that with this script I know how to script the rest of my dungeon so I'm really pleased :D Link to comment Share on other sites More sharing options...
Recommended Posts