Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 |
// ============================================================================ // JBAddonJailFightTally // Copyright 2006 by Mychaeel <mychaeel@planetjailbreak.com> // $Id: JBAddonJailFightTally.uc,v 1.1 2008-03-16 11:40:27 jrubzjeknf Exp $ // // Formerly known as JBAddonTally, renamed to prevent compatibility issues. // When players are in jail, displays a jail fight score tally. // ============================================================================ class JBAddonJailFightTally extends JBAddon cacheexempt; // ============================================================================ // Replication // ============================================================================ replication { reliable if (Role == ROLE_Authority) nEntries, Entries, Players, bGameEnded; } // ============================================================================ // Types // ============================================================================ struct TPlayer { var string Name; // cached player name var JBTagPlayer TagPlayer; // owner of this entry }; struct TEntry { var byte iPlayer; // reference into players array var int nKills; // number of kills in jail fights var int nDeaths; // number of deaths in jail fights var float LastKillTime; // when the player last killed someone var float LastDeathTime; // when the player was last killed }; // ============================================================================ // Properties // ============================================================================ var() const editconst string Build; // ============================================================================ // Variables // ============================================================================ var JBTagPlayer TagPlayerLocal; var int nEntries; // current number of entries var TEntry Entries[32]; // tally entries var TPlayer Players[32]; // non-movable player data var float nEntriesFade; // fade-in ratio of entire tally var float TimeFade; // last fade-in update var HudBase.SpriteWidget SpriteWidgetEntry; var HudBase.SpriteWidget SpriteWidgetBackground; var bool bGameEnded; // ============================================================================ // PostBeginPlay // // Creates and registers an instance of the game rule modifier class. // ============================================================================ event PostBeginPlay() { local JBGameRulesJailFightTally GameRulesTally; GameRulesTally = Spawn(class'JBGameRulesJailFightTally'); GameRulesTally.Addon = Self; Level.Game.AddGameModifier(GameRulesTally); // Get notified when the game ends. Tag = 'EndGame'; } // ============================================================================ // Trigger // // Called when the game ends. // ============================================================================ event Trigger(Actor Other, Pawn EventInstigator) { bGameEnded = True; } // ============================================================================ // AddToTally // // Adds a jail fight result to the score tally. // ============================================================================ function AddToTally(JBTagPlayer TagPlayerKiller, JBTagPlayer TagPlayerVictim) { local int iEntryKiller; local int iEntryVictim; iEntryKiller = FindOrCreateEntryFor(TagPlayerKiller); Entries[iEntryKiller].nKills += 1; Entries[iEntryKiller].LastKillTime = Level.TimeSeconds; while (iEntryKiller > 0 && Entries[iEntryKiller - 1].nKills < Entries[iEntryKiller].nKills) SwapEntries(iEntryKiller, --iEntryKiller); iEntryVictim = FindOrCreateEntryFor(TagPlayerVictim); Entries[iEntryVictim].nDeaths += 1; Entries[iEntryVictim].LastDeathTime = Level.TimeSeconds; TouchEntry(iEntryKiller); TouchEntry(iEntryVictim); } // ============================================================================ // FindOrCreateEntryFor // // Returns the index of the score tally entry of the given player. If none // exists, adds one to the list. // ============================================================================ function int FindOrCreateEntryFor(JBTagPlayer TagPlayer) { local int iEntry; for (iEntry = 0; iEntry < nEntries; ++iEntry) if (Players[Entries[iEntry].iPlayer].TagPlayer == TagPlayer) return iEntry; iEntry = nEntries++; if (nEntriesFade > 0.0 && nEntriesFade == nEntries - 1) nEntriesFade = nEntries; Players[iEntry].TagPlayer = TagPlayer; Entries[iEntry].iPlayer = iEntry; return iEntry; } // ============================================================================ // SwapEntries // // Swaps two entries in the score tally. // ============================================================================ function SwapEntries(int iEntry1, int iEntry2) { local TEntry EntryTemp; EntryTemp = Entries[iEntry1]; Entries[iEntry1] = Entries[iEntry2]; Entries[iEntry2] = EntryTemp; } // ============================================================================ // TouchEntry // // Makes a dummy modification to an entry. Works around an engine bug which // would otherwise not replicate that entry. // ============================================================================ function TouchEntry(int iEntry) { Entries[iEntry] = Entries[iEntry]; } // ============================================================================ // RenderOverlays // // Displays the jail fight score tally when the local player is in jail. // ============================================================================ simulated function RenderOverlays(Canvas Canvas) { local float KillTime; local float DeathTime; local int iEntry; local int Offset; local String ScoreKills; local String ScoreEfficiency; local Vector LocationCurrentEntry; local Vector LocationCurrentText; local Vector LocationCurrentBackground; local Vector SizeEntry; local Vector SizeBackground; local Vector SizeScoreKills; local Vector SizeScoreEfficiency; local TEntry EntryCurrent; local TPlayer PlayerCurrent; local PlayerReplicationInfo PlayerReplicationInfo; if (PlayerControllerLocal == None) PlayerControllerLocal = Level.GetLocalPlayerController(); if (TagPlayerLocal == None) TagPlayerLocal = Class'JBTagPlayer'.Static.FindFor(Level.GetLocalPlayerController().PlayerReplicationInfo); if (PlayerControllerLocal.myHUD.bHideHUD) return; if (((TagPlayerLocal != None && TagPlayerLocal.IsInJail()) || bGameEnded) && !JBGameReplicationInfo.bIsExecuting) nEntriesFade = FMin(nEntries, nEntriesFade + (Level.TimeSeconds - TimeFade) * 4.0); else nEntriesFade = FMax(0.0, nEntriesFade - (Level.TimeSeconds - TimeFade) * 4.0); TimeFade = Level.TimeSeconds; if (nEntriesFade > 0.0) { Canvas.Style = ERenderStyle.STY_Alpha; Canvas.Font = PlayerControllerLocal.myHUD.ScoreBoard.GetSmallFontFor(Canvas.ClipX, 0); Canvas.TextSize(" 999", SizeScoreKills .X, SizeScoreKills .Y); Canvas.TextSize(" 100%", SizeScoreEfficiency.X, SizeScoreEfficiency.Y); SizeBackground.X = SpriteWidgetBackground.TextureScale * (SpriteWidgetBackground.TextureCoords.X2 - SpriteWidgetBackground.TextureCoords.X1) * (Canvas.SizeX / 640); SizeBackground.Y = SizeScoreKills.Y * 1.2; SizeEntry.Y = SizeScoreKills.Y * 1.4; LocationCurrentEntry.X = SpriteWidgetEntry.PosX * Canvas.SizeX; LocationCurrentEntry.Y = SpriteWidgetEntry.PosY * Canvas.SizeY; LocationCurrentBackground.X = SpriteWidgetBackground.PosX * Canvas.SizeX; LocationCurrentBackground.Y = SpriteWidgetBackground.PosY * Canvas.SizeY; for (iEntry = 0; iEntry < nEntries; ++iEntry) { EntryCurrent = Entries[iEntry]; PlayerCurrent = Players[EntryCurrent.iPlayer]; if (PlayerCurrent.TagPlayer != None) { PlayerReplicationInfo = PlayerCurrent.TagPlayer.GetPlayerReplicationInfo(); if (PlayerReplicationInfo != None) PlayerCurrent.Name = PlayerReplicationInfo.PlayerName; } if (Players[EntryCurrent.iPlayer] != PlayerCurrent) Players[EntryCurrent.iPlayer] = PlayerCurrent; if (iEntry <= nEntriesFade - 1.0) Offset = 0; else Offset = Canvas.ClipX * 0.5 * (1.0 - FMax(0.0, nEntriesFade - iEntry)); Canvas.DrawColor = SpriteWidgetBackground.Tints[0]; Canvas.SetPos( LocationCurrentBackground.X - SizeBackground.X + Offset, LocationCurrentBackground.Y); Canvas.DrawTile( SpriteWidgetBackground.WidgetTexture, SizeBackground.X, SizeBackground.Y, SpriteWidgetBackground.TextureCoords.X1, SpriteWidgetBackground.TextureCoords.Y1, SpriteWidgetBackground.TextureCoords.X2 - SpriteWidgetBackground.TextureCoords.X1, SpriteWidgetBackground.TextureCoords.Y2 - SpriteWidgetBackground.TextureCoords.Y2); Canvas.DrawColor = SpriteWidgetEntry.Tints[0]; // Applying a color change due to a recent kill and/or death if (Level.TimeSeconds - EntryCurrent.LastKillTime <= 2 || Level.TimeSeconds - EntryCurrent.LastDeathTime <= 2) { KillTime = Level.TimeSeconds - EntryCurrent.LastKillTime; DeathTime = Level.TimeSeconds - EntryCurrent.LastDeathTime; Canvas.DrawColor.R -= 192 * (1 - FClamp((KillTime - 1)/1, 0, 1)); Canvas.DrawColor.G -= 192 * (1 - FClamp((DeathTime - 1)/1, 0, 1)); Canvas.DrawColor.B -= 192 * (1 - FClamp((FMin(KillTime, DeathTime) - 1)/1, 0, 1)); Canvas.DrawColor.A += 64 * (1 - FClamp((FMin(KillTime, DeathTime) - 1)/1, 0, 1)); log(Canvas.DrawColor.A); } /* if (EntryCurrent.nDeaths < EntryCurrent.nKills) ScoreDelta = "+" $ (EntryCurrent.nKills - EntryCurrent.nDeaths); else if (EntryCurrent.nDeaths > EntryCurrent.nKills) ScoreDelta = "-" $ (EntryCurrent.nDeaths - EntryCurrent.nKills); else ScoreDelta = "0";*/ ScoreKills = String(EntryCurrent.nKills); ScoreEfficiency = (EntryCurrent.nKills * 100 / (EntryCurrent.nKills + EntryCurrent.nDeaths)) $ "%"; LocationCurrentText.X = LocationCurrentEntry.X + Offset; LocationCurrentText.Y = LocationCurrentEntry.Y; DrawTextRightAligned(Canvas, ScoreEfficiency, LocationCurrentText.X, LocationCurrentText.Y); LocationCurrentText.X -= SizeScoreEfficiency.X; DrawTextRightAligned(Canvas, ScoreKills, LocationCurrentText.X, LocationCurrentText.Y); LocationCurrentText.X -= SizeScoreKills .X; DrawTextRightAligned(Canvas, PlayerCurrent.Name, LocationCurrentText.X, LocationCurrentText.Y); LocationCurrentEntry .Y += SizeEntry.Y; LocationCurrentBackground.Y += SizeEntry.Y; } } } // ============================================================================ // DrawTextRightAligned // // Draws right-aligned text at the given screen coordinates. // ============================================================================ simulated function DrawTextRightAligned(Canvas Canvas, coerce String Text, float X, float Y) { local Vector SizeText; Canvas.TextSize(Text, SizeText.X, SizeText.Y); Canvas.SetPos(X - SizeText.X, Y); Canvas.DrawTextClipped(Text); } // ============================================================================ // Defaults // ============================================================================ defaultproperties { Build="%%%%-%%-%% %%:%%" SpriteWidgetEntry = (PosX=0.970000,PosY=0.105000,Tints[0]=(B=255,G=255,R=255,A=191)) SpriteWidgetBackground = (WidgetTexture=Texture'HUDContent.Generic.HUD',TextureCoords=(X1=168,Y1=211,X2=334,Y2=255),TextureScale=0.530000,PosX=1.000000,PosY=0.100000,Tints[0]=(A=255)) FriendlyName = "Jail Fight Tally" Description = "Maintains and displays a score tally for jail fights." bAlwaysRelevant = True RemoteRole = ROLE_SimulatedProxy bIsOverlay = True } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |