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 |
/** replaces weapons with other weapons (including ammo) * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. */ class UTMutator_WeaponReplacement extends UTMutator config(Game); struct ReplacementInfo { /** class name of the weapon we want to get rid of */ var name OldClassName; /** fully qualified path of the class to replace it with */ var string NewClassPath; }; var config array<ReplacementInfo> WeaponsToReplace; var config array<ReplacementInfo> AmmoToReplace; function PostBeginPlay() { local UTGame Game; local int i, Index; Super.PostBeginPlay(); // replace default weapons Game = UTGame(WorldInfo.Game); if (Game != None) { for (i = 0; i < Game.DefaultInventory.length; i++) { if (Game.DefaultInventory[i] != None) { Index = WeaponsToReplace.Find('OldClassName', Game.DefaultInventory[i].Name); if (Index != INDEX_NONE) { if (WeaponsToReplace[Index].NewClassPath == "") { // replace with nothing Game.DefaultInventory.Remove(i, 1); i--; } Game.DefaultInventory[i] = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class')); } } } if (Game.TranslocatorClass != None) { Index = WeaponsToReplace.Find('OldClassName', Game.TranslocatorClass.Name); if (Index != INDEX_NONE) { if (WeaponsToReplace[Index].NewClassPath == "") { // replace with nothing Game.TranslocatorClass = None; } else { Game.TranslocatorClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class')); } } } } } function bool CheckReplacement(Actor Other) { local UTWeaponPickupFactory WeaponPickup; local UTWeaponLocker Locker; local UTAmmoPickupFactory AmmoPickup, NewAmmo; local int i, Index; local class<UTAmmoPickupFactory> NewAmmoClass; WeaponPickup = UTWeaponPickupFactory(Other); if (WeaponPickup != None) { if (WeaponPickup.WeaponPickupClass != None) { Index = WeaponsToReplace.Find('OldClassName', WeaponPickup.WeaponPickupClass.Name); if (Index != INDEX_NONE) { if (WeaponsToReplace[Index].NewClassPath == "") { // replace with nothing return false; } WeaponPickup.WeaponPickupClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class')); WeaponPickup.InitializePickup(); } } } else { Locker = UTWeaponLocker(Other); if (Locker != None) { for (i = 0; i < Locker.Weapons.length; i++) { if (Locker.Weapons[i].WeaponClass != None) { Index = WeaponsToReplace.Find('OldClassName', Locker.Weapons[i].WeaponClass.Name); if (Index != INDEX_NONE) { if (WeaponsToReplace[Index].NewClassPath == "") { // replace with nothing Locker.ReplaceWeapon(i, None); } else { Locker.ReplaceWeapon(i, class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'))); } } } } } else { AmmoPickup = UTAmmoPickupFactory(Other); if (AmmoPickup != None) { Index = AmmoToReplace.Find('OldClassName', AmmoPickup.Class.Name); if (Index != INDEX_NONE) { if (AmmoToReplace[Index].NewClassPath == "") { // replace with nothing return false; } NewAmmoClass = class<UTAmmoPickupFactory>(DynamicLoadObject(AmmoToReplace[Index].NewClassPath, class'Class')); if (NewAmmoClass == None) { // replace with nothing return false; } else if (NewAmmoClass.default.bStatic || NewAmmoClass.default.bNoDelete) { // transform the current ammo into the desired class AmmoPickup.TransformAmmoType(NewAmmoClass); return true; } else { // spawn the new ammo, link it to the old, then disable the old one NewAmmo = AmmoPickup.Spawn(NewAmmoClass); NewAmmo.OriginalFactory = AmmoPickup; AmmoPickup.ReplacementFactory = NewAmmo; return false; } } } } } return true; } defaultproperties { WeaponsToReplace(0)=(OldClassName="UTWeap_LinkGun",NewClassPath="UTGameContent.UTWeap_BioRifle_Content") WeaponsToReplace(1)=(OldClassName="UTWeap_FlakCannon",NewClassPath="UTGameContent.UTWeap_BioRifle_Content") AmmoToReplace(0)=(OldClassName="UTAmmo_FlakCannon",NewClassPath="UTGameContent.UTAmmo_BioRifle_Content") AmmoToReplace(1)=(OldClassName="UTAmmo_LinkGun",NewClassPath="UTGameContent.UTAmmo_BioRifle_Content") GroupNames(0)="WEAPONMOD" Begin Object Class=SpriteComponent Name=Sprite ObjName=Sprite Archetype=SpriteComponent'UTGame.Default__UTMutator:Sprite' ObjectArchetype=SpriteComponent'UTGame.Default__UTMutator:Sprite' End Object Components(0)=Sprite Name="Default__UTMutator_WeaponReplacement" ObjectArchetype=UTMutator'UTGame.Default__UTMutator' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |