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 |
class DruidUpgradeInv extends Inventory config(DruidUpgrade); var DruidUpgradeObj Obj; function Tick(float deltaTime) { Local RPGStatsInv Inv; local String CurrentVersion; Local MutUT2004RPG RPGMut; local Mutator m; Local String Entry; if(Instigator == None || Instigator.Controller == None || PlayerController(Instigator.Controller) == None || PlayerController(Instigator.Controller).PlayerReplicationInfo == None) { super.Tick(deltaTime); return; //early out. something is busted, hopefully it'll be worked out soon. } Inv = RPGStatsInv(Instigator.FindInventoryType(class'RPGStatsInv')); if(Inv != None) { for (m = Level.Game.BaseMutator; m != None; m = m.NextMutator) if (MutUT2004RPG(m) != None) { RPGMut = MutUT2004RPG(m); break; } if(RPGMut != None) { Entry = PlayerController(Instigator.Controller).getPlayerIDHash() @ PlayerController(Instigator.Controller).PlayerReplicationInfo.GetHumanReadableName(); Obj = new(None, Entry) class'DruidUpgradeObj'; if(Obj != None) { CurrentVersion = getCurrentVersion(); //Go go gadget upgrade. if(Obj.Version != CurrentVersion) { doUpgrade(Obj.Version, CurrentVersion, Inv); Obj.Version = CurrentVersion; Obj.saveConfig(); Inv.DataObject.saveConfig(); //now, recalculate their stats Inv.DataObject.CreateDataStruct(Inv.Data, false); RPGMut.ValidateData(Inv.DataObject); Inv.DataObject.CreateDataStruct(Inv.Data, false); } disable('Tick'); //we're done. Cash it out. } } } //if something isn't found, try next tick. super.Tick(deltaTime); } Function doUpgrade(String oldVersion, String newVersion, RPGStatsInv inv) { //you may want to override this method for your upgrade. If you do so, you may not want to call super so my upgrade doesn't run... if(newVersion == "182") do182Upgrade(Inv); } //you probably dont want to override this method. This one is mine. Function do182Upgrade(RPGStatsInv inv) { Local int x; Local bool NeedAdrenalineMaster; Local bool NeedWeaponsMaster; Local bool FoundAdrenalineMaster; Local bool FoundWeaponsMaster; Local bool FoundMonsterMaster; Local bool FoundEngineer; Local bool GotAwareness; Local int AwareIdx; for (x = 0; x < Inv.DataObject.Abilities.length; x++) { if (Inv.DataObject.Abilities[x] == class'ClassAdrenalineMaster') { FoundAdrenalineMaster = True; break; } else if (Inv.DataObject.Abilities[x] == class'ClassWeaponsMaster') { FoundWeaponsMaster = True; break; } else if (Inv.DataObject.Abilities[x] == class'ClassMonsterMaster') { FoundMonsterMaster = True; NeedAdrenalineMaster = False; NeedWeaponsMaster = False; // No break here - we've got something to look for. BF } else if (Inv.DataObject.Abilities[x] == class'ClassEngineer') { FoundEngineer = True; break; } else if(!NeedAdrenalineMaster && !NeedWeaponsMaster && !FoundMonsterMaster) { if (Inv.DataObject.Abilities[x] == class'DruidLoaded') NeedWeaponsMaster = True; else if (Inv.DataObject.Abilities[x] == class'DruidVampire') NeedWeaponsMaster = True; else if (Inv.DataObject.Abilities[x] == class'DruidRegen') NeedWeaponsMaster = True; else if (Inv.DataObject.Abilities[x] == class'DruidArtifactLoaded') NeedAdrenalineMaster = True; else if (Inv.DataObject.Abilities[x] == class'DruidEnergyVampire') NeedAdrenalineMaster = True; else if (Inv.DataObject.Abilities[x] == class'DruidAdrenalineSurge') NeedAdrenalineMaster = True; else if (Inv.DataObject.Abilities[x] == class'DruidAdrenalineRegen') NeedAdrenalineMaster = True; } else if (Inv.DataObject.Abilities[x] == class'DruidAwareness') { AwareIdx = x; GotAwareness = True; } } if(FoundAdrenalineMaster || FoundWeaponsMaster || FoundEngineer) { //hmm... Guess I didn't need to upgrade?! return; } // I think this is best, all things considered. BF if (!FoundMonsterMaster && GotAwareness) NeedWeaponsMaster = True; if(FoundMonsterMaster && GotAwareness) { log(Inv.DataObject.Name@"Needed Awareness Switch"); Inv.DataObject.Abilities[AwareIdx] = class'AbilityMedicAwareness'; // OW! This will disconnect them, but this is the easiest way to // get the change replicated to the client: Disconnect them. BF Instigator.Controller.Destroy(); } else if(NeedAdrenalineMaster) { log(Inv.DataObject.Name@"Needed Adrenaline Master"); Inv.DataObject.Abilities[Inv.DataObject.Abilities.length] = class'ClassAdrenalineMaster'; Inv.DataObject.AbilityLevels[Inv.DataObject.AbilityLevels.length] = 1; Inv.ClientAddAbility(class'ClassAdrenalineMaster', 1); } else if(NeedWeaponsMaster) { log(Inv.DataObject.Name@"Needed Weapons Master"); Inv.DataObject.Abilities[Inv.DataObject.Abilities.length] = class'ClassWeaponsMaster'; Inv.DataObject.AbilityLevels[Inv.DataObject.AbilityLevels.length] = 1; Inv.ClientAddAbility(class'ClassAdrenalineMaster', 1); } log("182 Upgrade complete for"@Inv.DataObject.Name); //upgrade complete. } Function String getCurrentVersion() { return "182"; //this version only needs to be incremented when a schema change is made. Therefore, it wont be the exact same version //that is the build number. //You might want to override this method for your own mutator if you need to do your own upgrading ;) } function GiveTo(Pawn Other, optional Pickup Pickup) { enable('Tick'); Super.GiveTo(Other); } defaultproperties { RemoteRole=ROLE_SimulatedProxy } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |