Article 65K91 CodeSOD: What are you, Chicken?

CodeSOD: What are you, Chicken?

by
Remy Porter
from The Daily WTF on (#65K91)

My Steam profile doesn't represent the most active gamer on Earth, but in my time I put some pretty serious hours into the recent XCOM games. Each mission your squad goes on gets a procedurally generated name, and that can lead to some funny results just by itself (like "Avenging Avenger"). But, if you've put too many hours into the game, you might notice that every once in awhile, you see a mission with "Chicken" in its name.

Now, it's obvious that this is just a joke. Clearly an Easter Egg hidden in the code by a programmer. But Rich D picked through the UnrealScript which powers the game, finding the code responsible.

class XGMission extends Actor abstract;var string m_strHelp; // The help string that displays when this mission is selected in MCvar float fAnimationTimer;var bool m_bRetaliation;var localized array<String> m_aFirstOpName;var localized array<String> m_aSecondOpName;var localized array<String> m_aFirstOpWord;var localized array<String> m_aSecondOpWord;var localized string m_strOpAvenger;var localized string m_strOpAshes;var localized string m_strOpRandom;var localized string m_strOpRandomWord;var localized string m_strChicken;// I just want to use "Chicken" every once in a whilevar localized string m_strTitle; // The mission's namevar localized string m_strSituation; // A string describing the narrative of the missionvar localized string m_strObjective; // A string describing the objective of the missionvar string m_strOpenExclamationMark; // A string for the open exclamation mark for Spanish language ""var string m_strTip;static function string GenerateOpName(optional bool bTutorial = false){local XGParamTag kTag;local int iSelection, iTop, iBottom;local bool bUseChicken;kTag = XGParamTag(`XEXPANDCONTEXT.FindTag("XGParam"));bUseChicken = Rand(500) == 0;// Choose which random op name generator to useif( Rand(2) == 0 ){kTag.StrValue0 = default.m_aFirstOpName[Rand(default.m_aFirstOpName.Length)];kTag.StrValue1 = default.m_aSecondOpName[Rand(default.m_aSecondOpName.Length)];if( bUseChicken ){kTag.StrValue1 = default.m_strChicken;}return `XEXPAND.ExpandString(default.m_strOpRandom);}else{iSelection = Rand(default.m_aFirstOpWord.Length);kTag.StrValue0 = default.m_aFirstOpWord[iSelection];iSelection = Rand(default.m_aSecondOpWord.Length);kTag.StrValue1 = default.m_aSecondOpWord[iSelection];if( bUseChicken ){kTag.StrValue0 = default.m_strChicken;}// Make sure the first and second word of the operation name are not the sameif(kTag.StrValue1 == kTag.StrValue0 ){iTop = default.m_aSecondOpWord.Length - (iSelection+1);iBottom = iSelection;if( iTop >= iBottom ){kTag.StrValue1 = default.m_aSecondOpWord[(iSelection+1) + Rand(iTop)];}else{kTag.StrValue1 = default.m_aSecondOpWord[Rand(iBottom)];}}return `XEXPAND.ExpandString(default.m_strOpRandomWord);}}defaultproperties{}

One of the localization files sets m_strChicken equal to chicken. And then we have the key line, bUseChicken = Rand(500) == 0- 0.2% of the time, part of the mission name string will contain the word "Chicken".

There isn't really a WTF here, just a fun bit of code. Sometimes, you just want to use chicken.

buildmaster-icon.png [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments