Core.Object | +--Engine.Actor | +--Engine.Triggers | +--XIII.XIIISaveGameTrigger
array
ActorsToDestroy
string
Description
int
IsEmpty
XIIIPlayerPawn
P
ProfileList
ReturnCode
SaveDescription
sound
SoundToLaunch
TeleporterName
i
void
CleanMap()
//____________________________________________________________________ // Get rid of all actors in my list ActorsToDestroy, meant to optimize (for checkpoints we are sure are no-return)
DoSave()
// Save Game upon touch by pawn if context-ok.
bool
PrepareSave()
00001 //----------------------------------------------------------- 00002 // 00003 //----------------------------------------------------------- 00004 class XIIISaveGameTrigger extends Triggers; 00005 00006 var() /*localized*/ string SaveDescription; 00007 var() string TeleporterName; 00008 var XIIIPlayerPawn P; 00009 var() array<Actor> ActorsToDestroy; 00010 var() sound SoundToLaunch; 00011 var transient int ReturnCode; 00012 var transient array<string> ProfileList; 00013 var transient int i; 00014 var transient int IsEmpty; 00015 var transient string Description; 00016 00017 //____________________________________________________________________ 00018 // Get rid of all actors in my list ActorsToDestroy, meant to optimize (for checkpoints we are sure are no-return) 00019 function CleanMap() 00020 { 00021 local int i; 00022 00023 for (i=0; i<ActorsToDestroy.Length; i++) 00024 { 00025 /* 00026 if ( ActorsToDestroy[i] != none ) // may be already destroyed 00027 ActorsToDestroy[i].Destroy(); 00028 */ 00029 if (ActorsToDestroy[i] != none) 00030 { 00031 if ( XIIIPawn(ActorsToDestroy[i]) == none ) 00032 ActorsToDestroy[i].Destroy(); 00033 else 00034 { // destroy only if not visible and not in player's hand 00035 if ( !P.Controller.CanSee(Pawn(ActorsToDestroy[i])) 00036 && ( XIIIPawn(ActorsToDestroy[i]) != P.LHand.pOnShoulder ) ) 00037 ActorsToDestroy[i].Destroy(); 00038 } 00039 } 00040 } 00041 } 00042 00043 //____________________________________________________________________ 00044 auto state WaitingForColl 00045 { 00046 event Touch(actor other) // should happen for checkpoints 00047 { 00048 P = XIIIPlayerPawn(Other); 00049 if ( (P != none) && !P.bIsDead ) 00050 GotoState('GoSaving'); 00051 } 00052 event Trigger( Actor Other, Pawn EventInstigator ) // should happen when entering map 00053 { 00054 P = XIIIPlayerPawn(EventInstigator); 00055 if ( (P != none) && !P.bIsDead ) 00056 GotoState('GoSaving'); 00057 } 00058 } 00059 00060 //____________________________________________________________________ 00061 state GoSaving 00062 { 00063 function bool PrepareSave() 00064 { 00065 local XIIIThingsToSave S; 00066 local Array<string> Profile; 00067 local int i; 00068 00069 S = XIIIThingsToSave(P.FindInventoryType(class'XIIIThingsToSave')); 00070 if ( S!=none && (S.XIIISaveGameTriggerTag==Tag) ) 00071 { 00072 log("SAVE: "$self$" Destroying because XIIIThingsToSave exists in pawn inventory and Tag matches our"); 00073 Destroy(); 00074 return false; 00075 } 00076 return true; 00077 } 00078 // Save Game upon touch by pawn if context-ok. 00079 function DoSave() 00080 { 00081 local int MaxSlot, i; 00082 local NavigationPoint T; 00083 local XIIIThingsToSave S; 00084 local string St; 00085 local mapinfo MI; 00086 local XIIIGameInfo GI; 00087 00088 log(":SAVE: "$self); 00089 00090 S = XIIIThingsToSave(P.FindInventoryType(class'XIIIThingsToSave')); 00091 if ( S != none ) 00092 S.Destroy(); 00093 00094 S = Spawn(class'XIIIThingsToSave',,,P.Location); 00095 if ( S == none ) 00096 { 00097 Log(" ---: Pb, couldn't create XIIIThingsToSave..."); 00098 return; 00099 } 00100 MI = XIIIGameInfo(Level.Game).MapInfo; 00101 if ( MI == none ) 00102 { 00103 ForEach AllActors(class'MapInfo', MI) 00104 Break; 00105 } 00106 GI = XIIIGameInfo(Level.Game); 00107 00108 S.GiveTo(P); 00109 S.XIIISaveGameTriggerTag = Tag; 00110 S.Health = P.Health; 00111 S.SpeedFactorLimit = P.SpeedFactorLimit; 00112 S.SoundToLaunch = SoundToLaunch; 00113 if (GI == none) 00114 { 00115 S.CheckpointNumber = 0; 00116 } 00117 else 00118 { 00119 GI.CheckpointNumber++; 00120 S.CheckpointNumber = GI.CheckpointNumber; 00121 } 00122 00123 for ( i=0; i<MI.Objectif.Length ; i++ ) 00124 { 00125 S.ObjectivesState.Length = S.ObjectivesState.Length + 1; 00126 S.ObjectivesState[i].bCompleted = MI.Objectif[i].bCompleted; 00127 S.ObjectivesState[i].bPrimary = MI.Objectif[i].bPrimary; 00128 S.ObjectivesState[i].bAntiGoal = MI.Objectif[i].bAntiGoal; 00129 } 00130 00131 /* ELR No use as dialogs will not be saved between maps 00132 // MLK: Saving dialog states 00133 for ( i=0; i<MI.DialogToSave.Length ; i++ ) 00134 { 00135 S.DialogToSave.Length++; 00136 S.DialogToSave[i].Lineind = MI.DialogToSave[i].Lineind; 00137 S.DialogToSave[i].Speakerind = MI.DialogToSave[i].Speakerind; 00138 } 00139 */ 00140 00141 Log(" -: XIIIThingsToSave have tag "$S.XIIISaveGameTriggerTag); 00142 00143 if ( TeleporterName != "" ) 00144 { 00145 foreach allactors(class'NavigationPoint', T, name(TeleporterName)) 00146 break; 00147 if (T == none) 00148 Log(" ---: Beware, var TeleporterName ("$TeleporterName$") don't match any NavigationPoint Tag"); 00149 } 00150 else 00151 Log(" ---: Beware, var TeleporterName ("$TeleporterName$") empty"); 00152 00153 // St = P.Controller.PlayerReplicationInfo.PlayerName$"-"$Level.Title$"-"$SaveDescription; 00154 St = /*Level.Title$"-"$*/SaveDescription; 00155 XIIICheatManager(PlayerController(P.Controller).CheatManager).LogInventory(); 00156 00157 if ( SaveAtCheckpoint(TeleporterName, St) ) 00158 { 00159 Log(" ---: Game Saved at checkpoint, TeleporterName="$TeleporterName$" & SaveDescription="$St); 00160 //P.ReceiveLocalizedMessage( class'XIIISaveMessage', 3, P.Controller.PlayerReplicationInfo, none, self ); 00161 } 00162 else 00163 { 00164 Log(" ---: ERROR Unable to save game at checkpoint, TeleporterName="$TeleporterName$" & SaveDescription="$St); 00165 //P.ReceiveLocalizedMessage( class'XIIISaveMessage', 5, P.Controller.PlayerReplicationInfo, none, self ); 00166 } 00167 00168 S.Destroy(); 00169 log(":ENDSAVE:"); 00170 //Destroy(); // for the test, it was moved at the end of the state code 00171 } 00172 Begin: 00173 if ( PrepareSave() ) 00174 { 00175 P.ReceiveLocalizedMessage( class'XIIISaveMessage', 1, P.Controller.PlayerReplicationInfo, none, self ); 00176 CleanMap(); 00177 DoSave(); 00178 //Sleep(1.0); 00179 //P.ReceiveLocalizedMessage( class'XIIISaveMessage', 2, P.Controller.PlayerReplicationInfo, none, self ); 00180 } 00181 00182 00183 // TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 00184 /* 00185 if (!RequestGetProfileList()) 00186 { 00187 log("Unable to get profile list"); 00188 } 00189 else 00190 { 00191 log ("GetProfileList requested. Waiting for completion"); 00192 while (!IsGetProfileListFinished(ReturnCode,ProfileList)) 00193 { 00194 Sleep(0.1); 00195 } 00196 if (ReturnCode<0) log ("Failure: Profile list not obtained"); 00197 else 00198 { 00199 log ("List of Profiles:"); 00200 for (ReturnCode=0; ReturnCode<ProfileList.Length; ReturnCode++) 00201 { 00202 log(" "$ProfileList[ReturnCode]); 00203 } 00204 } 00205 }*/ 00206 00207 /* 00208 if (!RequestCreateProfile("Tata")) 00209 { 00210 log ("Unable to Create profile for Tata"); 00211 } 00212 else 00213 { 00214 log ("CreateProfile requested for Tata. Waiting for completion"); 00215 while (!IsCreateProfileFinished(ReturnCode)) 00216 { 00217 Sleep(0.1); 00218 } 00219 if (ReturnCode<0) log ("Failure: Profile not created for Tata"); 00220 else log ("Profile created successfully for Tata"); 00221 } 00222 */ 00223 00224 /* 00225 if (!RequestGetProfileList()) 00226 { 00227 log("Unable to get profile list"); 00228 } 00229 else 00230 { 00231 log ("GetProfileList requested. Waiting for completion"); 00232 while (!IsGetProfileListFinished(ReturnCode,ProfileList)) 00233 { 00234 Sleep(0.1); 00235 } 00236 if (ReturnCode<0) log ("Failure: Profile list not obtained"); 00237 else 00238 { 00239 log ("List of Profiles:"); 00240 for (ReturnCode=0; ReturnCode<ProfileList.Length; ReturnCode++) 00241 { 00242 log(" "$ProfileList[ReturnCode]); 00243 } 00244 } 00245 } 00246 */ 00247 00248 /* 00249 if (!RequestUseProfile("Tata")) 00250 { 00251 log ("Unable to use profile Tata"); 00252 } 00253 else 00254 { 00255 log ("UseProfile requested for Tata. Waiting for completion"); 00256 while (!IsUseProfileFinished(ReturnCode)) 00257 { 00258 Sleep(0.1); 00259 } 00260 if (ReturnCode<0) log ("Failure: Profile Tata cannot be used"); 00261 else log ("Profile Tata is beeing used"); 00262 } 00263 00264 00265 for (i=0; i<GetMaxNumberOfSavingSlots(); i++) 00266 { 00267 if (!RequestIsSlotEmpty(i)) 00268 { 00269 log("Slot "$i$": Error: unable to access"); 00270 } 00271 else 00272 { 00273 while (!IsSlotEmptyFinished(ReturnCode, IsEmpty)) 00274 { 00275 Sleep(0.1); 00276 } 00277 if (ReturnCode < 0) 00278 { 00279 log("Slot "$i$": Error2: access failed"); 00280 } 00281 else 00282 { 00283 if (bool(IsEmpty)) 00284 { 00285 log("Slot "$i$": <EMPTY>"); 00286 } 00287 else 00288 { 00289 if (!RequestGetSlotContentDescription(i)) 00290 { 00291 log("Slot "$i$": Error3: not empty, but unable to get the description"); 00292 } 00293 else 00294 { 00295 while (!IsGetSlotContentDescriptionFinished(ReturnCode, Description)) 00296 { 00297 Sleep(0.1); 00298 } 00299 if (ReturnCode < 0) 00300 { 00301 log("Slot "$i$": Error4: get description failed"); 00302 } 00303 else 00304 { 00305 log("Slot "$i$": "$Description); 00306 } 00307 } 00308 } 00309 } 00310 } 00311 } 00312 */ 00313 00314 /* 00315 if (!RequestWriteSlot(5, "Test 2 SauvegardE")) 00316 { 00317 log("Unable to save in slot 5"); 00318 } 00319 else 00320 { 00321 while (!IsWriteSlotFinished(ReturnCode)) 00322 { 00323 Sleep(0.1); 00324 } 00325 if (ReturnCode < 0) 00326 { 00327 log("FAILED to save in slot 5"); 00328 } 00329 else 00330 { 00331 log("Game successfully saved in slot 5"); 00332 } 00333 } 00334 */ 00335 00336 //if (!ReadSlot(5)) 00337 //{ 00338 // log("Unable to load game in slot 5"); 00339 //} 00340 00341 /* 00342 if (!RequestWriteUserConfig()) 00343 { 00344 log("Unable to write use config !"); 00345 } 00346 else 00347 { 00348 while (!IsWriteUserConfigFinished(ReturnCode)) 00349 { 00350 Sleep(0.1); 00351 } 00352 if (ReturnCode < 0) 00353 { 00354 log("Failed to write user config !"); 00355 } 00356 else 00357 { 00358 log("user config successfull written"); 00359 } 00360 } 00361 */ 00362 00363 /* 00364 if (!RequestReadUserConfig()) 00365 { 00366 log("Unable to read use config !"); 00367 } 00368 else 00369 { 00370 while (!IsReadUserConfigFinished(ReturnCode)) 00371 { 00372 Sleep(0.1); 00373 } 00374 if (ReturnCode < 0) 00375 { 00376 log("Failed to read user config !"); 00377 } 00378 else 00379 { 00380 log("user config successfull read"); 00381 } 00382 } 00383 */ 00384 00385 00386 Destroy(); 00387 } 00388 00389 defaultproperties 00390 { 00391 TeleporterName="PlayerStart" 00392 }