Scripted Weapon doubt

Topics regarding Scripting with Reality Factory
Post Reply
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Scripted Weapon doubt

Post by Danimita92 »

Hi everybody. I've got a little doubt, you see I'm creating a Scripted Weapon in first person view, but I can't manage to make it rotate upwards or downwards like a normal weapon. Is there a way to do this?
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Scripted Weapon doubt

Post by darksmaster923 »

Herp derp.
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Scripted Weapon doubt

Post by Danimita92 »

Thanks, I tried, but it wont work.
I¡ll explain:
-I'm using a scripted player, with a camera in first person attached to an entity with offsets, so even if it's in a first person view, you see the scripted player from behind.
- When I'm pressing a certain key, the camera's offset take the camera closer to the player, and the scripted player stops being shown.
- Then, the scripted weapon appears where the scripted player was, and...

Now this weapon should move like a real weapon. I need to know how to do this. I looked at the other post, and have been all afternoon trying but several wrong things have happened, like the pawn rotating the wrong way (i look up, it rotates backwards and viceversa).

Here's the camera's script:

Code: Select all

{

Spawn[()
{
Console(true);
LowLevel("Init");
}]

Init[()
{
    if(GetEventState("AIM")=false)
    {
        PositionToPawn("jugador",-65,-5,-145,true,true);
        AttachCamera();
    }
    if(IsKeyDown(73))
    {
        PositionToPawn("weapon",-45,15,-55,true,true);
        AttachCamera();
    }        
}]

}
And the weapon script:

Code: Select all

{
   
Spawn[()
   {
       self.pitch_speed = 182;
       Console(true); //Turns on debug
       HideFromRadar(true);
       BoxWidth(20);
       BoxHeight(40);
       LowLevel("Setup");
    }]

   Setup[()
   {
    if(IsKeyDown(73))
        {
            PawnRender(true);
            PositionToPawn("jugador",0,0,0,true,true);
            self.ideal_pitch = self.camera_pitch;
            self.ideal_yaw = self.player_yaw;
            ChangeYaw();
            ChangePitch();
        }
    else
       {
            SetEventState("AIM", false);
       }
   }]       
}
Thanks for your time, i hope you know how to help.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Scripted Weapon doubt

Post by darksmaster923 »

first in your camera script

Code: Select all

{

Spawn[()
{
Console(true);
LowLevel("Init");
}]

Init[()
{
    if(GetEventState("AIM")=false)
    {
        PositionToPawn("jugador",-65,-5,-145,true,true);
        AttachCamera();
    }
    if(IsKeyDown(73))
    {
        PositionToPawn("weapon",-45,15,-55,true,true);
        AttachCamera();
    }       
}]

}
you have attachcamera(); on if states. you should have it start the beginning.
and you have to add this to the weapon script
camerapitchtemp = self.camera_pitch*10;
PositionToPawn("player",offsetX,75+offsetY+camerapitchtemp,offsetZ+camerapitchtemp,true,false);
juutis's one is probably better, but the code goes off the screen for me
Herp derp.
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Scripted Weapon doubt

Post by Danimita92 »

First of all, thanks for your time. I'm getting there. Now my problems are that each time the weapon appears, it appears looking at the same direction the pawn started. When i rotate the camera horizontally, it'll rotate around it, but the weapon wont rotate. AND, :wink: when i rotate the camera vertically, it rotates, but the other way around (if i look up, it'll rotate to look downwards and viceversa).

The player is doing this at the moment:

Code: Select all

Aim[()
{
    if(IsKeyDown(73))
    {
        PlayerRender(false);
        self.ideal_yaw=self.player_yaw;
        ChangeYaw();
        PawnRender(false);
        self.ThinkTime=0;
    }
    else
    {
        self.think = "RunPlayer";
        return 0;
    }
}]
The camera script:

Code: Select all

{

Spawn[()
{
Console(true);
LowLevel("Init");
}]

Init[()
{
    AttachCamera();
    if(GetEventState("AIM")=false)
    {
        PositionToPawn("jugador",-65,-5,-145,true,true);
    }
    if(IsKeyDown(73))
    {
        PositionToPawn("jugador",-45,15,-55,true,true);
    }        
}]

}
And the weapon:

Code: Select all

{
   
Spawn[()
   {
       self.pitch_speed = 182;
       Console(true); //Turns on debug
       HideFromRadar(true);
       BoxWidth(20);
       BoxHeight(40);
       LowLevel("Setup");
    }]

   Setup[()
   {
    if(IsKeyDown(73))
        {
            PawnRender(true);
            self.ideal_pitch = self.camera_pitch;
            self.ideal_yaw = self.player_yaw;
            ChangeYaw();
            ChangePitch();
            camerapitchtemp = self.camera_pitch*10;
            PositionToPawn("jugador",0,75+0+camerapitchtemp,0+camerapitchtemp,true,false);
        }
    else
       {
           PawnRender(false); 
           SetEventState("AIM", false);
       }
   }]       
}
Thanks for your help :D
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Scripted Weapon doubt

Post by Danimita92 »

:( Nobody? I really want to fix this, or else my project can't go on.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Scripted Weapon doubt

Post by darksmaster923 »

sorry, didnt see your post before. so the weapon rotates, but doesnt move?
Herp derp.
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Scripted Weapon doubt

Post by Danimita92 »

The camera rotates around it horizontaly, the actual weapon only rotates verticaly. And when it rotates verticaly, it does so the other way around. I look up, ir rotates to look down, and viceversa.
PS: I dont want the weapon to move, just rotate like a normal weapon.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Scripted Weapon doubt

Post by Juutis »

You're missing 'self.yaw_speed = ... ;' in the weapon script. Dunno if this is the problem though. Normally I would test the script in RF myself but at the moment I don't have the time for that.

***EDIT***
Oh, and try 'self.ideal_pitch = -self.camera_pitch;' for the pitch issue.
Pain is only psychological.
Post Reply