Page 1 of 1

Security cameras

Posted: Tue Sep 15, 2009 3:29 pm
by jamieo01
Hi, I am going to try to include the ability in my game to take control of cameras with a special gun so that you can see round corners to check for bad guys. Is this possible using just entitys if not how else could I do it. Thanks in advance

Re: Security cameras

Posted: Tue Sep 15, 2009 4:30 pm
by Juutis
Well, with a bit of scripting it's definitely possible:

Just add a pawn with this script:

Code: Select all

{
    
    ATTRIBUTE           [enemy_health]  //attribute that needs to be damaged for the camera to kick in
    TIMEON              [3]             //how many seconds the camera is active
    ABORTKEY            [46]            //the key that deactivates the camera instantly
                                        //46 is space
    timer               [0]
    initialview         [0]

Spawn[ ()
{
    Gravity(false);
    NewOrder("Init");
} ]

Init[ ()
{
    SetEventState(EntityName,false);
    AttributeOrder(ATTRIBUTE,1,"RunCamera");
    NewOrder("Wait");
} ]

Wait[ ()
{
} ]

RunCamera[ ()
{
    SetEventState(EntityName,true);
    timer = time + TIMEON;
    initialview = player_viewpoint;
    LowLevel("activate");
} ]

activate[ ()
{
    ThinkTime = 0;
    SwitchView(3);
    SetKeyPause(true);
    
    if((timer < time) or IsKeyDown(ABORTKEY))
    {
        SetKeyPause(false);
        SwitchView(initialview);
        HighLevel("Init");
        return;
    }
} ]

}
Give the pawn a name (szEntityName). This name will then be the trigger for a FixedCamera entity you're going to use to change the view. So add a FixedCamera entity and in the field ForceTrigger enter the name of the pawn.

Re: Security cameras

Posted: Wed Sep 16, 2009 10:44 pm
by jamieo01
Cool i'll try it out tommrow. Thanks a lot juutis :D