Page 1 of 1

turn 180 º

Posted: Thu Nov 29, 2012 5:07 pm
by doomero
i need a simple script for turn 180º the player

RE: turn 180 º

Posted: Thu Nov 29, 2012 7:02 pm
by Watermelon
Two ways of doing it:

1) Have a clientside script do the turn 180 command
2) Get actor angle, add 0.5... you may need to subtract 1.0 if its greater than 1.0 and the engine doesn't handle it right.

RE: turn 180 º

Posted: Thu Nov 29, 2012 7:03 pm
by Qent
http://zdoom.org/wiki/GetActorAngle
http://zdoom.org/wiki/SetActorAngle

Didn't test, but try something like

Code: Select all

script 123 (void) {
  SetActorAngle(ActivatorTID(), GetActorAngle(ActivatorTID()) + 0.5);
}
assuming you've assigned TIDs to players somehow.

EDIT: Ninja'd. :V

RE: turn 180 º

Posted: Thu Nov 29, 2012 7:07 pm
by doomero
yes, i used that script and works good thanks =)

RE: turn 180 º

Posted: Thu Nov 29, 2012 9:19 pm
by Ænima
You could even smooth it out across several calls of that function and make it look RE-style. Which is what I assume you're going to use it for. :P

RE: turn 180 º

Posted: Sat Dec 01, 2012 5:01 pm
by Ijon Tichy
Well I have a little script that, when run on a player, will smoothly turn them x amount of degrees. You can also specify which way it goes, and the factor argument controls how fast the turning happens. Higher values slow it down.

Code: Select all

script PARKMORE_TURN (int degrees, int factor, int direction) net clientside
{
    if (degrees < 0)
    {
        degrees *= -1;
        direction = cond(direction == CLOCKWISE, COUNTERCLOCKWISE, CLOCKWISE);
    }
    
    factor = cond(factor, factor, 4);

    int prevDegrees, addDegrees, curAngle;
    int curDegrees = 0;
    int floatDegrees = itof(degrees);
    int dirMult = cond(direction == CLOCKWISE, -1, 1);

    while (curDegrees < (floatDegrees - 0.1))
    {
        prevDegrees = curDegrees;
        addDegrees = (floatDegrees - curDegrees) / factor;
        curDegrees += addDegrees;

        SetActorAngle(0, GetActorAngle(0) + ((addDegrees * dirMult) / 360));
        Delay(1);
    }

    addDegrees = floatDegrees - curDegrees;
    SetActorAngle(0, GetActorAngle(0) + ((addDegrees * dirMult) / 360));
}
edit: you might want to #define PARKMORE_TURN or change the PARKMORE_TURN to a script number

RE: turn 180 º

Posted: Sat Dec 01, 2012 5:40 pm
by doomero
Ijon Tichy wrote: Well I have a little script that, when run on a player, will smoothly turn them x amount of degrees. You can also specify which way it goes, and the factor argument controls how fast the turning happens. Higher values slow it down.

Code: Select all

script PARKMORE_TURN (int degrees, int factor, int direction) net clientside
{
    if (degrees < 0)
    {
        degrees *= -1;
        direction = cond(direction == CLOCKWISE, COUNTERCLOCKWISE, CLOCKWISE);
    }
    
    factor = cond(factor, factor, 4);

    int prevDegrees, addDegrees, curAngle;
    int curDegrees = 0;
    int floatDegrees = itof(degrees);
    int dirMult = cond(direction == CLOCKWISE, -1, 1);

    while (curDegrees < (floatDegrees - 0.1))
    {
        prevDegrees = curDegrees;
        addDegrees = (floatDegrees - curDegrees) / factor;
        curDegrees += addDegrees;

        SetActorAngle(0, GetActorAngle(0) + ((addDegrees * dirMult) / 360));
        Delay(1);
    }

    addDegrees = floatDegrees - curDegrees;
    SetActorAngle(0, GetActorAngle(0) + ((addDegrees * dirMult) / 360));
}
edit: you might want to #define PARKMORE_TURN or change the PARKMORE_TURN to a script number
this could work on multiplayer?

RE: turn 180 º

Posted: Sat Dec 01, 2012 5:44 pm
by Ijon Tichy
It works in Parkmore, at least on players. If you don't need smooth turning, just add 0.5 to the actor's angle as illustrated above.

RE: turn 180 º

Posted: Sat Dec 01, 2012 6:52 pm
by doomero
Ijon Tichy wrote: It works in Parkmore, at least on players. If you don't need smooth turning, just add 0.5 to the actor's angle as illustrated above.
thanks dude i will test this script =)