Ticket #2273: 0AD_Taunts.patch
File 0AD_Taunts.patch, 3.8 KB (added by , 8 years ago) |
---|
-
binaries/data/config/default.cfg
41 41 ; Persist settings after leaving the game setup screen 42 42 persistmatchsettings = true 43 43 44 ; Enable playing sounds when a taunt is used in chat 45 enabletaunts = true 46 44 47 ; Default player name to use in multiplayer 45 48 ; playername = "anonymous" 46 49 -
binaries/data/mods/public/gui/options/options.json
96 96 "label": "Chat Timestamp", 97 97 "tooltip": "Show time that messages are posted in the lobby, gamesetup and ingame chat.", 98 98 "parameters": { "config": "chat.timestamp" } 99 }, 100 { 101 "type": "boolean", 102 "label": "Enable Taunts", 103 "tooltip": "Enable / Disable playing sounds when a taunt is used in a chat", 104 "parameters": { "config": "enabletaunts" } 99 105 } 100 106 ], 101 107 "graphicsSetting": -
binaries/data/mods/public/gui/session/messages.js
1 1 /** 2 * All known taunt commands. 3 * @type {Object} 4 */ 5 const g_Taunts = getTauntsData(); 6 7 /** 2 8 * All known cheat commands. 3 9 * @type {Object} 4 10 */ … … 429 435 }; 430 436 431 437 /** 438 * Loads all known taunt commands. 439 * 440 * @returns {Object} 441 */ 442 function getTauntsData() 443 { 444 let taunts = {}; 445 for (let fileName of getJSONFileList("simulation/data/taunts/")) 446 { 447 let currentTaunt = Engine.ReadJSONFile("simulation/data/taunts/"+fileName+".json"); 448 if (!currentTaunt) 449 continue; 450 if (Object.keys(taunts).indexOf(currentTaunt.Name) !== -1) 451 warn("Taunt name '" + currentTaunt.Name + "' is already present"); 452 else 453 taunts[currentTaunt.Name] = currentTaunt.File; 454 } 455 return taunts; 456 } 457 458 /** 432 459 * Loads all known cheat commands. 433 460 * 434 461 * @returns {Object} … … 450 477 } 451 478 452 479 /** 480 * Reads userinput from the chat and plays a sound in case it is a known taunt. 481 * 482 * @returns {boolean} - True if a taunt was executed. 483 */ 484 function executeTaunt(text) 485 { 486 // Find the cheat code that is a prefix of the user input 487 let tauntCode = Object.keys(g_Taunts).find(tauntCode => text.indexOf(tauntCode) == 0); 488 if (!tauntCode) 489 return; 490 491 let taunt = g_Taunts[tauntCode]; 492 Engine.PlayUISound("audio/"+taunt, false); 493 } 494 495 /** 453 496 * Reads userinput from the chat and sends a simulation command in case it is a known cheat. 454 497 * 455 498 * @returns {boolean} - True if a cheat was executed. … … 945 988 946 989 if (userName != g_PlayerAssignments[msg.guid].name) 947 990 notifyUser(userName, msg.text); 991 if (Engine.ConfigDB_GetValue("user", "enabletaunts") == "true") 992 executeTaunt(msg.text); 948 993 } 949 994 950 995 // GUID for players, playerID for AIs -
binaries/data/mods/public/simulation/data/taunts/asd.json
1 { 2 "Name": "asd?", 3 "File": "voice/greek/civ/civ_male_yes_1.ogg" 4 } -
binaries/data/mods/public/simulation/data/taunts/asd.json
1 { 2 "Name": "asd?", 3 "File": "voice/greek/civ/civ_male_yes_1.ogg" 4 }