Random model changing via menu or reload key.

master
Icedream 2016-04-10 21:36:13 +02:00
parent cea89c1927
commit e40dab1a8e
2 changed files with 71 additions and 0 deletions

View File

@ -660,6 +660,7 @@ handleHider() {
player thread enableThirdPersonSwitch("+actionslot 3", 1); player thread enableThirdPersonSwitch("+actionslot 3", 1);
player thread enableModelChange("+attack"); player thread enableModelChange("+attack");
player thread enableModelMenu("+smoke"); player thread enableModelMenu("+smoke");
player thread enableQuickRandomModelChange("+reload");
player thread giveHelpfulHintsForHider(); player thread giveHelpfulHintsForHider();
player thread revealWhenGameEnds(); player thread revealWhenGameEnds();
@ -725,6 +726,18 @@ setDisguiseModel(model)
player IPrintLnBold("^2You changed into ^4" + displayName); player IPrintLnBold("^2You changed into ^4" + displayName);
} }
setRandomDisguiseModel()
{
logPrint("setRandomDisguiseModel called");
player = self;
model = random(level.ModelList);
if (!IsDefined(model))
return;
player setDisguiseModel(model.name);
}
deleteDisguiseModel() deleteDisguiseModel()
{ {
logPrint("deleteDisguiseModel called"); logPrint("deleteDisguiseModel called");
@ -851,6 +864,24 @@ enableModelChange(playerCommand) {
} }
} }
enableQuickRandomModelChange(playerCommand)
{
LogPrint("enableQuickRandomModelChange called");
player = self;
player endon("disconnect");
player endon("death");
// Wait for player to request the quick random model change
player notifyOnPlayerCommand("quickrandmodel_requested", playerCommand);
for (;;)
{
player waittill("quickrandmodel_requested");
player setRandomDisguiseModel();
}
}
enableModelMenu(playerCommand) enableModelMenu(playerCommand)
{ {
LogPrint("enableModelMenu called"); LogPrint("enableModelMenu called");
@ -891,6 +922,9 @@ handleModelMenuSelection()
selection = StrTok(response, ","); selection = StrTok(response, ",");
switch (selection[0]) switch (selection[0])
{ {
case "randmodel":
player setRandomDisguiseModel();
break;
case "chmodel": case "chmodel":
if (selection.size != 2) if (selection.size != 2)
break; break;

View File

@ -201,6 +201,43 @@
MENU_MODEL_BUTTON(62) MENU_MODEL_BUTTON(62)
MENU_MODEL_BUTTON(63) MENU_MODEL_BUTTON(63)
itemDef itemDef
{
rect -64 -40 336 20 1 3
visible 1
group "mw2_button"
style 1
forecolor 1 1 1 1
disablecolor 0.6 0.55 0.55 1
background "menu_button_selection_bar"
type 1
textfont 3
textalign 6
textalignx -60
textscale 0.375
text "RANDOM"
action
{
play "mouse_click";
scriptMenuResponse "randmodel";
escape self;
}
onFocus
{
play "mouse_over";
if ( dvarstring( "gameMode" ) != "mp" )
{
setItemColor "mw2_button" backcolor 0 0 0 0;
}
setItemColor self backcolor 0 0 0 1;
setLocalVarBool "ui_menuAButton" ( 1 );
}
leaveFocus
{
setItemColor self backcolor 0 0 0 "0.0";
setLocalVarBool "ui_menuAButton" ( 0 );
}
}
itemDef
{ {
rect -64 -20 336 20 1 3 rect -64 -20 336 20 1 3
visible 1 visible 1