Command to return camera pitch?

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Command to return camera pitch?

Post by ZenBudha »

Trying to get a proper flashlight, and perhaps scripted weapons working properly. However I can't seem to find a command to check the camera's pitch.

Seems all AndyCR's flashlight pawn is needing is a way to check the camera's pitch followed by a rotate pawn command.

Sort of like (I'll have to actually look up the commands)
CameraPitch[0]
FlashlightPitch[0]

Pitchcheck ()]

CameraPitch=self.camera_pitch
FlashlightPitch=self.pitch

If (CameraPitch == FlashlightPitch)
RestartOrder (Pitchcheck)

else
NewOrder (ChangePitch)

ChangePitch ()]
RotatePawn (0, CameraPitch, 0)
NewOrder (Pitchcheck)

However I've dug through the script readme (new and old docs) and cannot find a command to check the camera's pitch.

I can check an enemy's pitch however if the pawn does not currently match the camera's pitch then adding a second pawn will do no good since it won't match the camera's pitch for the first pawn to check.

Which kind of puts a nail in the coffin for normal flashlights, scripted weapons, and scripted weapon innacuracy.
Fear not the textures for the almighty stylus is with thee - Book of Zen
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

http://dhost.info/realityfactory/online ... iables.htm
self.camera_pitch

Returns the current camera pitch.
hike1
RF FAQ-Keeper
Posts: 607
Joined: Tue Jul 05, 2005 4:19 am
Contact:

Post by hike1 »

Yeh, there oughta be a way to point the flashlight wherever the weapons can point, kind of goofy restricted to the horizontal.
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

Thanks QoD thats what I was looking for. Wasn't in the script docs though new or old.
Fear not the textures for the almighty stylus is with thee - Book of Zen
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

{

ptch [0]


Spawn[ ()
{
SetNoCollision();
FadeOut(0, 0);
Rotate("" , 10000, 0, ptch, 0, "");
LowLevel("Update");

}]

Update[ ()
{
PositionToPlayer(0, 0, 0);
PositionToPlayer(0, 0, GetCollideDistance("Bip01", 0, 0, 500000)-20, true);
ptch = self.camera_pitch;
HighLevel("Spawn");
}]
}
Here is where I am at so far and this is a modification of AndyCR's Flashlight script. I've tried everything I can think of literally spent over an hour testing it with one little adjustment at a time with no luck.

So any help would be appreciated.
Fear not the textures for the almighty stylus is with thee - Book of Zen
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

well, in this script the pawn's pitch can't match the pitch of the camera because you rotate the pawn camera_pitch degrees instead of setting the pawn's pitch to camera_pitch, also jumping back to the Spawn order is not a very good idea (calling SetCollision and FadeOut each time...)

Why don't you use the low level command ChangePitch?
ChangePitch();

Rotate the Pawn's actor from its current pitch angle towards the pitch angle specified by self.ideal_pitch at a speed of self.pitch_speed degrees per second. When the Pawn's pitch angle reaches the desired angle, rotation will cease.
something similar to this:

Code: Select all

Update[ () 
{ 
PositionToPlayer(0, 0, 20, true); 
self.ideal_pitch = self.camera_pitch; 
ChangePitch();
}]
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

I gave it a try but now the light just shines straight down.
Fear not the textures for the almighty stylus is with thee - Book of Zen
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

Can you send me a small demo of your setup (level, pawn, script) so I can check it out? I'm a bit lazy these days... :wink:
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

Yeah scroll down to AndyCR's scripted flashlight thread. You can try his if you haven't already. Thats what I am testing with.

The script I posted above was nothing more than a modified version of the script in his post.

His flashlight works better than any other I have seen in RF. However if I can get it to match all angles it will only be a small step away from having scripted weapon innacuracy.
Fear not the textures for the almighty stylus is with thee - Book of Zen
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

Ok I think I have located the problem. I turned debug on (I know I'm a rocket scientist).

It seems it's giving me a Method error or whatever for PositionToPlayer command no matter the syntax. I even cut and pasted it from another working script and still a no go.

I also tried PlayerToPosition from the doc's but the same error.

So I took it out figuring it wouldn't move with the player but would still match rotation and pitch.

Then I get the same error as above with the ChangePitch(); command.

Before that I was getting a method error with the RestartOrder(); command. Tried the NewOrder("Update"); command (trying to get the script to loop for hte rotation and pitch matching). Same error.

Really need a debugger program for Simkin of some sort. It's all greek to me and I used to script in VB.

Also according to the docs the self.ideal_pitch also needs the self.pitch_speed command to tell it how fast to rotate. So I also set that in the script at 10000.

If I can get this to work it will simply be a matter of attaching the pawn to Firebone01 in the 1st person wepon. Then having it have an invisible projetile, and do no damage. That way the pawn can detect what weapon is selected, and when the LMB is pressed. Allowing pretty much 1 pawn to be able to handle weapon innacuracy for every weapon.

Also I think using the Random(low, high); command with Rotation commands or perhaps something low level that is faster for pitch, and yaw innacuracy won't be a problem. Now will having multiple shots for shotguns at the same time.
Fear not the textures for the almighty stylus is with thee - Book of Zen
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

ok, here we go:
change the DynamicLight entity to a DSpotLight entity (set Rotate to True)

Code: Select all

{
    
    Spawn[()
    {
        LowLevel("setup");
    }]

    setup[()
    {
        SetNoCollision();
        PawnRender(false);
        self.yaw_speed = 100000;
        self.pitch_speed = 100000;
	
        self.think = "update";
    }]
    
    update[()
    {
        self.ThinkTime = 0.0;
	
        self.ideal_yaw = self.player_yaw;
        ChangeYaw();
	
        PositionToPlayer(0, 30, 10, true);

        self.ideal_pitch = -(self.camera_pitch);
        ChangePitch();
    }]

}
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

there's some inconsistency in the sign of the camera pitch, so in 3rd person view you would have to use:

self.ideal_pitch = self.camera_pitch;
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

hmm there seems to be a bug in the PositionToPlayer code when using it with 4 parameters (rotation) :? need to fix this...
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

Ok I've dug deeper into the code and this is rather a design flaw than a bug.... see bug reports for more details, for now you just have to use a high pitch speed and you may leave out the ChangeYaw() part
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

Great thansk for helping me out Quest.
Fear not the textures for the almighty stylus is with thee - Book of Zen
Post Reply