RuneI
Class Sword

source: c:\runehov\RuneI\Classes\sword.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Weapon
            |
            +--RuneI.Sword
Direct Known Subclasses:DwarfBattleSword, DwarfWorkSword, RomanSword, VikingBroadSword, VikingShortSword

class Sword
extends Engine.Weapon

//============================================================================= // Sword. //=============================================================================
Variables
 S1, S2
           temp

States
Throw

Function Summary
 
simulated
Debug(Canvas canvas, int mode)
 void SpawnHitEffect(vector HitLoc, vector HitNorm, int LowMask, int HighMask, Actor HitActor)
     
//=============================================================================
//
// SpawnHitEffect
//
// Spawns an effect based upon what was struck
//=============================================================================
 bool StickInWall(EMatterType matter)
     
//=============================================================================
//
// StickInWall
//
//=============================================================================


State Throw Function Summary
 int CalculateDamage(Actor Victim)



Source Code


00001	//=============================================================================
00002	// Sword.
00003	//=============================================================================
00004	class Sword expands Weapon
00005		abstract;
00006	
00007	var vector S1, S2;	//temp
00008	
00009	//=============================================================================
00010	//
00011	// SpawnHitEffect
00012	//
00013	// Spawns an effect based upon what was struck
00014	//=============================================================================
00015	function SpawnHitEffect(vector HitLoc, vector HitNorm, int LowMask, int HighMask, Actor HitActor)
00016	{	
00017		local int i,j;
00018		local EMatterType matter;
00019		local vector traceEnd, traceStart;
00020		local float traceDist;
00021		local rotator rot;
00022	
00023		// Determine what kind of matter was hit
00024		if ((HitActor.Skeletal != None) && (LowMask!=0 || HighMask!=0))
00025		{
00026			for (j=0; j<HitActor.NumJoints(); j++)
00027			{
00028				if (((j <  32) && ((LowMask  & (1 <<  j      )) != 0)) ||
00029					((j >= 32) && (j < 64) && ((HighMask & (1 << (j - 32))) != 0)) )
00030				{	// Joint j was hit
00031					matter = HitActor.MatterForJoint(j);
00032					break;
00033				}
00034			}
00035		}
00036		else if(HitActor.IsA('LevelInfo'))
00037		{
00038			matter = HitActor.MatterTrace(HitLoc, Owner.Location, WeaponSweepExtent);	
00039			//Only draw decals on walls...
00040			if(HitNorm.Z > -0.1 && HitNorm.Z < 0.1)
00041				Spawn(class'DecalSlash',,,, rotator(HitNorm));
00042		}
00043		else
00044		{
00045			matter = HitActor.MatterForJoint(0);
00046		}
00047	
00048		PlayHitMatterSound(matter);
00049	
00050		// Create effects
00051		switch(matter)
00052		{
00053			case MATTER_FLESH:
00054				if(HitActor.IsA('Sark') || HitActor.IsA('SarkRagnar'))
00055					Spawn(class'SarkBloodMist',,, HitLoc, rotator(HitNorm)); // Sark blood
00056				else
00057					Spawn(class'BloodMist',,, HitLoc, rotator(HitNorm));
00058	
00059				if(BloodTexture != None && !Region.Zone.bWaterZone && !class'GameInfo'.Default.bVeryLowGore)
00060				{
00061					SkelGroupSkins[1] = BloodTexture;
00062				}
00063				break;
00064			case MATTER_WOOD:
00065				Spawn(class'HitWood',,, HitLoc, rotator(HitNorm));
00066				break;
00067			case MATTER_STONE:
00068				Spawn(class'HitStone',,, HitLoc, rotator(HitNorm));
00069				break;
00070			case MATTER_METAL:
00071				Spawn(class'HitMetal',,, HitLoc, rotator(HitNorm));
00072				break;
00073			case MATTER_EARTH:
00074				Spawn(class'GroundDust',,, HitLoc, rotator(HitNorm));
00075				break;
00076			case MATTER_BREAKABLEWOOD:
00077				break;
00078			case MATTER_BREAKABLESTONE:
00079				break;
00080			case MATTER_WEAPON:
00081				Spawn(class'HitWeapon',,, HitLoc, rotator(HitNorm));
00082				break;
00083			case MATTER_SHIELD:
00084				break;
00085			case MATTER_ICE:
00086				Spawn(class'HitIce',,, HitLoc, rotator(HitNorm));
00087				break;
00088			case MATTER_WATER:
00089				break;
00090			case MATTER_SNOW:
00091				break;
00092		}
00093	}
00094	
00095	
00096	//=============================================================================
00097	//
00098	// StickInWall
00099	//
00100	//=============================================================================
00101	function bool StickInWall( EMatterType matter)
00102	{
00103		local rotator r;
00104		local vector X,Y,Z;
00105		local float WeaponLength;
00106	
00107		if (matter!=MATTER_WOOD && matter!=MATTER_ICE &&
00108			matter!=MATTER_EARTH && matter!=MATTER_SNOW &&
00109			matter!=MATTER_FLESH && matter!=MATTER_BREAKABLEWOOD)
00110			return false;
00111	
00112		// Coax any orientation into good range
00113		r = Rotation;
00114		r.Roll = Clamp(r.Roll, 27000, 34000);
00115		//slog("Roll="$R.Roll@"[27000..34000]");
00116	
00117		// Determine if it would be sticking into wall
00118		GetAxes(r, X,Y,Z);
00119		WeaponLength = VSize(GetJointPos(SweepJoint2)-GetJointPos(SweepJoint1));
00120		S1 = Location;
00121		S2 = Location + Y*WeaponLength;
00122	
00123		if (!FastTrace(Location + Y*WeaponLength, Location))
00124		{	// Stuck in wall
00125			SetRotation(r);
00126			return true;
00127		}
00128	
00129		return false;
00130	}
00131	
00132	simulated function Debug(Canvas canvas, int mode)
00133	{
00134		Super.Debug(canvas, mode);
00135		Canvas.DrawLine3D(S1, S2, 155, 155, 0);
00136		Canvas.DrawText("AttachParent: " @AttachParent);
00137		Canvas.CurY -= 8;
00138	}
00139	
00140	//=============================================================================
00141	//
00142	// Throw
00143	//
00144	// Special CalculateDamage function for thrown swords (to do special stab code)
00145	//=============================================================================
00146	
00147	state Throw
00148	{
00149		function int CalculateDamage(actor Victim)
00150		{
00151			local int dam;
00152			local Pawn P;
00153			local vector X,Y,Z, HitVec, HitVec2D;
00154			local float dotp;
00155			
00156			dam = Super.CalculateDamage(Victim);
00157			
00158			if(Victim.IsA('Pawn'))
00159			{
00160				P = Pawn(Victim);
00161				if(P.CanStabActor() && dam >= P.Health)
00162				{
00163					GetAxes(P.Rotation,X,Y,Z);
00164					X.Z = 0;
00165					HitVec = Normal(Location - Victim.Location);
00166					HitVec2D = HitVec;
00167					HitVec2D.Z = 0;
00168					dotp = HitVec2D dot X;
00169					if(dotp > 0.7)			//Only allow skewer from front..
00170					{
00171						StabActor(P);
00172						SetOwner(None);	//Disallow any other damage to others..
00173					}
00174				}
00175			}
00176			
00177			return(dam);
00178		}
00179	}
00180	
00181	defaultproperties
00182	{
00183	     bCanBePoweredUp=True
00184	     DamageType=Sever
00185	     ThrownDamageType=thrownweaponsever
00186	     ThrownSoundLOOP=Sound'WeaponsSnd.Throws.throw02L'
00187	     PowerUpSound=Sound'OtherSnd.Pickups.pickup01'
00188	     PoweredUpEndingSound=Sound'WeaponsSnd.PowerUps.powerend21'
00189	     PoweredUpEndSound=Sound'WeaponsSnd.PowerUps.powerend17'
00190	     SwipeClass=Class'RuneI.WeaponSwipeBlue'
00191	     A_Idle=weapon1_idle
00192	     A_Forward=S1_Walk
00193	     A_Backward=weapon1_backup
00194	     A_Forward45Right=S1_Walk45Right
00195	     A_Forward45Left=S1_Walk45Left
00196	     A_Backward45Right=weapon1_backup45Right
00197	     A_Backward45Left=weapon1_backup45Left
00198	     A_StrafeRight=StrafeRight
00199	     A_StrafeLeft=StrafeLeft
00200	     A_Jump=MOV_ALL_jump1_AA0S
00201	     A_ForwardAttack=LegsTest
00202	     A_AttackA=S1_attackA
00203	     A_AttackAReturn=S1_attackAreturn
00204	     A_AttackB=S1_attackB
00205	     A_AttackC=S1_attackC
00206	     A_AttackCReturn=S1_attackCReturn
00207	     A_AttackStandA=S1_attackA
00208	     A_AttackStandAReturn=S1_attackAreturn
00209	     A_AttackStandB=S1_attackB
00210	     A_AttackStandBReturn=S1_attackBreturn
00211	     A_AttackBackupA=S1_BackupAttackA
00212	     A_AttackBackupAReturn=S1_BackupAttackAReturn
00213	     A_AttackStrafeRight=S1_StrafeRightAttack
00214	     A_AttackStrafeLeft=S1_StrafeLeftAttack
00215	     A_JumpAttack=OneHandJumpAttackB
00216	     A_Throw=S3_throw
00217	     A_Defend=H3_DefendTO
00218	     A_DefendIdle=H3_DefendIdle
00219	     A_PainFront=Onehand_painRight
00220	     A_PainBack=Onehand_painRight
00221	     A_PainLeft=Onehand_painLeft
00222	     A_PainRight=Onehand_painRight
00223	     A_PickupGroundLeft=H3_PickupLeft
00224	     A_PickupHighLeft=H3_PickupLeftHigh
00225	     A_Taunt=S3_taunt
00226	     RespawnTime=30.000000
00227	     RespawnSound=Sound'OtherSnd.Respawns.respawn01'
00228	     PickupMessageClass=Class'RuneI.PickupMessage'
00229	}

End Source Code