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 |
class MPCarryableThrower extends TimeChargeUpWeapon; var() float extraSpawnDistance "This distance will be added when carryables spawn as projectiles. Can be used to prevent self-collisions."; var MPCarryable carryable; replication { reliable if (Role == ROLE_Authority) carryable; } simulated function heldByCharacter(Character c) { return; // MPCarryableThrower doesn't need this function } simulated function droppedByCharacter(Character c) { return; // MPCarryableThrower doesn't need this function } function setCarryable(MPCarryable c) { carryable = c; } protected function Projectile makeProjectile(Rotator fireRot, Vector fireLoc) { local vector newLoc; //hitLoc, hitNormal, startLoc; local int i; local MPCarryable extraCarryable; local Character c; local int numThrown; //local Vector extra, extraLoc, testLoc;; local bool bFreeze; c = Character(Owner); //startLoc = Owner.Location; //startLoc.z = c.EyeHeight; newLoc = fireLoc; //// hack check to stop carryable from falling through terrain //if (TerrainInfo(Trace(hitLoc, hitNormal, newLoc, startLoc, false, carryable.GetCollisionExtent())) != None) //{ // newLoc += hitNormal * carryable.CollisionHeight; //} //// Push the carryable further away from the player //// MJ: Disabled because it was used for Fuel but you currently can't throw Fuel //extra.X = extraSpawnDistance; //extra.Y = extraSpawnDistance; //extra.Z = 0; //extraLoc += Normal(Vector(fireRot)) * extra; //// Don't allow throwing through geometry //// MJ: Disabled...may no longer be necessary //startLoc -= Normal(Vector(fireRot)) * 10; //testLoc = extraLoc + Normal(Vector(fireRot)) * 10; //if (Trace(hitLoc, hitNormal, startLoc, fireLoc, true, carryable.GetCollisionExtent()) != None) //{ // bFreeze = true; // newLoc = c.Location - hitNormal * 20; //} // First compose carryables into their largest denominations (if applicable) c.composeCarryables(); // Throw carryables with spread // Don't throw the first one because it should be thrown without spread // Don't throw the character's permanent carryables // Throw in reverse so we can just chop off the array for(i=c.carryables.Length - 1; i>c.numPermanentCarryables; i--) { extraCarryable = c.carryables[i]; //Log("Carryable makeProjectile "$extraCarryable$", newLoc = "$newLoc$", shooterloc = "$c.Location$", fireRot = "$fireRot); launchCarryable(extraCarryable, newLoc, fireRot, true, bFreeze); numThrown++; } // Throw the first carryable without spread launchCarryable(c.carryables[0], newLoc, fireRot, false, bFreeze); numThrown++; fireCount++; // If none should be left, clear them completely if (c.numPermanentCarryables == 0) c.clearCarryables(); // Otherwise clear them partially else { c.carryables.Length = c.carryables.Length - numThrown; c.numCarryables = c.carryables.Length; } return None; } function launchCarryable(MPCarryable c, Vector newLoc, Rotator fireRot, bool bSpread, optional bool bFreeze) { local Vector X, Y, Z; local Vector newVelocity; GetAxes(fireRot, X, Y, Z); c.SetPhysics(c.droppedPhysics); c.bWasDropped = true; c.unifiedSetPosition(newLoc); //c.SetRotation(fireRot); newVelocity = Normal(Vector(fireRot)) * projectileVelocity; // Random spread for all carryables except the first if (bSpread) newVelocity += Vector(fireRot) + (c.spread * (FRand() - 0.5)) * X + (c.spread * (FRand() - 0.5)) * Y + (c.spread * (FRand() - 0.5)) * Z; // Charge it newVelocity *= charge * chargeScale + 1.0; // inherit velocity from pawn newVelocity += Owner.Velocity * projectileInheritedVelFactor; if (bFreeze) c.unifiedSetVelocity(Vect(0, 0, 0)); else c.unifiedSetVelocity(newVelocity); //Log("Launching "$c$" with velocity = "$newVelocity$" and charge "$charge$" at location "$newLoc$" in physics "$c.droppedPhysics); c.GotoState('Dropped'); } simulated function moveWeapon() { if (firstPersonMesh != None || firstPersonAltMesh != None) super.moveWeapon(); } protected function fireWeapon() { local Vector fireLoc; fireLoc = rookMotor.getProjectileSpawnLocation(); makeProjectile(getAimRotation(fireLoc), fireLoc); lastFireTime = Level.TimeSeconds; bFiredWeapon = true; } simulated state FirePressed { simulated function BeginState() { super.BeginState(); carryable.bThrowingEffect = true; carryable.updateCarryableEffects(); animClass.static.playEquippableAnim(self, fireAnimation); } } simulated state FireReleased { simulated function BeginState() { super.BeginState(); if (Role == ROLE_Authority) { carryable.bThrowingEffect = false; carryable.updateCarryableEffects(); } // carryable code will put state to 'dropped' } } // dropped state: we can never really be dropped, we just hide ourselves and disable collision so we can't be picked up simulated state Dropped { simulated function BeginState() { Character(Owner).removeEquipment(self); equipped = false; bHidden = true; SetCollision(false, false, false); } } // if carryable is a weapon-type, we need to handle display and attachment when we are the selected weapon simulated state Idle { simulated function BeginState() { super.BeginState(); if (Role == ROLE_Authority && carryable.bIsWeaponType) { carryable.bHidden = true; } } simulated function Tick(float Delta) { super.Tick(Delta); if (!IsAnimating()) playIdleAnim(); } } // if carryable is a weapon-type, we need to handle display and attachment when we are not the selected weapon simulated state Held { simulated function BeginState() { super.BeginState(); if (Role == ROLE_Authority && carryable.bIsWeaponType) { if (carryable.isReplicatedInstance()) { carryable.attachToCarrier(); carryable.bHidden = false; } else carryable.bHidden = true; } } } defaultproperties { firstPersonMesh = None thirdPersonMesh = None chargeScale = 1 maxCharge = 0.5 roundsPerSecond = 1.0 ammoCount = 1 ammoUsage = 1 projectileClass = None projectileVelocity = 800 projectileInheritedVelFactor = 1.0 firstPersonOffset = (X=50,Y=30,Z=0) aimClass = class'AimArcWeapons' animClass = class'CharacterEquippableAnimator' animPrefix = "Carryable" releaseAnimation = "throw" releaseDelay = 0.1 bShowChargeOnHUD = true bCanDrop = false extraSpawnDistance = 100 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |