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 |
//============================================================================= // ArbitItem - Arbitrary Item spawner // (c) }TCP{Wolf aka Mia_The_Chaotic 2005 // TODO: // - AdjustedSpawnTime: done 18.09.2005 // - Capacity: done 18.09.2005 // - Random: done 18.09.2005 // - Have items fall to GROUND (Krull) since some items look stupid when // spawned one after another (Belt floats in air, armor on ground) // done 18.08.2007 // - Tag: hmm... tag is set on spawn, what about event? // - 04.010.2007 - build 3 - findReplacedItem was buggy // THANKS KRULL would probably not have found that without you lol //============================================================================= class ArbitItem expands Pickup; //Actor; // subclassing pickup for "MyMarker" (Bot support) //var InventorySpot MyMarker; // Debug var() bool bDebug; // logs some extra stuff if true // CFG var() config class<Inventory> SpawnItem[10]; // what to spawn var() config byte SpawnItemFallsToGround[10]; // if true(1), spawned item will fall to ground instead of float in the air var() config float AdjustedSpawnTime; // how much faster/slower to spawn stuff var int numItems; // number of actors in spawnlist (dynamically filled) var int nextItem; // next Actor in list to spawn var() config int Capacity_max; // if greater than 0, there is a capacity limit var int Capacity; // current capacity remaining var bool bCapacity; // capacity feature on off var() config bool bRandomize; // if true, next item will always be picked randomely // Runtime reference var Inventory currentItem; // reference to currently spawned item // other runtime variables var float SleepTime; // time in seconds until the next item is spawned event PostBeginPlay() { // make invis if not debugging if (!bDebug) { DrawType=DT_None; //default.DrawType=DT_None; } Super(Actor).PostbeginPlay(); // don't execute Pickup.PostBeginPlay(); //Super.PostBeginPlay(); // check capacity feature if (Capacity_max > 0) { bCapacity = true; Capacity = Capacity_max; } } event destroyed() { if (bDebug) LOG(self$" DESTROYED!!!!"); if (currentItem != None) currentItem.destroy(); if (MyMarker != None) MyMarker.markedItem = None; } /* STARTING STATE - FIRST WE HAVE TO SEE IF ITEMS WE ARE SPAWNING ARE REPLACED. THUS, WE HAVE TO ADJUST THE SPAWNLIST... */ auto state CheckReplacement { function BeginState() { local int i; local Actor what; // destroy any other actors inside a 2-mark radius (safeguard) foreach RadiusActors(Class'Actor', what,2,location) { if (what != self) { if (bDebug) log("safeguard destroys "$what,'ARBITITEM'); what.destroy(); } } // looks like 224 has a problem with default properties... this is for debugging // commented out in release // DEBUG BEGIN /*SpawnItem[0]=class'UnrealI.ASMD'; SpawnItem[1]=class'UnrealShare.Armor'; SpawnItem[2]=class'UnrealShare.SuperHealth';*/ // DEBUG END for (i=0; i<ArrayCount(SpawnItem); i++) { if (bDebug) log("CheckReplacement state - check item = "$i$" - "$SpawnItem[i],'ARBITITEM'); if (SpawnItem[i]!=None) numItems = i+1; } nextItem = 0; if (bDebug) log("CheckReplacement state - numItems = "$numItems,'ARBITITEM'); if (bDebug) logSpawnList(); if (numItems <= 0) { log(self$" without any Items to spawn - self-terminating!",'ARBITITEM'); self.destroy(); return; } // check if stuff gets replaced if (bDebug) log("Starting replacement check on items...",'ARBITITEM'); for (i=0; i< numItems; i++) { // spawn item currentItem = spawn(SpawnItem[i], Owner, Tag, Location, Rotation); //if (currentItem != None) Level.Game.IsRelevant(currentItem); if (bDebug) log("CURRENT ITEM ===== "$i@CurrentItem,'ARBITITEM'); if ((currentItem == None) || (currentItem.bDeleteMe)) { // item was replaced currentItem = findReplacedItem(); if (currentItem == none) // item was either destroyed or replaced by a non-Item removeItem(i); else // enter the class of the new item in the original's place SpawnItem[i] = currentItem.class; } if (currentItem != None) currentItem.destroy(); } if (bDebug) log("Completed replacement check on items...",'ARBITITEM'); // check again if all items were replaced... if (numItems <= 0) { log(self$" had all its Items replaced and is now without any Items to spawn - self-terminating!"); self.destroy(); return; } if (bDebug) log(self$" has "$numItems$" after replacement check...",'ARBITITEM'); if (bDebug) logSpawnList(); nextItem = 0; if (currentItem != None) currentItem.destroy(); if (bDebug) log("GOTOSTATE Pickup!",'ARBITITEM'); gotoState('Pickup'); } /* function EndState() { log("Endstate CHECK"); } */ } // end state checkreplacement // aid function - tries to determine what item the last spawned has // been replaced with function Inventory findReplacedItem() { local Actor what; local Inventory result; if (bDebug) log("Trying to find replaced item...",'ARBITITEM'); foreach RadiusActors(Class'Actor', what,2,location) { if ( (what != none) && // found something (what != self) && // is not self arbititem (Inventory(what) != none) // it is an inventory item ) break; } if (what == none) { if (bDebug) log("item was destroyed...",'ARBITITEM'); return none; } result = Inventory(what); /*if (result == none) { log(self$" item was replaced but "$what.class$" is not a Item.",'ARBITITEM'); what.destroy(); return none; }*/ return result; } function removeItem(int which) { local int i; if (bDebug) log("Removing item "$which$" ("$SpawnItem[which]$") from list...",'ARBITITEM'); for (i=which; i<numItems-1; i++) SpawnItem[i] = SpawnItem[i+1]; SpawnItem[--numItems] = None; } // simply log entire list function logSpawnList() { local int i; log(self$" has spawnlist:",'ARBITITEM'); for (i=0; i<arrayCount(SpawnItem); i++) log(i$" "$SpawnItem[i],'ARBITITEM'); } /* STATE Item: Spawn item until it has been picked up. */ state Pickup { function BeginState() { if (bDebug) log("BeginState pickup - spawn item "$nextItem$"="$SpawnItem[nextItem],'ARBITITEM'); // spawn next item currentItem = spawn(SpawnItem[nextItem], Owner, Tag, Location, Rotation); if (bCapacity) Capacity--; if (currentItem == none) log("Spawn failure of "$nextItem$" - "$SpawnItem[nextItem]$"!",'ARBITITEM'); else { Level.Game.PlaySpawnEffect(currentItem); currentItem.Event = Event; // should we? // Physics? implemented for Krull at 18.08.2007 if (SpawnItemFallsToGround[nextItem]>0) currentItem.SetPhysics(Phys_Falling); } // if it is a weapon, make it so it is always picked up when touched if (currentItem.IsA('Weapon')) Weapon(currentItem).bWeaponStay = false; // use Item's properties to adjust self properly self.SetCollisionSize(currentItem.CollisionRadius, currentItem.CollisionHeight); // bot support if (MyMarker != None) { currentItem.MyMarker = MyMarker; MyMarker.markedItem = currentItem; } if (bDebug) log("PICKUP! "$CollisionRadius$" "$CollisionHeight,'ARBITITEM'); // set 2ndary check... SetTimer(getRespawnTime()*0.2, true); if (bRandomize) { nextItem = rand(numItems); if (bDebug) log("random -> next="$nextItem,'ARBITITEM'); } else { nextItem++; if (nextItem >= numItems) nextItem = 0; } Enable('Touch'); Enable('Timer'); } function EndState() { disable('Touch'); // no effect? disable('Timer'); } // secondary constant check if item was taken function Timer() { if (bDebug) log("timer...",'ARBITITEM'); if (!currentItem.isInState('Sleeping')) return; ItemTaken(); } // triggered when somebody touches (the Item currently spawned) event Touch( Actor Other ) { if (bDebug) log(Other$" touched...",'ARBITITEM'); if (bDebug) log("state of currentItem = "$currentItem.getStateName(),'ARBITITEM'); if (!Other.IsA('Pawn')) return; // simple check to deter other types of touch // would if (!Other.ValidTouch(currentItem)) work? if (!currentItem.isInState('Sleeping')) return; // the item was NOT taken... ItemTaken(); } function ItemTaken() { // item was taken... // sleep the amount of time the NEXT item to be spawned takes to spawn SleepTime = getRespawnTime(); if (bDebug) log("Item taken... now going to sleep "$SleepTime,'ARBITITEM'); currentItem.destroy(); if (MyMarker != None) MyMarker.markedItem = None; if ((bCapacity) && (Capacity <= 0)) { if (bDebug) log(self$" capacity zero... disabling..."); self.destroy(); return; } gotoState('Sleeping'); } } /* STATE SLEEPING: inventory which is lying around in the map awaiting being picked up is in the state "sleeping". Thus, I found it fitting the spawner should be in exactly that state until the next item is supposed to become available */ state Sleeping { function BeginState() { if (bDebug) log(self$" BeginState SLEEPING",'ARBITITEM'); } function EndState() { if (bDebug) log(self$" EndState SLEEPING",'ARBITITEM'); } Begin: Sleep(SleepTime); // the amount of sleeptime was determined in state Pickup gotoState('Pickup'); } // Bot support event float BotDesireability( pawn Bot ) { local float result; if (currentItem == None) result = -1; else result = (currentItem.BotDesireability(Bot)); if (bDebug) log(self$" was desired by "$Bot$" - currentItem="$currentItem$" result="$result,'ARBITITEM'); return result; } // things to disable from normal pickup event Touch( Actor Other ) {} // don't do anything outside of state pickup /* state Pickup { function BeginState() {gotoState('Pickup');} Begin: gotoState('Pickup'); } */ /* event Timer() {log("event timer");} event HitWall( vector HitNormal, actor HitWall ) {log("event hitwall");} event Falling() {log("event falling");} event Landed( vector HitNormal ) {log("event landed");} event ZoneChange( ZoneInfo NewZone ) {log("event zonechange");} event UnTouch( Actor Other ) {log("event untouch");} event Bump( Actor Other ) {log("event bump");} event BaseChange() {log("event basechange");} event Attach( Actor Other ) {log("event attach");} event Detach( Actor Other ) {log("event detach");} event KillCredit( Actor Other ) {log("event killcredit");} event Actor SpecialHandling(Pawn Other) {log("event specialhandling");} event bool EncroachingOn( actor Other ) {log("event encroachingon");} event EncroachedBy( actor Other ) {log("event encroachedby");} event InterpolateEnd( actor Other ) {log("event interpolateend");} event EndedRotation() {log("event endedrotation");} */ // other functions // get respawn of next item function float getRespawnTime() { return SpawnItem[nextItem].default.RespawnTime * AdjustedSpawnTime; } //SpawnItemFallsToGround(1)=1 defaultproperties { SpawnItem(1)=Class'UnrealShare.ShieldBelt' SpawnItem(2)=Class'UnrealShare.SuperHealth' AdjustedSpawnTime=1.000000 bHidden=True RemoteRole=ROLE_None DrawType=DT_Sprite CollisionRadius=1.000000 CollisionHeight=1.000000 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |