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 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 |
// MPActor // Base class for "UGM" objects as described in the Tribes3 design doc class MPActor extends Rook native dependsOn(ObjectiveInfo); cpptext { // stats recording virtual UBOOL Tick(float deltaSeconds, ELevelTick tickType); } // A localized name to uniquely identify this object in text messages var() localized string localizedName; var() bool bAllowSpectators "If true, spectators can switch to view this object"; var(Objectives) localized String primaryFriendlyObjectiveDesc "The localized description of the primary objective"; var(Objectives) localized String primaryEnemyObjectiveDesc "The localized description of the primary objective"; var(Objectives) localized String primaryNeutralObjectiveDesc "The localized description of the primary objective"; var(Stats) class<Stat> defendStat "The stat awarded for killing enemies near this object if it's on the same team"; var(Stats) class<Stat> attackStat "The stat awarded for killing enemies near this object if it's on the enemy team"; var(Stats) int defendRadius "Radius within which you're considered to be defending this object"; var(Stats) int attackRadius "Radius within which you're considered to be attacking this object"; var() Name idleAnim "An animation to play when this object is idle"; var(LocalMessage) class<MPEventMessage> secondaryMessageClass "The class to use for secondary game event messages"; var array<PlayerCharacterController> spectatorList; //function PreBeginPlay() //{ // registerMessage(class'MessageLevelStart', "GameInfo"); //} simulated function PostBeginPlay() { Super.PostBeginPlay(); if (DrawType == DT_Mesh && hasAnim(idleAnim)) LoopAnim(idleAnim); } // onMessage //function onMessage(Message msg) //{ // // add objectives on level start // addDefaultObjectives(); //} // PostTakeDamage // MPActors take no damage by default function PostTakeDamage( float Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType, optional float projectileFactor) { } // Override cleanup() in base classes to manually destroy any dynamically created // instances. This ensures that everything gets filtered properly on map load. function cleanup() { removeDefaultObjectives(); } // Override this function to register any stats with StatTracker function registerStats(StatTracker tracker) { local ModeInfo mode; tracker.registerStat(defendStat); tracker.registerStat(attackStat); mode = ModeInfo(Level.Game); if (mode != None && (attackStat != None || defendStat != None)) { mode.registerPlayerKillListener(self); } } // Helper functions // getNearest // Gets the nearest rook of the given class function Rook getNearest(class<Rook> type, Vector from, optional TeamInfo onlyTeam) { local float maxDist; local float dist; local Actor nearest; local Actor a; local Rook r; maxDist = 9999999999; ForEach DynamicActors(type, a) { r = Rook(a); dist = VSize(r.Location - from); if (dist < maxDist && (onlyTeam == None || onlyTeam == r.Team())) { maxDist = dist; nearest = r; } } return r; } // scoreTeam // increments the score for the object's team, or an optional other team function scoreTeam(int amount, optional TeamInfo otherTeam) { local TeamInfo scoringTeam; if (otherTeam != None) { scoringTeam = otherTeam; } else if (team() != None) { scoringTeam = team(); } dispatchMessage(new class'MessageTeamScored'(scoringTeam)); scoringTeam.score += amount; if (MultiplayerGameInfo(Level.Game) != None) MultiplayerGameInfo(Level.Game).postTeamScored(scoringTeam, amount, self); } // scoreIndividual // Sets an individual's score function scoreIndividual(Character who, int amount) { if (who.tribesReplicationInfo != None) { who.tribesReplicationInfo.score += amount; who.tribesReplicationInfo.offenseScore += amount; } } function awardStat( Class<Stat> s, Character who, optional Controller target, optional int amount ) { local ModeInfo mode; mode = ModeInfo(Level.Game); if (mode != None && who != None) { mode.Tracker.awardStat(Controller(who.tribesReplicationInfo.Owner), s, target, amount); } } function incrementStatAttempt( Class<Stat> s, Character who ) { local ModeInfo mode; mode = ModeInfo(Level.Game); if (mode != None && who != None) { mode.Tracker.incrementStatAttempt(who, s); } } function onPlayerKilled(Controller Killer, Controller Target) { local ModeInfo mode; mode = ModeInfo(Level.Game); if (mode == None) return; // Award defense stat; killer or target can be in radius // TODO: Distribute points according to who damaged Target the most? if (defendStat != None && Rook(Killer.Pawn).team() == team() && Rook(Target.Pawn).team() != team() && (VDist(Location, Target.Location) <= defendRadius || VDist(Location, Killer.Location) <= defendRadius)) { mode.Tracker.awardStat(Killer, defendStat, Target); } // Award attack stat; target must be in radius else if (attackStat != None && Rook(Killer.Pawn).team() != team() && Rook(Target.Pawn).team() == team() && VDist(Location, Target.Location) <= attackRadius) { mode.Tracker.awardStat(Killer, attackStat, Target); } } function addDefaultObjectives() { if (primaryFriendlyObjectiveDesc != "") addFriendlyObjective(primaryFriendlyObjectiveDesc); if (primaryEnemyObjectiveDesc != "") addEnemyObjective(primaryEnemyObjectiveDesc); if (primaryNeutralObjectiveDesc != "") addNeutralObjective(primaryNeutralObjectiveDesc); evaluateObjectiveState(); } function removeDefaultObjectives() { local TeamInfo t; // Quick and dirty...just try removing them from all TeamInfos ForEach DynamicActors(class'TeamInfo', t) { if (t.objectives.remove(getUniqueObjectiveName())) Log("Removing "$getUniqueObjectiveName()$" from "$t); } evaluateObjectiveState(); } function removePersonalObjective(PlayerCharacterController c) { c.objectives.remove(getPersonalObjectiveName()); } function setPersonalObjective(PlayerCharacterController c, string desc, optional Actor other) { local ObjectiveActors oa; oa = new class'objectiveActors'; if (other != None) oa.objectiveActors[0] = other; else oa.objectiveActors[0] = self; // Only allow one personal objective c.objectives.addUsingString(getPersonalObjectiveName(), desc, ObjectiveStatus_Active, ObjectiveType_Primary, oa); } function addFriendlyObjective(string desc, optional Actor other) { local ObjectiveActors oa; local TeamInfo t; if (team() == None) return; oa = new class'objectiveActors'; if (other != None) oa.objectiveActors[0] = other; else oa.objectiveActors[0] = self; ForEach DynamicActors(class'TeamInfo', t) { if (t == team()) { //Log("Adding friendly objective for "$self$" to team "$t$" using name "$getUniqueObjectiveName()); t.objectives.addUsingString(getUniqueObjectiveName(), desc, ObjectiveStatus_Active, ObjectiveType_Primary, oa); } } } function addEnemyObjective(string desc, optional Actor other) { local ObjectiveActors oa; local TeamInfo t; if (team() == None) return; oa = new class'objectiveActors'; if (other != None) oa.objectiveActors[0] = other; else oa.objectiveActors[0] = self; ForEach DynamicActors(class'TeamInfo', t) { if (t != team()) { //Log("Adding enemy objective for "$self$" to team "$t$" using name "$getUniqueObjectiveName()); t.objectives.addUsingString(getUniqueObjectiveName(), desc, ObjectiveStatus_Active, ObjectiveType_Primary, oa); } } } function addNeutralObjective(string desc, optional Actor other) { local ObjectiveActors oa; local TeamInfo t; if (team() != None) return; oa = new class'objectiveActors'; if (other != None) oa.objectiveActors[0] = other; else oa.objectiveActors[0] = self; ForEach DynamicActors(class'TeamInfo', t) { //Log("Adding neutral objective for "$self$" to team "$t$" using name "$getUniqueObjectiveName()); t.objectives.addUsingString(getUniqueObjectiveName(), desc, ObjectiveStatus_Active, ObjectiveType_Primary, oa); } } function setObjectiveState(int i) { local ObjectiveInfo o; local TeamInfo t; //log("Setting objective state "$i$" on "$self); // set friendly and enemy states ForEach DynamicActors(class'TeamInfo', t) { o = t.objectives.objectiveFromName(getUniqueObjectiveName()); if (o != None) { //Log("Setting objective state of "$o$" for team "$t$" to "$i); o.state = i; } } } function setObjectiveTally(int num, int max) { local ObjectiveInfo o; local TeamInfo t; ForEach DynamicActors(class'TeamInfo', t) { o = t.objectives.objectiveFromName(getUniqueObjectiveName()); if (o != None) { //Log("Setting objective state of "$o$" for team "$t$" to "$i); o.UpdateTally(num, max); } } } function evaluateObjectiveState() { // Overridden in subclasses } function name getUniqueObjectiveName() { return self.Name; } function name getPersonalObjectiveName() { return 'PersonalObjective'; } simulated function string GetHumanReadableName() { local string value; value = localizedName; if(value == "") value = super.GetHumanReadableName(); if(value == "") value = string(class.name); return value; } simulated function expandLattice(TeamInfo t) { local LatticeInfo l; if (GameInfo(Level.Game) != None) { l = GameInfo(Level.Game).Lattice; if (l != None) l.makeNeighboursAvailable(self, t); } } simulated function contractLattice(TeamInfo t) { local LatticeInfo l; if (GameInfo(Level.Game) != None) { l = GameInfo(Level.Game).Lattice; if (l != None) l.makeNeighboursUnavailable(self, t); } } simulated function onAvailableToLattice() { // Subclasses can provide code to support lattices } simulated function onUnavailableToLattice() { // Subclasses can provide code to support lattices } function setSpectatorViewTarget(Pawn target) { local Controller C; local PlayerCharacterController pcc; if (!bAllowSpectators) return; for (C=Level.ControllerList; C!=None; C=C.NextController) { pcc = PlayerCharacterController(C); if (pcc == None || !pcc.playerReplicationInfo.bIsSpectator) continue; if (pcc.viewTarget == self) { pcc.SetViewTarget(target); pcc.ClientSetViewTarget(target); // Remember that this player was spectating self addSpectator(pcc); } } } function addSpectator(PlayerCharacterController pcc) { local int i; // Don't allow duplicates for (i=0; i<spectatorList.Length; i++) { if (spectatorList[i] == pcc) return; } spectatorList[spectatorList.Length] = pcc; } function removeSpectator(PlayerCharacterController pcc) { local int i; for (i=0; i<spectatorList.Length; i++) { if (spectatorList[i] == pcc) { spectatorList.Remove(i, 1); return; } } } function resetSpectatorViewTarget() { local int i; local PlayerCharacterController pcc; if (!bAllowSpectators) return; // Force all remembered spectators back to viewing self for (i=0; i<spectatorList.Length; i++) { pcc = spectatorList[i]; if (pcc == None || !pcc.playerReplicationInfo.bIsSpectator) continue; pcc.SetViewTarget(self); pcc.ClientSetViewTarget(self); } // Clear the list spectatorList.Length = 0; } function Pawn getViewTarget() { return self; } // An GameOver state state GameOver { // Don't do anything } defaultproperties { bAIThreat = false bBlockKarma = true bTriggerEffectEventsBeforeGameStarts = true bCanBeSensed = false bUseCompressedPosition = false bSimulateGravity = false bCanBeDamaged = false bAllowSpectators = true bNeedPostRenderCallback = true // required for DoIdentify to work } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |