Untitled diff

创建于 差异永不过期
27 删除
242 行
107 添加
322 行
object_event_clear(PlayerControl, ev_step, ev_step_begin);
//PrOF 2017

global.joystickExists = false;
global.secondaryDelay = 15;
//If this gets added it'll be a lot cleaner, clearing and adding is just a lot of code

controllerObserver = object_add();
object_set_persistent(controllerObserver, true);
object_event_add(controllerObserver, ev_create, 0, '
mouseLocked = false;
JoystickMouseLockTimer = 0;
mouseStarterY = window_get_width() / 2;
mouseStarterX = window_get_height() / 2;
');


object_event_add(controllerObserver, ev_step, 0, '
if(joystick_exists(1)){
global.joystickExists = true;
JoystickMouseLockTimer += global.delta_factor;
//Cursor movement, inspiration taken form ArrowAim.gml
//TODO Configurable sensitivity
//TODO change deadzone calculation to be a percentage
if (joystick_check_button(1, 7) && JoystickMouseLockTimer >= 10) {
mouseLocked = !mouseLocked;
JoystickMouseLockTimer = 0;
}
if (!mouseLocked) {
if(instance_exists(MenuController)) {
//Menu mode
/* Woo debug stuff, coming hopefully next update
lStickY = joystick_ypos(1)*30;
lStickX = joystick_xpos(1)*30;
if (lStickY < 6 && lStickY > -6 && lStickX < 6 && lStickX > -6){
//Do nothing
}
else {
mouseStarterY = mouseStarterY + lStickY;
mouseStarterX = mouseStarterX + lStickX;
window_mouse_set(mouseStarterX, mouseStarterY);
}
show_message("X " + string(mouseStarterX) + " Y " + string(mouseStarterY));
*/
}
else {
//Gameplay mode
Sensitivity = 150;
//Sniper and quote are handled differently
if (instance_exists(Player)) {
global.secondaryDelay = 15;
/*
if (global.myself.class = CLASS_SNIPER) {
//TODO use old aim method when aimed
Sensitivity = 500;
}
*/
if (global.myself.class = CLASS_QUOTE) {
//Disable the delay between Secondary actions
global.secondaryDelay = 0;
}
}
Text moved with changes from lines 139-144 (99.5% similarity)
mousex = window_get_width() / 2;
mousey = window_get_height() / 2;
rStickY = joystick_rpos(1)*100;
rStickX = joystick_upos(1)*100;
//window_mouse_set(mousex + rStickX, mousey + rStickY);
gradi = arctan2(rStickY, rStickX);
if (rStickY < 20 && rStickY > -20 && rStickX < 20 && rStickX > -20){
//Do nothing
}
else {
window_mouse_set(Sensitivity * cos(gradi) + mousex, Sensitivity * sin(gradi) + mousey);
}
}
}
}
');
instance_create(0,0,controllerObserver);


object_event_add(PlayerControl, ev_create, 0, '
object_event_add(PlayerControl, ev_create, 0, '
//Used by the stupid Special action workaround
//Used by the stupid Special action workaround
JoystickWorkaroundFramesCount = 0;
JoystickSecondaryTimer = 0;
');
');


object_event_clear(PlayerControl, ev_step, ev_step_begin);
object_event_add(PlayerControl, ev_step, ev_step_begin, '
object_event_add(PlayerControl, ev_step, ev_step_begin, '
if(instance_exists(MenuController))
if(instance_exists(MenuController))
exit;
exit;
var kickOpen;
var kickOpen;
kickOpen = false
kickOpen = false
if (instance_exists(ScoreTableController))
if (instance_exists(ScoreTableController))
if (ScoreTableController.showadmin)
if (ScoreTableController.showadmin)
kickOpen = true;
kickOpen = true;
if(instance_exists(TeamSelectController) || instance_exists(ClassSelectController) || kickOpen)
if(instance_exists(TeamSelectController) || instance_exists(ClassSelectController) || kickOpen)
menuOpen = true;
menuOpen = true;
else
else
menuOpen = false;
menuOpen = false;


//Checking for input - Mapped Keys
//Checking for input - Mapped Keys
if(keyboard_check_pressed(global.changeTeam))
if(keyboard_check_pressed(global.changeTeam))
inputChangeTeam();
inputChangeTeam();
if(keyboard_check_pressed(global.changeClass))
if(keyboard_check_pressed(global.changeClass))
inputChangeClass();
inputChangeClass();


event_user(8);
event_user(8);
var keybyte;
var keybyte;
keybyte = 0;
keybyte = 0;


/* KeyByte flags:
/* KeyByte flags:
02 - down
02 - down
08 - primary
08 - primary
10 - secondary
10 - secondary
20 - right
20 - right
40 - left
40 - left
80 - up
80 - up
*/
*/


//character object exists
//character object exists
if(global.myself.object != -1)
if(global.myself.object != -1)
{
{
if(!menuOpen)
if(!menuOpen)
{
{
JoystickWorkaroundFramesCount += 1;
JoystickSecondaryTimer += global.delta_factor;
if(keyboard_check(global.left)) keybyte |= $40;
if(keyboard_check(global.left)) keybyte |= $40;
if(keyboard_check(global.right)) keybyte |= $20;
if(keyboard_check(global.right)) keybyte |= $20;
if(keyboard_check(global.jump)) keybyte |= $80;
if(keyboard_check(global.jump)) keybyte |= $80;
if(keyboard_check(global.down)) keybyte |= $02;
if(keyboard_check(global.down)) keybyte |= $02;
if(keyboard_check(global.taunt)) keybyte |= $01;
if(keyboard_check(global.taunt)) keybyte |= $01;
if(keyboard_check_pressed(global.chat1)) inputChat1();
if(keyboard_check_pressed(global.chat1)) inputChat1();
if(keyboard_check_pressed(global.chat2)) inputChat2();
if(keyboard_check_pressed(global.chat2)) inputChat2();
if(keyboard_check_pressed(global.chat3)) inputChat3();
if(keyboard_check_pressed(global.chat3)) inputChat3();
if(keyboard_check_pressed(global.drop)) inputDrop();
if(keyboard_check_pressed(global.drop)) inputDrop();
if(keyboard_check_pressed(global.medic))
if(keyboard_check_pressed(global.medic))
{
{
inputCallMedic();
inputCallMedic();
}
}
if(!global.myself.humiliated)
if(!global.myself.humiliated)
{
{
if(keyboard_check(global.attack)) keybyte |= $10;
if(keyboard_check(global.attack)) keybyte |= $10;
if(keyboard_check(global.special)) keybyte |= $08;
if(keyboard_check(global.special)) keybyte |= $08;
if(keyboard_check_pressed(global.special)) inputSpecial();
if(keyboard_check_pressed(global.special)) inputSpecial();
if(keyboard_check_pressed(global.taunt)) inputTaunt();
if(keyboard_check_pressed(global.taunt)) inputTaunt();
if(mouse_check_button(mb_left))
if(mouse_check_button(mb_left))
{
{
if(global.attack == MOUSE_LEFT) keybyte |= $10;
if(global.attack == MOUSE_LEFT) keybyte |= $10;
if(global.special == MOUSE_LEFT) keybyte |= $08;
if(global.special == MOUSE_LEFT) keybyte |= $08;
}
}
if(mouse_check_button_pressed(mb_left) and global.special == MOUSE_LEFT)
if(mouse_check_button_pressed(mb_left) and global.special == MOUSE_LEFT)
inputSpecial();
inputSpecial();


if(mouse_check_button(mb_right))
if(mouse_check_button(mb_right))
{
{
if(global.attack == MOUSE_RIGHT) keybyte |= $10;
if(global.attack == MOUSE_RIGHT) keybyte |= $10;
if(global.special == MOUSE_RIGHT) keybyte |= $08;
if(global.special == MOUSE_RIGHT) keybyte |= $08;
}
}
if(mouse_check_button_pressed(mb_right) and global.special == MOUSE_RIGHT)
if(mouse_check_button_pressed(mb_right) and global.special == MOUSE_RIGHT)
inputSpecial();
inputSpecial();
}
}
//Same as Keyboard, but with a Joystick check, maybe some button could be a context action?
//Actual plugin, same as keyboard, but with a Joystick check
//For now it only works with the first controller connected
//Left analog stick could also work using some axis, but it is simpler this way. This will be changed once the controllerObserver gets used
//Left analog stick could also work using some axis, but it is simpler this way. If this many checks lag the game I will change it
if (global.joystickExists) {
if (joystick_exists(1)) {
//Left
//Left
if(joystick_direction(1) == vk_numpad4 || joystick_direction(1) == vk_numpad7 || joystick_direction(1) == vk_numpad1) keybyte |= $40;
if(joystick_direction(1) == vk_numpad4 || joystick_direction(1) == vk_numpad7 || joystick_direction(1) == vk_numpad1) keybyte |= $40;
//Right
//Right
if(joystick_direction(1) == vk_numpad6 || joystick_direction(1) == vk_numpad9 || joystick_direction(1) == vk_numpad3) keybyte |= $20;
if(joystick_direction(1) == vk_numpad6 || joystick_direction(1) == vk_numpad9 || joystick_direction(1) == vk_numpad3) keybyte |= $20;
//Jump
//Jump
if(joystick_check_button(1, 5)) keybyte |= $80;
if(joystick_check_button(1, 5)) keybyte |= $80;
//Down
//Down
if(joystick_direction(1) == vk_numpad2 || joystick_direction(1) == vk_numpad1 || joystick_direction(1) == vk_numpad3) keybyte |= $02;
if(joystick_direction(1) == vk_numpad2 || joystick_direction(1) == vk_numpad1 || joystick_direction(1) == vk_numpad3) keybyte |= $02;