Subclassing Monsters..........

Questions, Informations and Discussions
Post Reply
Master_Unreal

Subclassing Monsters..........

Post by Master_Unreal »

If you are subclassing or making a monster, you may have an error where your monster does not see you. In the event that this happens, add this code to your monster

EDIT: The following code has been edited, this includes pointers for the Orders variable

Code: Select all

function WhatToDoNext(name LikelyState, name LikelyLabel)
{
	local Pawn aPawn;

	aPawn = Level.PawnList;
	while ( aPawn != None )
	{
		if ( (aPawn.IsA('PlayerPawn') || aPawn.IsA('ScriptedPawn'))
			&& (VSize(Location - aPawn.Location) < 500)
			&& CanSee(aPawn) )
		{
			if ( SetEnemy(aPawn) )
			{
				GotoState('Attacking');
				return;
			}
		}
		aPawn = aPawn.nextPawn;
	}
	while ( aPawn == None )
	{
		if (Orders == 'Patroling') 
			GotoState('Patroling');
		else if (Orders == 'Guarding')
			GotoState('Guarding');
		else if ( Orders == 'Ambushing' )
			GotoState('Ambushing','FindAmbushSpot');
		else if ( (LikelyState != '') && (FRand() < 0.35) )
			GotoState(LikelyState, LikelyLabel);
		else
			StartRoaming();
	}

	Super.WhatToDoNext(LikelyState, LikelyLabel);
}	
if you look at the line "if ( (aPawn.IsA('PlayerPawn') )" That basically says that if it sees that object, in this case, PlayerPawn, it sets that object as the enemy and goes to state Attacking, you can insert any pawn name here and it will react when it sees that pawn. If you do not add this code your monster will do nothing upon seeing the player and/or enemy

Master_Unreal
Last edited by Master_Unreal on Wed Nov 10, 2010 12:14 am, edited 1 time in total.
Master_Unreal

Re: Subclassing Monsters..........

Post by Master_Unreal »

Another issue, if your monster has a new projectile that it shoots, or maybe it just won't shoot at all, you will have to dig into the parent class code some to find the function that spawns the projectiles, in the case of Slith, function ShootTarget, and replace it with this

Code: Select all

function ShootTarget()
{
	local rotator FireRotation;
	local vector X,Y,Z, projStart;

	GetAxes(Rotation,X,Y,Z);
	MakeNoise(1.0);
	projStart = Location + 0.9 * CollisionRadius * X + 0.4 * CollisionRadius * Y + 0.8 * CollisionHeight * Z;
	FireRotation = AdjustAim(ProjectileSpeed, projStart, 400, bLeadTarget, bWarnTarget);  
	spawn(RangedProjectile,self,'',projStart, FireRotation);
}
projStart = Location + 0.9 * CollisionRadius * X + 0.4 * CollisionRadius * Y + 0.8 * CollisionHeight * Z;

This line here, you will have to play around with those values ALOT in order to finally get what you want, do not remove any of the CollisionRadius or the CollisionHeight, it will not compile, you will simply have to get what you want through trial and error
Post Reply