Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release L4D Style Radial Menu
#1


Code:
detectRadialMenu()
{
    self endon("death");
    self endon("disconnect");
    while(1) {
        if(!self.inRoundFreeze) {
            if(self UseButtonPressed() && isAlive(self) && !self.justSpawned && !self.ignoreF) {
                if(!self.textVisible){
                    for(i = 0; i < self.text.size; i++) {
                        self.text[i] showElem();
                    }
                    self.textVisible = true;
                    self.currentAngles = self getPlayerAngles();
                }
                self thread scanRadialPos();
            } else if(isAlive(self) && !self.justSpawned && !self.ignoreF) {
                if(self.textVisible){
                    for(i = 0; i < self.text.size; i++) {
                        self.text[i] hideElem();
                    }
                    self doSelectionChoice(self.selection);
                    self processMenuChallenge(0, "menu_challenge_quick", self.menuAbuseTime);
                    self processMenuChallenge(1, "menu_challenge_abuse", self.menuAbuse);
                    self processMenuChallenge(2, "menu_challenge_sadist", self.menuSadist);
                    self.menuAbuseTime = 0;
                    self SetMoveSpeedScale(1);
                    self allowJump(true);
                    self.textVisible = false;
                }
                self.menuAbuseTime += 0.01;
            }
        }
        wait 0.01;
    }
}

processMenuChallenge(challengeID, challenge, challengeValue)
{
    if(challenge == "menu_challenge_quick") {
        if(challengeValue < 0.1 && !self.pers["menu"]["challenge"][challengeID]) {
            self popupChallenge("Speed Freak", "^1I think you need to calm down a little....");
            self.pers["menu"]["challenge"][challengeID] = true;
        }
    }
    
    if(challenge == "menu_challenge_abuse" && !self.pers["menu"]["challenge"][challengeID] ) {
        if(challengeValue >= 50) {
            self popupChallenge("Mr Menu Abuse", "^1Now, get a life!");
            self.pers["menu"]["challenge"][challengeID] = true;
        }
    }
    
    if(challenge == "menu_challenge_sadist" && !self.pers["menu"]["challenge"][challengeID] ) {
        if(challengeValue >= 10) {
            self popupChallenge("Are you a Sadist or Emo?", "^1Stop analing yourself now!");
            self.pers["menu"]["challenge"][challengeID] = true;
        }
    }
    
}

popupChallenge(firstText, secondText)
{
    notifyData = spawnStruct();
    notifyData.titleText = &"MP_CHALLENGE_COMPLETED";
    notifyData.sound = "mus_challenge_complete";
    notifyData.notifyText = firstText;
    notifyData.notifyText2 = secondText;
    self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
}

doSelectionChoice(selectionInt)
{
        switch(selectionInt) {
            case 0:
                level thread maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( self, "fire", "scream" );
                self.menuSadist++;
            break;
            case 1:
                closest_ally = self maps\mp\gametypes\_battlechatter_mp::get_closest_player_ally();
                level thread maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( closest_ally, "inform_need", "medic", false );
                level thread maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( self, "inform_need", "medic", false );
                self sayTeam(self.pers["menu"]["strings"]["medic"][randomInt(3)]);
            break;
            case 2:
                level thread maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( self, "grenade_incoming", "grenade" );
                self sayTeam(self.pers["menu"]["strings"]["grenade"][randomInt(3)]);
            break;
            case 3:
                level thread maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( self, "enemy", "sniper", false );
                self sayTeam(self.pers["menu"]["strings"]["sniper"][randomInt(3)]);
            break;
            case 4:
                level thread maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( self, "enemy", "infantry" );
                self sayTeam(self.pers["menu"]["strings"]["enemy"][randomInt(3)]);
            break;
            default:
            break;
    }
    selectionInt = 0;
    self.menuAbuse++;
}
        
scanRadialPos()
{    
    self allowJump(false);
    self SetMoveSpeedScale(0);

    self.newAngles = self getPlayerAngles();
    
    for(i = 0; i < self.text.size; i++) {
        self.text[i].fontscale = 1.5;
        self.text[i].color = (1, 1, 1);
        self.text[i].alpha = 1;
    }
    
    if((180 - self.newAngles[1]) < 20) {
        self.newAngles[1] -= 40;
        self.currentAngles[1] -= 40;
    }
    
    if(self.newAngles[1] < self.currentAngles[1] - 20 && self.currentAngles[0] + 20 > self.newAngles[0] && self.currentAngles[0] - 20 < self.newAngles[0]) {
        self.text[3].fontscale = 2;
        self.text[3].color = (0.192, 0.192, 0.192);
        self.text[3].alpha = 0.7;
        self.selection = 3;
    } else if(self.newAngles[1] > self.currentAngles[1] + 20 && self.currentAngles[0] + 20 > self.newAngles[0] && self.currentAngles[0] - 20 < self.newAngles[0]) {
        self.text[2].fontscale = 2;
        self.text[2].color = (0.192, 0.192, 0.192);
        self.text[2].alpha = 0.7;
        self.selection = 2;
    } else if(self.newAngles[0] < self.currentAngles[0] - 20) {
        self.text[1].fontscale = 2;
        self.text[1].color = (0.192, 0.192, 0.192);
        self.text[1].alpha = 0.7;
        self.selection = 1;
    } else if(self.newAngles[0] > self.currentAngles[0] + 20) {
        self.text[4].fontscale = 2;
        self.text[4].color = (0.192, 0.192, 0.192);
        self.text[4].alpha = 0.7;
        self.selection = 4;
    } else {
        self.text[0].fontscale = 2;
        self.text[0].color = (0.192, 0.192, 0.192);
        self.text[0].alpha = 0.7;
        self.selection = 0;
    }
}

createHUD()
{
    self.justSpawned = true;
    self.selection = 0;
    self.textVisible = false;
    self.ignoreF = false;
    self.inRoundFreeze = false;
    
    createText(0, "Scream", 1.5, "default", "center", "center", 0, 0, 0.5);
    createText(1, "Need a Medic!", 1.5, "default", "center", "center", 0, -100, 1);
    createText(2, "Grenade!", 1.5, "default", "center", "center", -100, 0, 1);
    createText(3, "Sniper!", 1.5, "default", "center", "center", 100, 0, 1);
    createText(4, "Enemy Spotted!", 1.5, "default", "center", "center", 0, 100, 1);
    self thread destroyDeath(self.text);
    
    wait 0.75;
    self.justSpawned = false;
}

/*
         1
         |
         |
2 ------ 0 ------- 3
         |
         |
         4

*/

createText(var, text, textSize, font, alignX, alignY, X, Y, alpha)
{
    if(!isDefined(self.text)) {
        self.text = [];
    }

    self.text[var] destroy();
    self.text[var] = self createFontString( font, textSize );
    self.text[var].hideWhenInMenu = true;
    self.text[var].alpha = alpha;
    self.text[var] setPoint( alignX, alignY, X, Y );
    self.text[var] setText( text );
    self.text[var] hideElem();
}

destroyDeath(array)
{
    self waittill("death");
    for(i = 0; i < array.size; i++)
    {
        array destroy();
    }
}

This is what you're onPlayerSpawned should look like:
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    self.menuAbuse = 0;
    self.menuAbuseTime = 0;
    self.menuSadist = 0;
    for(;;)
    {
        self waittill("spawned_player");
        //The default HUD code was removed for this example
        self thread createHUD();
        self thread detectRadialMenu();
    }
}

Enjoy the mini-challeneges and don't whine about the efficiency of the code. I created this almost 5-6 months ago and I haven't touched it since.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#2
Old code? Or wasn't this ever public?
Reply

#3
It was never public, just the video. Snippets of this was in previous builds of cmMOD.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Rainbow What is your favourite dress/style? Nekochan 10 6,383 11-11-2013, 21:39
Last Post: Nekochan
Question Help Admin menu koren30 4 5,120 10-07-2013, 20:17
Last Post: Yamato
  [Tutorial] How-To, Mod menu picture-REVISED/no iwifix needed rotceh_dnih 52 32,287 09-28-2013, 02:08
Last Post: Monkey Arms
  Help How do I open the admin menu for GeKKos QS Mod? conorr 1 3,085 08-15-2013, 13:52
Last Post: Yamato
  Trying to compile a modified menu DidUknowiPwn 7 5,708 07-05-2013, 21:55
Last Post: DidUknowiPwn
  Preview Admin / Mod Menu Hologramm 5 6,945 05-29-2013, 00:35
Last Post: sleepunknot
  Map Menu in Black Ops 1 EliTeEishiii 2 3,053 04-21-2013, 18:54
Last Post: Nekochan
  Menu base EliTeEishiii 1 2,877 04-17-2013, 16:10
Last Post: Nekochan
Rainbow [Release] [Contest] Scroll Menu iAegle 49 36,855 03-21-2013, 07:30
Last Post: jermC
  [Release] Mouse operated menu met94 18 13,713 03-06-2013, 10:27
Last Post: BHF98

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.