Return to defence. First encounter seems human defence automated (cannons). No... not defaults. Defaults are sleeping well and ought to sleep well else server will sleep well. Good, enough with sleep, let's move on:
MinigunCannon (MH version)
Code: Select all
//=============================================================================
// MHMinigunCannon.
//=============================================================================
class MHMinigunCannon extends MHTeamCannon;
var Actor MuzzFlash;
function PostBeginPlay()
{
Super.PostBeginPlay();
MuzzFlash = Spawn(class'CannonMuzzle');
MuzzFlash.SetBase(self);
}
function Name PickAnim()
{
Drop = 0;
if (DesiredRotation.Pitch < -1000 )
{
if ( DesiredRotation.Pitch < -4000 )
return 'Fire5';
else
return 'Fire3';
}
else if (DesiredRotation.Pitch > 1000 )
{
if ( DesiredRotation.Pitch > 4000 )
return 'Fire9';
else
return 'Fire7';
}
else
return 'Fire1';
}
simulated function SpawnBase()
{
GunBase = Spawn(class'GrBase', self);
GunBase.bAnimByOwner = true;
}
function PlayDeactivate()
{
TweenAnim('Activate', 1.5);
}
function StartDeactivate()
{
PlaySound(ActivateSound, SLOT_None,5.0);
Mesh = mesh'Botpack.GrMockGunM';
AnimSequence = 'Fire1';
AnimFrame = 0.0;
SetPhysics(PHYS_Rotating);
DesiredRotation = StartingRotation;
PrePivot = vect(0,0,0);
}
function ActivateComplete()
{
Mesh = mesh'Botpack.GrFinalGunM';
PrePivot = vect(0,0,40);
}
function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local int rndDam;
local UT_Shellcase s;
s = Spawn(class'UT_ShellCase',, '', PrePivot + Location + 20 * X + 10 * Y + 30 * Z);
if ( s != None )
s.Eject(((FRand()*0.3+0.4)*X + (FRand()*0.2+0.2)*Y + (FRand()*0.3+1.0) * Z)*160);
if (Other == Level)
Spawn(class'UT_LightWallHitEffect',,, HitLocation+HitNormal, Rotator(HitNormal));
else if ( (Other!=self) && (Other != None) )
{
if ( !Other.bIsPawn && !Other.IsA('Carcass') )
spawn(class'UT_SpriteSmokePuff',,,HitLocation+HitNormal*9);
rndDam = 5 + Rand(4);
if ( DeathMatchPlus(Level.Game).bNoviceMode )
rnddam *= (0.4 + 0.15 * Level.game.Difficulty);
if (Other != None)
Other.TakeDamage(rndDam, self, HitLocation, rndDam*500.0*X, 'shot');
}
}
function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation,
Vector momentum, name damageType)
{
MakeNoise(1.0);
Health -= NDamage;
if (Health <0)
{
PlaySound(DeActivateSound, SLOT_None,5.0);
NextState = 'Idle';
Enemy = None;
Spawn(class'UT_BlackSmoke');
GotoState('DamagedState');
}
else if ( instigatedBy == None || InstigatedBy.IsA('TeamCannon') )
return;
else if ( (Enemy == None) && (!instigatedBy.bIsPlayer || !Level.Game.bTeamGame || !SameTeamAs(instigatedBy.PlayerReplicationInfo.Team)) )
{
Enemy = instigatedBy;
//////////////// MH Needs 1) accidental damaged
if (InstigatedBy.IsA('ScriptedPawn'))
{
ScriptedPawn(InstigatedBy).Hated=Self; //Claim enemy because I think I'll attack
ScriptedPawn(InstigatedBy).Enemy=Self;
//Should be enough
}
///////////////
GotoState('ActiveCannon'); //Probably yes
}
}
function Shoot()
{
local Actor HitActor;
local Vector HitLocation, HitNormal, EndTrace, ProjStart, X,Y,Z;
local rotator ShootRot;
if (DesiredRotation.Pitch < -10000) Return;
if ( AmbientSound == None )
PlaySound(FireSound, SLOT_None,5.0);
if ( Enemy != None )
{
GetAxes(Rotation,X,Y,Z);
ProjStart = PrePivot + Location + X*20 + 12 * Y + 16 * Z;
ShootRot = rotator(Enemy.Location - ProjStart);
ShootRot.Yaw = ShootRot.Yaw + 1024 - Rand(2048);
DesiredRotation = ShootRot;
ShootRot.Pitch = ShootRot.Pitch + 256 - Rand(512);
GetAxes(ShootRot,X,Y,Z);
PlayAnim(PickAnim());
MuzzFlash.SetLocation(ProjStart);
if ( FRand() < 0.4 )
Spawn(class'MTracer',,, ProjStart, ShootRot);
HitActor = TraceShot(HitLocation,HitNormal,ProjStart + 10000 * X,ProjStart);
ProcessTraceHit(HitActor, HitLocation, HitNormal, X,Y,Z);
bShoot = false;
ShootRot.Pitch = ShootRot.Pitch & 65535;
if ( ShootRot.Pitch < 32768 )
ShootRot.Pitch = Min(ShootRot.Pitch, 5000);
else
ShootRot.Pitch = Max(ShootRot.Pitch, 60535);
MuzzFlash.SetRotation(ShootRot);
ShootRot.Pitch = 0;
SetRotation(ShootRot);
}
else
{
GotoState('Idle');
return;
}
}
state ActiveCannon
{
ignores SeePlayer;
function EnemyNotVisible()
{
local Pawn P;
Enemy = None;
for ( P=Level.PawnList; P!=None; P=P.NextPawn )
if ( P.bCollideActors && !P.bDeleteMe && !P.bHidden && P.bIsPlayer && (!Level.Game.bTeamGame || !SameTeamAs(P.PlayerReplicationInfo.Team))
&& (P.Health > 0) && !P.IsA('TeamCannon')
&& LineOfSightTo(P) || (LineOfSightTo(P) && P.PlayerReplicationInfo == None && !P.IsA('StationaryPawn') && MyTeam == 0))
{
Enemy = P;
if ( P.IsA('ScriptedPawn') && FRand() > 0.6 && ScriptedPawn(P).Enemy!=Self) //2) Convince Monster about this threat randomly
{
ScriptedPawn(P).Hated=Self;
ScriptedPawn(P).Enemy=Self;
}
return;
}
GotoState('Idle');
}
function Killed(pawn Killer, pawn Other, name damageType)
{
Global.Killed(Killer,Other,damagetype);
if ( Other == Enemy )
{
EnemyNotVisible();
}
}
function Timer()
{
local Pawn P;
if (Enemy != None && !Enemy.bHidden && !Enemy.bDeleteMe && LineOfSightTo(Enemy))
{
if ( Target == None )
Target = Enemy;
if ( Target == None )
{
GotoState('Idle');
return;
}
DesiredRotation = rotator(Target.Location - Location - PrePivot);
DesiredRotation.Yaw = DesiredRotation.Yaw & 65535;
MuzzFlash.bHidden = false;
if ( bShoot )
Shoot();
else
{
TweenAnim(PickAnim(), 0.2);
bShoot=True;
SetTimer(SampleTime,True);
}
}
else
{ GotoState('Idle'); return; }
}
function BeginState()
{
Super.BeginState();
}
function EndState()
{
AmbientSound = None;
MuzzFlash.bHidden = true;
}
Begin:
Disable('Timer');
FinishAnim();
PlayActivate();
FinishAnim();
ActivateComplete();
Enable('Timer');
SetTimer(SampleTime,True);
RotationRate.Yaw = TrackingRate;
SetPhysics(PHYS_Rotating);
AmbientSound = Class'Minigun2'.Default.FireSound;
bShoot=True;
FaceEnemy:
if (Enemy != None && LineOfSightTo(Enemy))
{
TurnToward(Enemy);
Goto('FaceEnemy');
}
else{ Target = None; Enemy = None; GotoState('Idle');}
}
defaultproperties
{
FireSound=Sound'UnrealI.Rifle.RifleShot'
SampleTime=0.100000
Mesh=LodMesh'Botpack.grmockgunM'
SoundRadius=96
SoundVolume=255
CollisionHeight=24.000000
}
Would be more easier to add uc files but seems unallowed so ...
The deal is: Cannon with MyTeam=0 will be player's friend else in MyTeam=1 will hunt player. Cannon friend of player will hunt monster, monster will respond if gets mad. Player defence being ready I have to setup monster mission things. I'll see ...