User talk:Mandrill

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Dragoon Wraith TALK 23:11, 13 August 2006 (EDT): I saw you request MoveMouse, so I thought I'd let you know that v0005 has several functions for moving the mouse, which hadn't been documented before your request (an oversight by yours truly, thank you for the reminder). They are now documented here, here, here, and here.

Dragoon Wraith TALK 11:21, 14 August 2006 (EDT): That could be tricky (we have the tools, but it's going to be complicated). First, your invisible mesh. That depends on whether or not you need a script to be running on it (I suspect not, as you'll only be moving it around and telling it to cast spells - things better done from a Global Script than from a local script. In this case, it has been recommended to me that you use an XMarker - they're generally used for AI packages, but you can use your own fairly easily. Find one, go to it in a cell, and duplicate it (while it's selected, press Ctrl+D). Take yours and double-click it, and type in a unique Reference ID, and if there's a checkbox for Persistant, check it (I can't remember off-hand if there is for markers). Markers are good because they are invisible. Alternatively, you could use just about any other object in the game and put it in a cell somewhere (it won't matter where because we'll move it to the player), and give it a Reference ID and make it Persistant and Initially Disabled.
Now write your global script like this:
float timer
float pos

[...]

if ( refID.GetInSameCell player == 1 )
  refID.MoveTo player
endif

set pos to player.GetPos X
refID.SetPos X pos
set pos to player.GetPos Y
refID.SetPos Y pos
set pos to player.GetPos Z
refID.SetPos Z pos
That will keep the marker on top of the player. So now it should be casting from where the player is, which is good. Two things to keep in mind. First, I'm not sure where the player's Z coordinate is - might be in the middle of the body, or it might be the feet. You'll need to test that. If it's the feet, use GetPos Z + 64 to go half-way up the body. Second, and more importantly, I'm not at all sure that the spell won't hit the player if it is cast from within him - if it does hit the player, you'll have to move the marker a little bit in front of the player - which would be tricky, but you'll have to do it anyway for this next bit.
Now, Cast requires a target - that target is going to be another Marker or disabled object, whose Reference ID I'll call ref2ID. The basic casting will be this:
refID.Cast "spell" ref2ID
What you need is for ref2ID to be right in front of the player's crosshair (invisible, of course) to get the angle right. That requires trigonometry, and this is where things get very tricky. It doesn't have to be far in front of the player, just enough to get the angle of the Cast right. You'll need player.GetAngle Z (left-right) and player.GetAngle X (up-down) to figure out where the player is looking - and then you'll need to figure out the XYZ coordinates for something on the line that the player is looking down. In two dimensions, this is annoying but not too bad, but three is rather tricky.
Basically, at this point, you need what was taught to me as "pre-calculus" to pull this off. A strong understanding of sinusoidal functions is necessary. Do you know how this stuff works?
Dragoon Wraith TALK 15:17, 14 August 2006 (EDT): I kind of suspected that you wouldn't know much about sinusoidal functions - it's the kind of thing you'd only know if you'd dealt with it recently - anyone who hasn't taken a pre-calculus, calculus, or physics course recently, and doesn't deal with this kind of thing regularly as part of their job or something, isn't likely to. I can maybe help with that - because you're right, this would see a lot of application. Basically, it involves use of sine or cosine to create a circle. Not entirely sure how to do it for a sphere myself, but I think I can figure it out. I'll see if I can come up with something.
As for your question about the second activator, you've got it exactly right. The first activator casts it at the second activator, but it goes through the second activator into whatever's in front of the player.
Your worries about global scripts, on the other hand, are incorrect - read the article about them and how fQuestDelayTime works - you can set the script to run every frame (in fact, this functionality is part of the definition of a global script - less than once a frame, and it's just a quest script).
Dragoon Wraith TALK 23:20, 14 August 2006 (EDT): I don't think it'll be too bad, I'll just have to draw some graphs and think about it a bit. I personally have a fairly strong grasp of the functions in question, likely about as good as possible with a high school education, having focussed in math and physics to a large degree. I'll see if I can't come up with something, shouldn't take too long.