Player/Monster detection range...pulling my hair out!

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Cybog

New Member
May 9, 2006
17
0
0
Ok, I am fairly noobish to the scripting game, so I appreciate any help I can get.

For the game my team is doing we want to add our custom bots and monsters to the level, but there is just one problem - They detect us from WAAAY too far away. I've played with their sight and hearing and it doesn't seem to matter. Ive adjusted their scripted sequence's "SetAlertness" to all sorts of things, and nothing seems to work. My goal is to have them walk around (pretty mindlessly) and attack me when I get close or attack them.

Can anyone please tell me how to fix their detection radius so that they don't see me from half a map away? This is driving me nuts and I can't add any monsters if they are immediately seeing me from such extreme distances.

Thanks in advance!
 

Cybog

New Member
May 9, 2006
17
0
0
Ok, I am using custom monster classes but don't know what to add or what to adjust. I am simply using hybrid / chop-shop scripts to get my basic animations and characters to work.

What part of the script would need to be adjusted in the Monster class then?
 

meowcat

take a chance
Jun 7, 2001
803
3
18
What did you adjust the Monster's SightRadius and HearingThreshold to? (They are set to 12000 and 2800 respectively in unrealpawn.uc and pawn.uc). In my custom pawn class (which is also controled by a heavily modified bot) I turned the sightradius down to about 4,000 and that worked better for my purposes. The hearingthreshold will really get you though, as MakeNoise (which calls Hearnoise in AIControllers and sets the noisemaker to the enemy in most controller scripts) is called quite often (firing weapons, pickups, taking damage, jumping etc.) and should be turned down in order to make your monsters harder of hearing.
 

Cybog

New Member
May 9, 2006
17
0
0
Here is the code I am using for my custom bot:

Code:
Class SalvationMonster extends Monster;

defaultproperties
{
	Alertness=1
	DetectionRadius=1
	HearingThreshold=1
	SightRadius=1
	bForgetful=true
	RequiredEquipment(0)=""
	RequiredEquipment(1)=""
}

var float DetectionRadius;
var bool bForgetful;

function SetMeUp(name SEvent, name STag, int SHealth, name SAITag)
{
	Event = SEvent;
	Tag = STag;

	AIScriptTag = SAITag;

	if (SHealth != 0)
	{
		Health = SHealth;
	}
}

simulated function PlayDirectionalHit(Vector HitLoc)
{
}

function PostBeginPlay()
{
	Super.PostBeginPlay();

	RequiredEquipment[0] = "";
	RequiredEquipment[1] = "";
}

function RunAway()
{
	local PathNode P, Prev;
	local Array<PathNode> Y;

	foreach RadiusActors(class'PathNode', P, 4096)
	{

		if (P != None)
		{
			Y[Y.Length] = P;
	
			P = Y[RandRange(0, Y.Length -1)];
		
			if (P.Location == Location) // Makes sure the monster does actually move.
			{
				return;
			}

			if (P == Prev) // Stops monster from going to previous pathnode.
			{
				return;
			}
		
			else
			{
				Controller.bPreparingMove = true;
				//Acceleration = vect(0,0,0);
				bShotAnim = true;
				Prev = P;
				Controller.Destination = P.Location;
				Controller.GotoState('TacticalMove','WaitForAnim');
			}
	
		}

		else
		{
			MonsterController(Controller).WanderOrCamp(false);
		}

	}
}

Even with this, the bot will sense me almost immediately in the game and start walking towards me. I get no errors when compiling, so I am unsure if there is something wrong with the code. I set all the values to zero and get the same results.

Anyone have any ideas? Someone has to know how to change this :mad:
 

Cybog

New Member
May 9, 2006
17
0
0
Sorry, that is the script for the Monster class.

Here is the script for the actual monster that extends the Monster class:

Code:
Class SalvationMonster_Zombie extends SalvationMonster;

function RangedAttack(Actor A)
{
	if ( VSize(A.Location - Location) < MeleeRange + CollisionRadius + A.CollisionRadius )
	{
		MeleeDamageTarget(5, (15000.0 * Normal(A.Location - Location)));
	}
}

simulated function Tick( float DeltaTime )
{
	if (MonsterController(Controller) != None)
	{

	if ( Level.timeseconds - MonsterController(Controller).ChallengeTime > FMax(3,Rand(6)) )
	{
		MonsterController(Controller).ChallengeTime = Level.timeseconds;
		PlayChallengeSound();
	}

	}
}

simulated function PlayDying(class<DamageType> DamageType, vector HitLoc)
{
	AmbientSound = None;
    bCanTeleport = false; 
    bReplicateMovement = false;
    bTearOff = true;
    bPlayedDeath = true;
		
	HitDamageType = DamageType; // these are replicated to other clients
    TakeHitLocation = HitLoc;
	LifeSpan = RagdollLifeSpan;

    GotoState('Dying');
		
	Velocity += TearOffMomentum;
    BaseEyeHeight = Default.BaseEyeHeight;
    SetPhysics(PHYS_Falling);

	PlayAnim('DeathF',1.2,0.05);	
}

defaultproperties;

{

     bCanDodge=True
     bAlwaysStrafe=True
     ChallengeSound(0)=Sound'SkaarjPack_rc.Skaarj.chalnge1s'
     ChallengeSound(1)=Sound'SkaarjPack_rc.Skaarj.chalnge3s'
     ChallengeSound(2)=Sound'SkaarjPack_rc.Skaarj.roam11s'
     ChallengeSound(3)=Sound'SkaarjPack_rc.Skaarj.roam11s'
     GibCountCalf=2
     GibCountForearm=1
     GibCountHead=1
     GibCountTorso=3
     GibCountUpperArm=2
	bCanJump=false
     RagImpactSounds(0)=Sound'GeneralImpacts.Wet.Breakbone_01'
     RagImpactSounds(1)=Sound'GeneralImpacts.Wet.Breakbone_02'
     RagImpactSounds(2)=Sound'GeneralImpacts.Wet.Breakbone_03'
     RagImpactSounds(3)=Sound'GeneralImpacts.Wet.Breakbone_04'
     bCanFly=False
     MeleeRange=60.000000
     GroundSpeed=170
     Health=140
     bPhysicsAnimUpdate=True
     DrawType=DT_Mesh
     Mesh=VertMesh'CodeBaseMonsters.Male1'
     AmbientSound=Sound'GeneralAmbience.texture38'
     DrawScale=0.95000
     Skins(0)=Texture'SPMonsterTex.monsters.zombie'
     Skins(1)=Texture'SPMonsterTex.monsters.zombie'
	
	//These need to be defined or else it will not animate in net play

	MovementAnims[0]="WalkF"
	MovementAnims[1]="WalkF"
	MovementAnims[2]="WalkF"
	MovementAnims[3]="WalkF"
	WalkAnims[0]="WalkF"
	WalkAnims[1]="WalkF"
	WalkAnims[2]="WalkF"
	WalkAnims[3]="WalkF"
	CrouchAnims[0]="WalkF"
	CrouchAnims[1]="WalkF"
	CrouchAnims[2]="WalkF"
	CrouchAnims[3]="WalkF"
	AirAnims[0]="WalkF"
	AirAnims[1]="WalkF"
	AirAnims[2]="WalkF"
	AirAnims[3]="WalkF"
	SwimAnims[0]="WalkF"
	SwimAnims[1]="WalkF"
	SwimAnims[2]="WalkF"
	SwimAnims[3]="WalkF"
	TurnLeftAnim="WalkF"
	TurnRightAnim="WalkF"
	CrouchTurnLeftAnim="WalkF"
	CrouchTurnRightAnim="WalkF"
	IdleRestAnim="WalkF"
	IdleCrouchAnim="WalkF"
	AirStillAnim="WalkF"
	IdleSwimAnim="WalkF"

    TakeoffAnims[0]="WalkF"
    TakeoffAnims[1]="WalkF"
    TakeoffAnims[2]="WalkF"
    TakeoffAnims[3]="WalkF"
    TakeoffStillAnim="WalkF"

}
 
Last edited:

meowcat

take a chance
Jun 7, 2001
803
3
18
Hmm... looks correct to me, but iirc there are a lot of funny pawn/controller initiation issues. I would say try adding some log statements (or better yet have the bot send ClientMessages to the local player controller (you) if in "debug" mode telling you what it is doing.) You should probably add the following code to your monster class as well so that you can see the AI variables in game using the 'viewactor' console command followed by 'ShowDebug' (these will show you all kinds of useful info about what your 'bot' is thinking):
Code:
function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
{
	//local string DebugString;
	Super.DisplayDebug(Canvas,YL,YPos);

	Canvas.SetDrawColor(80,140,255);
	Canvas.DrawText("YOUR_PAWN Vision->"@PeripheralVision$", SightRadius->"@SightRadius$", Alertness"@Alertness$", HearingThreshold"@HearingThreshold);
	YPos += YL;
	Canvas.SetPos(4,YPos);
}

now when viewing your bot/monster in game you can see if those AI variables have been reset somehow.
 

Cybog

New Member
May 9, 2006
17
0
0
Here is what my screen looks like after adding this code:

log9zz.jpg





Nothing seems to be changing, even after the level starts and I get attacked (Other than the location coordinates). I am unsure if this is showing the proper things...?
 

Cybog

New Member
May 9, 2006
17
0
0
After doing this, their sight radius and hearing radius are exactly the same as specified in the command, and yet at the beginning of the level they detect me and come towards me no matter what.

Can you guide me through whatever command you entered into your script to get it to work? Does it look just like this one?

Does the gametype matter? I am extending Deathmatch for this game. When making a single player style map, is this ok?

The fact that he is an extend of a Monster class rather than a Pawn?

I'm throwing out all sorts of ideas....I have this thread posted on 4 forums and nobody seems to know how to set up a single player map with proper working bots....I have a hard time believing this :mad:
 

meowcat

take a chance
Jun 7, 2001
803
3
18
Ok, it took me a minute or two but I found the code that allows it to see you. The reason I did not have this issue was that I did not subclass MonsterController. Look at the FindNewEnemy function in Monster controller. It searches through all level controllers and picks an enemy that can be seen (would appear not to take pawn.sightradius into account) from where the monster is. This function is called whenever the monster does not have an enemy (form the ExecuteWhatToDoNext function). Change this function to take into account the pawn view radius, or perhaps remove it al together. I would recommend overwriting the ExecuteWhatToDoNext function in your custom controller class and remove the call to that function (or something similar)
 

Cybog

New Member
May 9, 2006
17
0
0
Sorry if I am so noob :( But the scripts that I have are sorta piece-milled together...I am still learning the language for the most part.

Can you help me clarify what exact function I should be writing into my custom controller? I looked through the Monster class and I don't see any "FindNewEnemy" anywhere in the script :(

Again, thank you big time for this help. Everyone I have asked so far can't seem to get it figured out either.
 

Cybog

New Member
May 9, 2006
17
0
0
Ok, I think I know what you are saying. My problem is lying in the fact that I am not using any sort of Monster controller. I'm not even sure how to set this up.

Basically all I have been doing is extending the monster class, and then extending of of that custom type. Gonna have to do some more research into setting up a controller. Not sure how that works :(