2012-08-16 21:48:16 +00:00
|
|
|
/*
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
Duke Nukem 3D SplitScreen mod
|
|
|
|
Beta 1
|
|
|
|
By Bloodclaw
|
2012-08-16 21:48:18 +00:00
|
|
|
|
|
|
|
Modified from original for use with EDuke32 SVN.
|
2014-01-12 14:04:51 +00:00
|
|
|
Requires an EDuke32 binary built with SPLITSCREEN_MOD_HACKS preprocessor flag.
|
|
|
|
Usage: eduke32 -mx splitscr.con -q2
|
2012-08-16 21:48:16 +00:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Key name definitions
|
|
|
|
definegamefuncname 11 P2_Move_Forward
|
|
|
|
definegamefuncname 12 P2_Move_Backward
|
|
|
|
definegamefuncname 13 P2_Turn_Left
|
|
|
|
definegamefuncname 14 P2_Turn_Right
|
|
|
|
definegamefuncname 17 P2_Aim_Up
|
|
|
|
definegamefuncname 18 P2_Aim_Down
|
|
|
|
definegamefuncname 19 P2_Fire
|
|
|
|
definegamefuncname 20 P2_Open
|
|
|
|
definegamefuncname 21 P2_Jump
|
|
|
|
definegamefuncname 22 P2_Crouch
|
|
|
|
definegamefuncname 23 P2_Inventory
|
|
|
|
definegamefuncname 24 P2_Inventory_Left
|
|
|
|
definegamefuncname 25 P2_Inventory_Right
|
|
|
|
definegamefuncname 26 P2_Quick_Kick
|
|
|
|
definegamefuncname 27 P2_Previous_Weapon
|
|
|
|
definegamefuncname 28 P2_Next_Weapon
|
|
|
|
|
|
|
|
|
2012-08-16 21:48:18 +00:00
|
|
|
gamevar pid 1 0 // This hold player 2 id
|
|
|
|
gamevar pnum 0 0 // This is set to player 2 sprite number
|
|
|
|
|
|
|
|
// Temp variables
|
2012-08-20 21:23:48 +00:00
|
|
|
gamevar tmp 0 0
|
2012-08-16 21:48:18 +00:00
|
|
|
gamevar px 0 0 // Player (both 1 and 2) X coordinate
|
|
|
|
gamevar py 0 0 // Player Y coordinate
|
|
|
|
gamevar pz 0 0 // Player Z coordinate
|
|
|
|
gamevar psect 0 0 // Player sector number
|
|
|
|
gamevar pang 0 0 // Player angle
|
|
|
|
gamevar phoriz 0 0 // Player vertical angle
|
|
|
|
gamevar phorizoff 0 0 // Something similar
|
|
|
|
gamevar pangcos 0 0 // Cosinus of player angle (used for player 2 movements)
|
|
|
|
gamevar pangsin 0 0 // Sinus of player angle
|
|
|
|
gamevar pinput 0 0 // Set to input, used in the PROCESSINPUT event
|
|
|
|
|
|
|
|
gamevar pcrosshair 0 0 // Do you like crosshairs? Game options will tell.
|
2012-08-20 21:29:54 +00:00
|
|
|
gamevar crossscale 0 0 // crosshair scale
|
2012-08-16 21:48:18 +00:00
|
|
|
gamevar pweapon 0 0 // Player weapon
|
|
|
|
|
|
|
|
gamevar p1heat 0 0 // Common night vision googles
|
|
|
|
gamevar p2heat 0 0
|
|
|
|
|
2012-08-16 21:48:16 +00:00
|
|
|
|
|
|
|
// Crosshair need to be redone for two players
|
|
|
|
onevent EVENT_DISPLAYCROSSHAIR
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
2012-08-16 21:49:01 +00:00
|
|
|
|
|
|
|
define KNEE_WEAPON 0
|
|
|
|
define PISTOL_WEAPON 1
|
|
|
|
define SHOTGUN_WEAPON 2
|
|
|
|
define CHAINGUN_WEAPON 3
|
|
|
|
define RPG_WEAPON 4
|
|
|
|
define HANDBOMB_WEAPON 5
|
|
|
|
define SHRINKER_WEAPON 6
|
|
|
|
define DEVISTATOR_WEAPON 7
|
|
|
|
define TRIPBOMB_WEAPON 8
|
|
|
|
define FREEZE_WEAPON 9
|
|
|
|
define HANDREMOTE_WEAPON 10
|
|
|
|
define GROW_WEAPON 11
|
|
|
|
|
|
|
|
// Next and previous weapon actions will never pick the expander.
|
2012-08-16 21:48:16 +00:00
|
|
|
onevent EVENT_NEXTWEAPON
|
|
|
|
getplayer[THISACTOR].curr_weapon pweapon
|
2012-08-21 17:37:54 +00:00
|
|
|
ifvare pweapon HANDBOMB_WEAPON // XXX: HANDREMOTE_WEAPON?
|
|
|
|
{
|
|
|
|
getplayer[THISACTOR].subweapon tmp
|
|
|
|
andvar tmp 0xfffff7ff
|
|
|
|
setplayer[THISACTOR].subweapon tmp
|
|
|
|
}
|
2012-08-16 21:49:01 +00:00
|
|
|
else ifvare pweapon SHRINKER_WEAPON
|
2012-08-21 17:37:54 +00:00
|
|
|
{
|
|
|
|
ifvarg player[THISACTOR].ammo_amount GROW_WEAPON 0
|
|
|
|
setvar RETURN SHRINKER_WEAPON // select expander
|
|
|
|
// else select next weapon
|
|
|
|
}
|
2012-08-16 21:48:16 +00:00
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_PREVIOUSWEAPON
|
|
|
|
getplayer[THISACTOR].curr_weapon pweapon
|
2012-08-21 17:37:54 +00:00
|
|
|
|
2012-08-16 21:49:01 +00:00
|
|
|
ifvare pweapon DEVISTATOR_WEAPON
|
2012-08-16 21:48:16 +00:00
|
|
|
{
|
2012-08-21 17:37:54 +00:00
|
|
|
ifvarg player[THISACTOR].ammo_amount GROW_WEAPON 0
|
|
|
|
{
|
|
|
|
getplayer[THISACTOR].subweapon tmp
|
|
|
|
orvar tmp 0x800
|
|
|
|
setplayer[THISACTOR].subweapon tmp
|
|
|
|
// select previous weapon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ifvare pweapon GROW_WEAPON
|
|
|
|
{
|
|
|
|
ifvarg player[THISACTOR].ammo_amount SHRINKER_WEAPON 0
|
|
|
|
setvar RETURN SHRINKER_WEAPON // select shrinker
|
|
|
|
// else select previous weapon
|
2012-08-16 21:48:16 +00:00
|
|
|
}
|
|
|
|
endevent
|
|
|
|
|
|
|
|
// Disable all the following keys, need room for player 2
|
|
|
|
onevent EVENT_LOOKUP // Move Forward
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_LOOKDOWN // Move Backward
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_LOOKLEFT // Turn Left
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_LOOKRIGHT // Turn Right
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_AIMUP // Aim Up
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_AIMDOWN // Aim Down
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY1 // Fire
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY2 // Open
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY3 // Jump
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY4 // Crouch
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY5 // Inventory
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY6 // Inventory Left
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY7 // Inventory Right
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY8 // Quick Kick
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY9 // Previous Weapon
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
onevent EVENT_WEAPKEY10 // Next Weapon
|
|
|
|
setvar RETURN -1
|
|
|
|
endevent
|
|
|
|
|
|
|
|
|
|
|
|
// Controls for player 2
|
|
|
|
onevent EVENT_PROCESSINPUT // I had to use this event in case player 1 die
|
|
|
|
getinput[THISACTOR].bits pinput
|
|
|
|
|
|
|
|
ifvarand pinput 8
|
|
|
|
{
|
|
|
|
setinput[pid].bits 8
|
|
|
|
ifvarl phoriz 199 addvar phoriz 14
|
|
|
|
setplayer[pid].horiz phoriz // For some reasons, only setting the bits won't work
|
|
|
|
}
|
|
|
|
ifvarand pinput 16
|
|
|
|
{
|
|
|
|
setinput[pid].bits 16
|
|
|
|
ifvarg phoriz 1 subvar phoriz 14
|
|
|
|
setplayer[pid].horiz phoriz
|
|
|
|
}
|
|
|
|
ifvarand pinput 64
|
|
|
|
{
|
|
|
|
setinput[pid].avel -20
|
|
|
|
}
|
|
|
|
ifvarand pinput 128
|
|
|
|
{
|
|
|
|
setinput[pid].avel 20
|
|
|
|
}
|
|
|
|
ifvarand pinput 8192 // This block and the following one are for moving forward and backward, with X and Y speeds set with help of sinus and cosinus
|
|
|
|
{
|
|
|
|
setvar RETURN -1
|
|
|
|
getplayer[pid].i pnum
|
|
|
|
getactor[pnum].ang pang
|
|
|
|
cos pangcos pang
|
|
|
|
mulvar pangcos 10
|
|
|
|
divvar pangcos 64
|
|
|
|
sin pangsin pang
|
|
|
|
mulvar pangsin 10
|
|
|
|
divvar pangsin 64
|
|
|
|
setinput[pid].fvel pangcos
|
|
|
|
setinput[pid].svel pangsin
|
|
|
|
}
|
|
|
|
ifvarand pinput 16384
|
|
|
|
{
|
|
|
|
setvar RETURN -1
|
|
|
|
getplayer[pid].i pnum
|
|
|
|
getactor[pnum].ang pang
|
|
|
|
cos pangcos pang
|
|
|
|
mulvar pangcos -10
|
|
|
|
divvar pangcos 64
|
|
|
|
sin pangsin pang
|
|
|
|
mulvar pangsin -10
|
|
|
|
divvar pangsin 64
|
|
|
|
setinput[pid].fvel pangcos
|
|
|
|
setinput[pid].svel pangsin
|
|
|
|
}
|
|
|
|
// Following code come from Eduke32 wiki
|
|
|
|
shiftvarr pinput 8
|
|
|
|
andvar pinput 0xF
|
|
|
|
switch pinput
|
|
|
|
case 1:
|
|
|
|
setinput[pid].bits 4
|
|
|
|
break
|
|
|
|
case 2:
|
|
|
|
setinput[pid].bits 536870912
|
|
|
|
break
|
|
|
|
case 3:
|
|
|
|
setinput[pid].bits 1
|
|
|
|
break
|
|
|
|
case 4:
|
|
|
|
setinput[pid].bits 2
|
|
|
|
break
|
|
|
|
case 5:
|
|
|
|
setinput[pid].bits 1073741824
|
|
|
|
break
|
|
|
|
case 6:
|
|
|
|
setinput[pid].bits 1048576
|
|
|
|
break
|
|
|
|
case 7:
|
|
|
|
setinput[pid].bits 134217728
|
|
|
|
break
|
|
|
|
case 8:
|
|
|
|
setinput[pid].bits 4194304
|
|
|
|
break
|
|
|
|
case 9:
|
|
|
|
setinput[pid].bits 2816
|
|
|
|
break
|
|
|
|
case 10:
|
|
|
|
setinput[pid].bits 3072
|
|
|
|
break
|
|
|
|
endswitch
|
|
|
|
endevent
|
|
|
|
|
|
|
|
|
2012-08-16 21:48:31 +00:00
|
|
|
// NOTE: status bar is displayed for both players (EDuke32 splitscreen hack)
|
2012-08-16 21:48:16 +00:00
|
|
|
|
|
|
|
|
2012-08-20 21:29:54 +00:00
|
|
|
// orientation bits for the crosshairs for left/right split
|
2012-08-16 21:49:01 +00:00
|
|
|
define ORIENT 1032 // 26
|
2012-08-16 21:48:18 +00:00
|
|
|
|
|
|
|
// gametext args
|
|
|
|
define P1X 4
|
|
|
|
define P2X 164
|
|
|
|
|
2012-08-20 21:23:48 +00:00
|
|
|
gamevar arg_player_id 0 0
|
|
|
|
|
|
|
|
state show_player_view
|
|
|
|
getplayer[arg_player_id].posx px
|
|
|
|
getplayer[arg_player_id].posy py
|
|
|
|
getplayer[arg_player_id].posz pz
|
|
|
|
getplayer[arg_player_id].ang pang
|
|
|
|
getplayer[arg_player_id].horiz phoriz
|
|
|
|
getplayer[arg_player_id].horizoff phorizoff
|
|
|
|
addvarvar phoriz phorizoff
|
|
|
|
|
|
|
|
// simulate corresponding part in G_DrawRooms (almost)
|
|
|
|
ifvarvare player[arg_player_id].spritebridge 0
|
|
|
|
{
|
|
|
|
setvarvar tmp player[arg_player_id].truecz
|
|
|
|
addvar tmp 1024
|
|
|
|
ifvarvarl pz tmp
|
|
|
|
setvarvar pz tmp
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setvarvar tmp player[arg_player_id].truefz
|
|
|
|
subvar tmp 1024
|
|
|
|
ifvarvarg pz tmp
|
|
|
|
setvarvar pz tmp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getplayer[arg_player_id].cursectnum psect
|
|
|
|
|
|
|
|
ifvarg psect -1
|
|
|
|
{
|
2012-08-20 21:28:48 +00:00
|
|
|
getuserdef .screen_size tmp
|
|
|
|
|
|
|
|
ifvare tmp 0
|
|
|
|
{
|
|
|
|
// above/below split: first player is above
|
|
|
|
ifvare arg_player_id 0
|
|
|
|
showviewunbiased px py pz pang phoriz psect 0 0 319 100
|
|
|
|
else
|
|
|
|
showviewunbiased px py pz pang phoriz psect 0 100 319 199
|
|
|
|
}
|
2012-08-20 21:23:48 +00:00
|
|
|
else
|
2012-08-20 21:28:48 +00:00
|
|
|
{
|
|
|
|
// side by side split: first player is left
|
|
|
|
ifvare arg_player_id 0
|
|
|
|
showviewunbiased px py pz pang phoriz psect 0 0 160 199
|
|
|
|
else
|
|
|
|
showviewunbiased px py pz pang phoriz psect 160 0 319 199
|
|
|
|
}
|
2012-08-20 21:23:48 +00:00
|
|
|
}
|
|
|
|
ends
|
|
|
|
|
2012-08-16 21:48:31 +00:00
|
|
|
onevent EVENT_DISPLAYROOMS
|
|
|
|
setvar RETURN 1 // don't draw them
|
|
|
|
|
|
|
|
// an EDuke32 hack now:
|
|
|
|
// setplayer[THISACTOR].rotscrnang 0 // (almost) Prevent the screen rotation when player 1 die
|
2012-08-16 21:48:16 +00:00
|
|
|
|
2012-08-20 21:23:48 +00:00
|
|
|
// DRAW THE PLAYER VIEWS!
|
|
|
|
setvar arg_player_id 0
|
|
|
|
state show_player_view
|
|
|
|
setvar arg_player_id 1
|
|
|
|
state show_player_view
|
2012-08-16 21:48:16 +00:00
|
|
|
|
|
|
|
// Draw crosshairs if they are enabled
|
|
|
|
getuserdef[THISACTOR].crosshair pcrosshair
|
|
|
|
ifvare pcrosshair 1
|
|
|
|
{
|
2012-08-20 21:29:54 +00:00
|
|
|
getuserdef .crosshairscale crossscale
|
|
|
|
shiftvarl crossscale 16, divvar crossscale 100
|
|
|
|
|
|
|
|
getuserdef .screen_size tmp
|
|
|
|
ifvarn tmp 0
|
|
|
|
{
|
|
|
|
// left/right
|
|
|
|
|
|
|
|
rotatesprite 80 100 crossscale 0 CROSSHAIR 0 0 ORIENT 0 0 xdim ydim
|
|
|
|
rotatesprite 240 100 crossscale 0 CROSSHAIR 0 0 ORIENT 0 0 xdim ydim
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// above/below
|
|
|
|
setvar tmp 8
|
|
|
|
rotatesprite 160 50 crossscale 0 CROSSHAIR 0 0 tmp 0 0 xdim ydim
|
|
|
|
rotatesprite 160 150 crossscale 0 CROSSHAIR 0 0 tmp 0 0 xdim ydim
|
|
|
|
}
|
2012-08-16 21:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-16 21:48:36 +00:00
|
|
|
// NOTE: weapons are drawn for both players now (EDuke32 hack)
|
2012-08-16 21:48:16 +00:00
|
|
|
endevent
|