Code:
class MMSkillMagicMissile extends MMSkill;
const AdjustPoint = 100;
const GatherDist = 50; //The distance from the offset point the missile needs to get before chasing the target
const SquareAngle = 16384;
var Vector PointTarget[2]; //If there is no target, define two points to follow
var float PosOffset; //A little random distance from the target
//debug
//var(Debug) bool bDebug; // Used to toggle debug logging
simulated function CustomFire()
{
//The variables for the tracing
local Vector End, PawnEyePosition, PawnEyeHitLocation, PawnEyeHitNormal, CameraHitLocation, CameraHitNormal;
local Rotator CameraRotation;
local TargetableObject CameraHitObject, PawnEyeHitObject;
local Actor SeekTarget;
//The variables for the missile position
local Vector Offset, Pos[5], Loc, Tar[2], CamLoc;
local Rotator Facing, ViewRot, Temp;
local float CRadius, CHeight;
local int i;
local MMMagicMissile Missile;
if ( Owner.Role == ROLE_Authority )
{
Loc = Owner.Location;
CamLoc = MMGamePawn(Owner).GetPawnViewLocation();
MMGamePawn(Owner).GetPawnEyesViewPoint(PawnEyePosition, CameraRotation);
End = CamLoc + (Vector(CameraRotation) * WeaponRange);
CameraHitObject = TargetableObject(Owner.Trace(CameraHitLocation, CameraHitNormal, End, CamLoc, true, Vect(3,3,3)));
//Owner.DrawDebugLine(CamLoc, End, 255, 0, 0, true);
if (CameraHitObject != none)
{
PawnEyeHitObject = TargetableObject(Owner.Trace(PawnEyeHitLocation, PawnEyeHitNormal, CameraHitLocation, PawnEyeHitLocation, true, Vect(3,3,3)));
if (IsZero(PawnEyeHitLocation) || CameraHitObject == PawnEyeHitObject)
{
SeekTarget = CameraHitObject;
//`Log(CameraHitObject @ PawnEyeHitObject @ SeekTarget);
}
}
Facing = Pawn(Owner).GetViewRotation();
Facing.Pitch = 0;
//Facing = Owner.newRotation;
CRadius = Pawn(Owner).GetCollisionRadius();
CHeight = Pawn(Owner).GetCollisionHeight();
Offset = Loc - (Vector(Facing) * (CRadius / 1.5));
ViewRot = Pawn(Owner).GetViewRotation();
Tar[0] = CamLoc + (Vector(ViewRot) * AdjustPoint);
Tar[1] = CamLoc + (Vector(ViewRot) * 2500);
Temp = Facing;
Temp.Yaw += SquareAngle;
Pos[0] = Offset + (Vector(Temp) * CRadius);
Temp = Facing;
Temp.Yaw -= SquareAngle;
Pos[1] = Offset + (Vector(Temp) * CRadius);
Pos[2] = Pos[0] + (Vect(0, 0, 1) * (CHeight / 1.5));
Pos[3] = Pos[1] + (Vect(0, 0, 1) * (CHeight / 1.5));
Pos[4] = Offset + (Vect(0, 0, 1) * CHeight);
Offset = Offset - (Vector(Facing) * (CRadius / 2)); //So the missiles do a better turn
for(i=0; i<5; i++)
{
Missile = Owner.Spawn(class'MMMagicMissile', Owner, , Pos[i], Rotator(Pos[i] - Offset), , true);
if( Missile != None && !Missile.bDeleteMe )
{
//Missile.InitialRelease = Loc;
Missile.GatherDist = GatherDist;
Missile.AdjustPoint = AdjustPoint;
//Missile.PointTarget[0] = Tar[0];// + (VRand() * PosOffset);
Missile.PointTarget = Tar[1];// + (VRand() * (PosOffset / 2));
Missile.VectorTarget = Tar[0];
Missile.SetTarget(SeekTarget, true);
//Missile.Init(Pos[i] - Offset);
`Log("Magic Missile incomming");
}
}
if (bDebug)
{
Missile.bDebug = true;
Owner.DrawDebugSphere(Tar[0], 25, 8, 0, 0, 255, true);
Owner.DrawDebugSphere(Tar[1], 16, 8, 255, 0, 0, true);
}
}
}
DefaultProperties
{
bDebug=false
SkillName="Magic Missile"
bCanChannel=true
WeaponRange=1200
maxChannelTime=3.f
MagicCost=5
MagicChannelCost=10
MagicDamage=5
MagicDamageChannel=15
PosOffset=30.f;
//Weapon variables
FireInterval(0)=+1.0;
WeaponFireTypes(0)=EWFT_Custom
WeaponProjectiles(0)=class'MMMagicMissile'
FiringStatesArray(0)=WeaponFiring
}
Bookmarks