turn 180 º

Discuss all aspects related to modding Zandronum here.
Post Reply
doomero
Forum Regular
Posts: 134
Joined: Tue Jun 05, 2012 3:45 am

turn 180 º

#1

Post by doomero » Thu Nov 29, 2012 5:07 pm

i need a simple script for turn 180º the player
Last edited by doomero on Thu Nov 29, 2012 6:24 pm, edited 1 time in total.

Watermelon
Zandrone
Posts: 1244
Joined: Thu Jun 28, 2012 9:07 pm
Location: Rwanda

RE: turn 180 º

#2

Post by Watermelon » Thu Nov 29, 2012 7:02 pm

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.

Qent
Retired Staff / Community Team Member
Posts: 1424
Joined: Tue May 29, 2012 7:56 pm
Contact:

RE: turn 180 º

#3

Post by Qent » Thu Nov 29, 2012 7:03 pm

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
Last edited by Qent on Thu Nov 29, 2012 7:04 pm, edited 1 time in total.

doomero
Forum Regular
Posts: 134
Joined: Tue Jun 05, 2012 3:45 am

RE: turn 180 º

#4

Post by doomero » Thu Nov 29, 2012 7:07 pm

yes, i used that script and works good thanks =)

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

RE: turn 180 º

#5

Post by Ænima » Thu Nov 29, 2012 9:19 pm

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
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: turn 180 º

#6

Post by Ijon Tichy » Sat Dec 01, 2012 5:01 pm

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
Last edited by Ijon Tichy on Sat Dec 01, 2012 5:02 pm, edited 1 time in total.

doomero
Forum Regular
Posts: 134
Joined: Tue Jun 05, 2012 3:45 am

RE: turn 180 º

#7

Post by doomero » Sat Dec 01, 2012 5:40 pm

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?

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: turn 180 º

#8

Post by Ijon Tichy » Sat Dec 01, 2012 5:44 pm

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.

doomero
Forum Regular
Posts: 134
Joined: Tue Jun 05, 2012 3:45 am

RE: turn 180 º

#9

Post by doomero » Sat Dec 01, 2012 6:52 pm

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 =)

Post Reply