make scriptedpawn attack bots?

Discussions about Coding and Scripting
Post Reply
yurkapotam
Novice
Posts: 3
Joined: Wed Jul 19, 2023 4:21 pm
Personal rank: didn't ask

make scriptedpawn attack bots?

Post by yurkapotam »

I want to make my scriptedpawn attack bots.
How?

Code: Select all

function eAttitude AttitudeToCreature(Pawn Other)
{
	return ATTITUDE_Hate;
}
This should make that the scriptedpawn attacks every pawn (im a noob so i guess it will), even ones of its kind, but doesn't attack bots...
SMILES BATTLE!!!
:minigun1: :minigun2:
User avatar
papercoffee
Godlike
Posts: 10451
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: make scriptedpawn attack bots?

Post by papercoffee »

Which pawn?
Buggie
Godlike
Posts: 2749
Joined: Sat Mar 21, 2020 5:32 am

Re: make scriptedpawn attack bots?

Post by Buggie »

You need look at AttitudeToPlayer, damageAttitudeTo, AttitudeTo.
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: make scriptedpawn attack bots?

Post by sektor2111 »

SetEnemy has an important word in this stage. Original UT has ZERO deal with ScriptedPawn Vs Bot - this is why MonsterHunt uses an "attached code".
This is another reason to have a good stock and/or XC_Engine capable to replace functions.
papercoffee wrote: Mon Jul 24, 2023 2:26 am Which pawn?
ALL stock ScriptedPawns from all 436 versions are the same as described X times in forum - IGNORING Bots.
yurkapotam
Novice
Posts: 3
Joined: Wed Jul 19, 2023 4:21 pm
Personal rank: didn't ask

Re: make scriptedpawn attack bots?

Post by yurkapotam »

Fixed it! the SetEnemy function only accepts ScriptedPawn and PlayerPawn, added bots to the "list"
SMILES BATTLE!!!
:minigun1: :minigun2:
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: make scriptedpawn attack bots?

Post by sektor2111 »

"List" is not very needed, maybe some checks for Pawns with "PlayerReplicationInfo" - once single main check. I think there are changes in 469, somewhere in XC_Engine I see this:

Code: Select all

// REVIEW ASAP, CHANGES IN V469
function bool SetEnemy( Pawn NewEnemy )
{
	local bool result;
	local eAttitude newAttitude, oldAttitude;
	local bool noOldEnemy;
	local float newStrength;

	if ( (NewEnemy == Self) || (NewEnemy == None) || (NewEnemy.Health <= 0) || Level.bStartup )
		return false;
	if ( !bCanWalk && !bCanFly && !NewEnemy.FootRegion.Zone.bWaterZone )
		return false;
	if ( (NewEnemy.PlayerReplicationInfo == None) && (ScriptedPawn(NewEnemy) == None) )
		return false;
	if ( NewEnemy.PlayerReplicationInfo != None && NewEnemy.PlayerReplicationInfo.bIsSpectator )
		return false;
...
...
There are negative conditions that are rejecting an invalid enemy, the rest keeps going as normal - no discrimination. A "List" it's not even needed.
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: make scriptedpawn attack bots?

Post by sektor2111 »

A little bump...
Usually I do not have issues at this point (Monster vs Bot)... but there are issues concerning the attack from a range that goes out of "LineOfSightTo" whatever, a native function embedded in Engine at C++ Level (which I cannot handle)... When some maps (which I play a lot) need more "a monster-like" behavior, I'm using various scripts which are developing "sensors" out of lousy engine "rules". This happy keypoint (it's on top position that's why is happy :lol2: ) is working in a latent process in this stage...
VisFightTrg.PNG
Following some scripting rules but not what engine is demanding, it will engage ScriptedPawns in attack concerning Players - those that are mainly "hunters" in MonsterHunt. Even a "Queen" looks more interested in firing at enemy rather than looping in Teleporting State when player is far from it - taking in account some "SightRadius" - which engine seems to forget.
Spoiler

Code: Select all

class SeeThem expands Keypoint;

var Pawn P;

event PostBeginPlay()
{
	InitialState = 'CheckingThem';
}

function CheckSee(Pawn P)
{
	local Pawn Pw, AnEnemy;
	local vector EyeSpot;
	local float Zh;
	local int bestDist, Dist;
	local bool bSeenCloser;

	if ( P.bDeleteMe || P == None )
	{
		log ("Exec Drop :: CheckSee :: P :: Invalid !",name);
		return;
	}
	EyeSpot = P.Location;
	EyeSpot.Z += P.CollisionHeight * 0.6;
	bestDist = P.SightRadius;
	foreach AllActors(class'Pawn', Pw)
	{
		if ( Pw == P )
			continue;
		else
		{
			if ( Pw.PlayerReplicationInfo != None && Pw.PlayerReplicationInfo.Team == 0 && !Pw.bHidden )
			{
				if ( FastTrace (EyeSpot,Pw.Location) )
				{
					Dist = VSize(EyeSpot - Pw.Location);
					if ( Dist < bestDist )
					{
						bestDist = Dist;
						bSeenCloser = True;
						AnEnemy = Pw;
					}
				}
			}
		}
	}
	if (bSeenCloser)
	{
//		P.SeePlayer(AnEnemy);
//		if ( Tentacle(P) != None )
//			log( P.Name@"has seen"@AnEnemy.GetHumanName()$".",name );
		P.Enemy = AnEnemy;
		P.Target = AnEnemy;
		P.LastSeenPos = AnEnemy.Location;
		if ( ScriptedPawn(P).bHasRangedAttack)
			P.GoToState('RangedAttack');
		else
			P.GotoState('Attacking');
	}
}

function SetupPositions()
{
	local ScriptedPawn S;

	foreach AllActors(class'ScriptedPawn',S)
		S.SetLocation(S.Location);
}

state CheckingThem
{
Begin:
	Sleep(2.2);
	SetupPositions(); //Reinforcing after PreBeginPlay collision deal.
ALoop:
	if ( Level != None )
	{
		P = Level.PawnList;
		if ( Level.Game != None )
			if  ( Level.Game.bGameEnded )
				GoTo('End');
	}
	while ( P != None )
	{
		if ( ScriptedPawn(P) != None && ( P.Enemy == None || !P.LineOfSightTo(P.Enemy) ) && P.Health > 1 && !P.bHidden )
		{
			if ( P.SightRadius < 10000 )
				P.SightRadius = 10000;
			CheckSee(P);
		}
		Sleep(0.003);
		if ( P == None || P.bDeleteMe ) // Check if P is not gone during sleep above
			break;
		else
			P = P.NextPawn;
	}
FinishLoop:
	Sleep(0.1);
	GoTo ('ALoop');
End:
	P = None;
	Stop;
}
It turns out that a map full of junks is now clean and operational, perfectly usable in places where some "MH2" rules won't mess things up.
User avatar
papercoffee
Godlike
Posts: 10451
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: make scriptedpawn attack bots?

Post by papercoffee »

sektor2111 wrote: Mon Jul 24, 2023 2:33 pmALL stock ScriptedPawns from all 436 versions are the same as described X times in forum - IGNORING Bots.
Then we need an attacking cow.
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: make scriptedpawn attack bots?

Post by sektor2111 »

Let the cows (actually a sort of dinosaurs...) alone because I have other "news". Some "Pawns" aka "CrazyPupae" class from a random map brought me a surprise ON-LINE... They were attacking me in rare cases, mainly crawling... not very attacking even human being (maybe I wasn't human in that moment... :loool: ) - and not taking damage. Suddenly game has crashed and I restarted it, joining the server again. Pupaes were not there anymore --- ooops. I went to do a research... Interesting "dumb stuff" not "crazystuff" as it was called. Projectile was "bNetTemporary" working separately in both server and client and creating monsters in both stages. While in server Bots killed "mini-monsters", in my client they were still living, not really attacking and not really damaging but fully filling the field and not dying from weapons, only after stepping on them. I was wondering if such a "client-monster" will attempt to attack finding a path to player if map it's screwed up with "VisibleTeleporter", what will happen with client... To me it's clear... Also I'm not going to ask about "PawnList" from server vs "PawnList" from client... For sure these sort of dumb things must be fixed in 469 because 469 should solve all sort of "human related issues :omfg: " not only game related bugs...
That was about pupaes not really attacking - and if they attacked, no damage was taken - client has no deal with A.I. and game control after all...

Not a big problem in end... but because all was imported in "MyLevel", I could solve these "network" related problems without to modify any external package... I earned a map but... it was not that fast to figure out what was happening.

I did an edit of a map with client specific creatures but... they were not delegated to be in touch with any player (SkyBox stuff) - here was only a miserable stage full of debris... good luck at making "maps", boys...

In this stage story is way longer and not really totally linked with monsters vs bots and then I won't hijack the thread with things which I had to solve...
Post Reply