May 09, 2021, 12:49:58 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Due to a rise in bot activity, new posters need to be approved before posting.

Join the community Discord server!

Pages: [1]

Author Topic: middleClickClassSpeechBubble  (Read 1279 times)

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3492
  • she's never quite as dead as you think
middleClickClassSpeechBubble
« on: April 06, 2013, 01:37:33 pm »

As requested by Cerapter.

Middle-click on a player and you'll "say" the bubble matching their team and class.

Code: [Select]
// ajf 2013
// Made in response to this request: http://www.ganggarrison.com/forums/index.php?topic=33614.0
// Plugin thread: http://www.ganggarrison.com/forums/index.php?topic=33641.0

// Mapping needed because ordering of bubbles != ordering of class constants
global.classBubbles[CLASS_SCOUT] = 0;
global.classBubbles[CLASS_PYRO] = 1;
global.classBubbles[CLASS_SOLDIER] = 2;
global.classBubbles[CLASS_HEAVY] = 3;
global.classBubbles[CLASS_DEMOMAN] = 4;
global.classBubbles[CLASS_MEDIC] = 5;
global.classBubbles[CLASS_ENGINEER] = 6;
global.classBubbles[CLASS_SPY] = 7;
global.classBubbles[CLASS_SNIPER] = 8;

object_event_add(Character, ev_mouse, ev_global_middle_press, '
    var bubbleImage;

    // We have to use global_middle_press and this
    // because Character hit boxes are way too small to be useful
    if (distance_to_point(mouse_x, mouse_y) < 25) {
        // prevent enemy cloaked spy detection
        if (!(cloak && team != global.myself.team)) {
            if (player.class != CLASS_QUOTE) {
                bubbleImage = global.classBubbles[player.class];
                if (player.team == TEAM_BLUE) {
                    bubbleImage += 10;
                }
            } else {
                bubbleImage = 47;
                if (player.team == TEAM_BLUE) {
                    bubbleImage += 1;
                }
            }
            write_ubyte(global.serverSocket, CHAT_BUBBLE);
            write_ubyte(global.serverSocket, bubbleImage);
        }
    }
');
« Last Edit: April 06, 2013, 01:40:05 pm by Andrea »
Logged
aka Andrea.

did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

Danikah

  • Guest
Re: middleClickClassSpeechBubble
« Reply #1 on: April 06, 2013, 02:30:18 pm »

I send my kisses
Logged

Nova

  • Seasoned Member
  • *****
  • Karma: 4
  • Offline Offline
  • Posts: 1740
  • Personal Text
Re: middleClickClassSpeechBubble
« Reply #2 on: April 20, 2013, 02:37:46 am »

Is it possible to change the Button to "q"? If so, how?
Logged

Takapajula

  • Junior Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 178
  • Quantity is a quality all it''''''''s own.
Re: middleClickClassSpeechBubble
« Reply #3 on: April 20, 2013, 03:37:38 am »

Is it possible to change the Button to "q"? If so, how?
Logged
hey could somebody create a plugin or autohotkey script thingy to make firebugs flareblast useable by pressing middle mouse button k thx

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6426
  • Developer
Re: middleClickClassSpeechBubble
« Reply #4 on: April 20, 2013, 04:29:24 am »

Is it possible to change the Button to "q"? If so, how?

Code: [Select]
// ajf 2013 (copyright ololol)
// Made in response to this request: http://www.ganggarrison.com/forums/index.php?topic=33614.0
// Plugin thread: http://www.ganggarrison.com/forums/index.php?topic=33641.0

global.class_image_letter = 'Q'; // Change this to re-bind the key

// Mapping needed because ordering of bubbles != ordering of class constants
global.classBubbles[CLASS_SCOUT] = 0;
global.classBubbles[CLASS_PYRO] = 1;
global.classBubbles[CLASS_SOLDIER] = 2;
global.classBubbles[CLASS_HEAVY] = 3;
global.classBubbles[CLASS_DEMOMAN] = 4;
global.classBubbles[CLASS_MEDIC] = 5;
global.classBubbles[CLASS_ENGINEER] = 6;
global.classBubbles[CLASS_SPY] = 7;
global.classBubbles[CLASS_SNIPER] = 8;

object_event_add(Character, ev_keypress, ord(global.class_image_letter), '
    var bubbleImage;

    // We have to use global_middle_press and this
    // because Character hit boxes are way too small to be useful
    if (distance_to_point(mouse_x, mouse_y) < 25) {
        // prevent enemy cloaked spy detection
        if (!(cloak && team != global.myself.team)) {
            if (player.class != CLASS_QUOTE) {
                bubbleImage = global.classBubbles[player.class];
                if (player.team == TEAM_BLUE) {
                    bubbleImage += 10;
                }
            } else {
                bubbleImage = 47;
                if (player.team == TEAM_BLUE) {
                    bubbleImage += 1;
                }
            }
            write_ubyte(global.serverSocket, CHAT_BUBBLE);
            write_ubyte(global.serverSocket, bubbleImage);
        }
    }
');

Try this. I haven't tested it, so bugs may exist, but it should work.
Logged
Pages: [1]
 

Page created in 0.034 seconds with 37 queries.