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 |
//----------------------------------------------------------- // //----------------------------------------------------------- class GiveItemsInv extends Inventory; //client side only var PlayerController PC; var Player Player; var DruidsRPGKeysInteraction DKInteraction; replication { reliable if (Role<ROLE_Authority) DropHealthPickup, DropAdrenalinePickup; } function PostBeginPlay() { if(Level.NetMode == NM_DedicatedServer || Level.NetMode == NM_ListenServer || Level.NetMode == NM_Standalone) setTimer(5, true); super.postBeginPlay(); } simulated function PostNetBeginPlay() { if(Level.NetMode != NM_DedicatedServer) enable('Tick'); super.PostNetBeginPlay(); } simulated function Tick(float deltaTime) { local int x; if (Level.NetMode == NM_DedicatedServer || DKInteraction != None) { disable('Tick'); } else { PC = Level.GetLocalPlayerController(); if (PC != None) { Player = PC.Player; if(Player != None) { //first, find out if they have the interaction already. for(x = 0; x < Player.LocalInteractions.length; x++) { if(DruidsRPGKeysInteraction(Player.LocalInteractions[x]) != None) { DKInteraction = DruidsRPGKeysInteraction(Player.LocalInteractions[x]); } } if(DKInteraction == None) //they dont have one AddInteraction(); } if(DKInteraction != None) disable('Tick'); } } } //not done through the interaction master, because that requires a string with a package name. simulated function AddInteraction() { DKInteraction = new class'DruidsRPGKeysInteraction'; if (DKInteraction != None) { Player.LocalInteractions.Length = Player.LocalInteractions.Length + 1; Player.LocalInteractions[Player.LocalInteractions.Length-1] = DKInteraction; DKInteraction.ViewportOwner = Player; // Initialize the Interaction DKInteraction.Initialize(); DKInteraction.Master = Player.InteractionMaster; } else Log("Could not create DruidsRPGKeysInteraction"); } // AddInteraction simulated function Destroyed() { if(DKInteraction != None) { RemoveInteraction(); } super.Destroyed(); } simulated function RemoveInteraction() { if(Player != None && Player.InteractionMaster != None && DKInteraction != None) Player.InteractionMaster.RemoveInteraction(DKInteraction); DKInteraction = None; } static function DropHealth(Pawn P) { local GiveItemsInv GI; if (P == None) return; if (P.Health <= 25) return; // ok, lets try it GI = GiveItemsInv(P.FindInventoryType(class'GiveItemsInv')); if (GI != None) { GI.DropHealthPickup(); } } function DropHealthPickup() { local vector X, Y, Z; local Inventory Inv; local int HealthUsed; local RPGStatsInv StatsInv; local int ab; local Pawn PawnOwner; local Pickup NewPickup; PawnOwner = Pawn(Owner); if (PawnOwner == None) return; HealthUsed = class'HealthPack'.default.HealingAmount; // ok, now we need to check if this bod has smart healing, to avoid throw and pickup exploit for (Inv = PawnOwner.Controller.Inventory; Inv != None; Inv = Inv.Inventory) { StatsInv = RPGStatsInv(Inv); if (StatsInv != None) break; } if (StatsInv == None) //fallback, should never happen StatsInv = RPGStatsInv(PawnOwner.FindInventoryType(class'RPGStatsInv')); if (StatsInv != None) //this should always be the case { for (ab = 0; ab < StatsInv.Data.Abilities.length; ab++) { if (ClassIsChildOf(StatsInv.Data.Abilities[ab], class'AbilitySmartHealing')) { HealthUsed += 25 * 0.25 * StatsInv.Data.AbilityLevels[ab]; } } } if (PawnOwner.Health <= HealthUsed) return; GetAxes(PawnOwner.Rotation, X, Y, Z); NewPickup = PawnOwner.spawn(class'HealthPack',,, PawnOwner.Location + 1.5 * PawnOwner.CollisionRadius * Vector(PawnOwner.Controller.GetViewRotation())); if (NewPickup == None) { return; } NewPickup.RemoteRole = ROLE_SimulatedProxy; NewPickup.bReplicateMovement = True; NewPickup.bTravel=True; NewPickup.NetPriority=1.4; NewPickup.bClientAnim=true; NewPickup.Velocity = Vector(PawnOwner.Controller.GetViewRotation()); NewPickup.Velocity = NewPickup.Velocity * ((PawnOwner.Velocity Dot NewPickup.Velocity) + 500) + Vect(0,0,200); NewPickup.RespawnTime = 0.0; NewPickup.InitDroppedPickupFor(None); NewPickup.bAlwaysRelevant = True; PawnOwner.Health -= HealthUsed; if (PawnOwner.Health <= 0) PawnOwner.Health = 1; // dont kill it by throwing health. Shouldn't really need this, but... // no exp for dropping health - too exploitable } static function DropAdrenaline(Pawn P) { local GiveItemsInv GI; if (P == None) return; if (P.Health <= 25) return; // ok, lets try it GI = GiveItemsInv(P.FindInventoryType(class'GiveItemsInv')); if (GI != None) { GI.DropAdrenalinePickup(); } } function DropAdrenalinePickup() { local vector X, Y, Z; local Pawn PawnOwner; local AdrenalinePickup NewPickup; PawnOwner = Pawn(Owner); if (PawnOwner == None) return; if (PawnOwner.Controller == None) return; if (PawnOwner.Controller.Adrenaline < 25) return; GetAxes(PawnOwner.Rotation, X, Y, Z); NewPickup = PawnOwner.spawn(class'AdrenalinePickup',,, PawnOwner.Location + 1.5 * PawnOwner.CollisionRadius * Vector(PawnOwner.Controller.GetViewRotation())); if (NewPickup == None) { return; } NewPickup.RemoteRole = ROLE_SimulatedProxy; NewPickup.bReplicateMovement = True; NewPickup.bTravel=True; NewPickup.NetPriority=1.4; NewPickup.bClientAnim=true; NewPickup.Velocity = Vector(PawnOwner.Controller.GetViewRotation()); NewPickup.Velocity = NewPickup.Velocity * ((PawnOwner.Velocity Dot NewPickup.Velocity) + 500) + Vect(0,0,200); NewPickup.RespawnTime = 0.0; NewPickup.InitDroppedPickupFor(None); NewPickup.bAlwaysRelevant = True; NewPickup.AdrenalineAmount = 25; NewPickup.SetDrawScale(class'AdrenalinePickup'.default.DrawScale * 2); // bigger cos more adrenaline PawnOwner.Controller.Adrenaline -= 25; if (PawnOwner.Controller.Adrenaline < 0) PawnOwner.Controller.Adrenaline = 0; // no exp for dropping health - too exploitable } defaultproperties { bOnlyRelevantToOwner=False bAlwaysRelevant=True RemoteRole=ROLE_AutonomousProxy } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |