I tried some variations on your code, but your version is the only that works fine. Thanks
onevent EVENT_DRAWWEAPON
ifvarand TEMP4 268435456 // Is the player holding the Alternate Fire key down?
ifvare player[THISACTOR].curr_weapon 3 // M4A1 Carbine Iron Sight
{
setplayer[THISACTOR].runspeed 42100
setvar RETURN -1
setvar x 160
setvarvar WEAP_DISPLAY_TEMP2 WEAPSWAYX
divvar WEAP_DISPLAY_TEMP2 2
subvarvar x WEAP_DISPLAY_TEMP2
setvar y 140
setvarvar WEAP_DISPLAY_TEMP3 WEAPSWAYY
divvar WEAP_DISPLAY_TEMP3 2
subvarvar y WEAP_DISPLAY_TEMP3
setvarvar WEAP_DISPLAY_TEMP4 weapon_xoffset // setvar the weapon x sway to displaytemp4
divvar WEAP_DISPLAY_TEMP4 2 // divide it by 2
addvarvar x WEAP_DISPLAY_TEMP4 // add it to x
subvar x 5 // offset it by 5
subvar y 40
setvar x 160
subvarvar x WEAPSWAYX
subvar x 10
addvarvar x weapon_xoffset
setvar y 142
subvarvar y WEAPSWAYY
rotatesprite x y 52500 0 3825 shade pal 0 0 0 xdim ydim // iron sight
break
}
getplayer[THISACTOR].weapon_pos WEAP_DISPLAY_TEMP2
mulvar WEAP_DISPLAY_TEMP2 -20
setvar tilenum 2536
rotatesprite x y 2536 WEAP_DISPLAY_TEMP2 tilenum shade pal 0 0 0 xdim ydim
setplayer[THISACTOR].runspeed RUNNINGSPEED
endevent
TURNAROUND key has been disabled:
onevent EVENT_TURNAROUND
setvar RETURN -1
endevent
This one will disable the crosshair once iron sight has been activated:
onevent EVENT_DISPLAYCROSSHAIR
ifvare player[THISACTOR].curr_weapon 3
ifvarand TEMP4 268435456
{
setvar RETURN -1
}
endevent
gamevar turnaround_keytime 0 1
gamevar sight_on 0 1
...
ifvarand TEMP4 268435456
{ addvar turnaround_keytime 1 }
else
{ setvar turnaround_keytime 0 }
ifvare turnaround_keytime 1
{ xorvar sight_on 1 }
ifvare sight_on 1
{ /* your code here */ }
....
This post has been edited by RichardStorm: 28 May 2018 - 11:21 AM
This post has been edited by Drek: 28 May 2018 - 11:26 AM
This post has been edited by thisbecasper: 28 May 2018 - 03:29 PM
thisbecasper, on 28 May 2018 - 02:41 PM, said:
This post has been edited by thisbecasper: 28 May 2018 - 04:51 PM
RichardStorm, on 28 May 2018 - 06:11 AM, said:
thisbecasper, on 28 May 2018 - 04:31 PM, said:
Trooper Dan, on 28 May 2018 - 07:24 PM, said:
RichardStorm, on 28 May 2018 - 11:20 AM, said:
gamevar turnaround_keytime 0 1
gamevar sight_on 0 1
...
ifvarand TEMP4 268435456
{ addvar turnaround_keytime 1 }
else
{ setvar turnaround_keytime 0 }
ifvare turnaround_keytime 1
{ xorvar sight_on 1 }
ifvare sight_on 1
{ /* your code here */ }
....
thisbecasper, on 29 May 2018 - 05:29 AM, said:
onevent EVENT_GAME
ifp pfacing
getactor[THISACTOR].extra actorhp
endevent
This post has been edited by thisbecasper: 29 May 2018 - 07:33 AM
This post has been edited by thisbecasper: 10 July 2018 - 02:17 AM
Zaxtor, on 21 July 2018 - 07:28 PM, said:
Zaxtor, on 21 July 2018 - 08:11 PM, said:
int const fistY = klabs(pPlayer->look_ang) / 9;
int const fistZoom = clamp(65536 - (sintable[(512 + (fistInc << 6)) & 2047] << 2), 40920, 90612);
int const fistYOffset = 194 + (sintable[((6 + fistInc) << 7) & 2047] >> 9);
int const fistPal = P_GetHudPal(pPlayer);
int wx[2] = { windowxy1.x, windowxy2.x };
rotatesprite((-fistInc + 222 + (fix16_to_int(g_player[screenpeek].inputBits->q16avel) >> 5)) << 16, (fistY + fistYOffset) << 16,
fistZoom, 0, FIST, fistShade, fistPal, 2, wx[0], windowxy1.y, wx[1], windowxy2.y);
Trooper Dan, on 22 July 2018 - 06:19 PM, said:
int const fistY = klabs(pPlayer->look_ang) / 9;
int const fistZoom = clamp(65536 - (sintable[(512 + (fistInc << 6)) & 2047] << 2), 40920, 90612);
int const fistYOffset = 194 + (sintable[((6 + fistInc) << 7) & 2047] >> 9);
int const fistPal = P_GetHudPal(pPlayer);
int wx[2] = { windowxy1.x, windowxy2.x };
rotatesprite((-fistInc + 222 + (fix16_to_int(g_player[screenpeek].inputBits->q16avel) >> 5)) << 16, (fistY + fistYOffset) << 16,
fistZoom, 0, FIST, fistShade, fistPal, 2, wx[0], windowxy1.y, wx[1], windowxy2.y);
set y1 player[].look_ang div y1 9 abs y1 set z1 65536 set z2 player[].fist_incs shiftl z2 6 add z2 512 and z2 2047 sin z2 z2 sub z1 z2 clamp z1 40920 90612 set y2 player[].fist_incs add y2 6 shiftl y2 7 and y2 2047 sin y2 y2 shiftr y2 9 add y2 194 set x1 input[].q16avel shiftr x1 5 set x2 player[].fist_incs inv x2 add x2 222 add x1 x2 shiftl x1 16 add y1 y2 shiftl y1 16 rotatesprite x1 y1 z1 0 FIST gs actor[player[].i].pal 2050 windowx1 windowy1 windowx2 windowy2
appendevent EVENT_DISPLAYFIST
ife pchar 1
{
set RETURN -1
// thanks to Mblackwell for fist CON code, adapted from Duke source
set y player[].look_ang
div y 9
abs y
set z 65536
set z2 player[].fist_incs
ifg z2 32 set z2 32
shiftl z2 6
add z2 512
and z2 2047
sin z2 z2
sub z z2
clamp z 40920 90612
set y2 player[].fist_incs
ifg y2 32 set y2 32
add y2 6
shiftl y2 7
and y2 2047
sin y2 y2
shiftr y2 9
add y2 194
set x player[].fist_incs
ifg x 32 set x 32
inv x
add x 222
shiftl x 16
add y y2
shiftl y 16
rotatesprite x y z 0 SHELLYFIST gs sprite[player[].i].pal 2050 0 0 xdim ydim
}
endevent
This post has been edited by Trooper Dan: 23 July 2018 - 02:29 AM
thisbecasper, on 14 August 2018 - 11:10 AM, said:
appendevent EVENT_GAME
ifactor HOLODUKE ifn sprite[].statnum 1 changespritestat THISACTOR 1
endevent
Trooper Dan, on 14 August 2018 - 11:16 AM, said:
appendevent EVENT_GAME
ifactor HOLODUKE ifn sprite[].statnum 1 changespritestat THISACTOR 1
endevent
This post has been edited by thisbecasper: 14 August 2018 - 11:53 AM
thisbecasper, on 14 August 2018 - 02:42 PM, said: