ZenCoder's fix for PlayerBots

Show us and share your created maps.
Post Reply
User avatar
evilgrins
Posts: 746
Joined: Fri Oct 13, 2017 12:14 am
Location: Palo Alto, CA
Contact:

ZenCoder's fix for PlayerBots

Post by evilgrins »

I'm not a coder, doing scripts is not my strong suit... but I copy & paste with the best of them!
Image
I was toying with this for awhile, before I actually tried it... and admittedly screwed up a map I'd been editing for a very long time.

The annoying thing about summoning playerbots, or editing them directly onto a map, is they can't be team assigned and they all show up on the scoreboard as "Player". This is especially annoying if you are working with more than one of them. But due to a recent map edit I've been working on, 1 of 4, I discovered there's been a work-around for this that I somehow never noticed before...

...which was especially annoying as I've been asking if this were possible for years and everybody told me it couldn't be done!

Part of the mapping edits I've been working on is this map:
https://unrealarchive.org/maps/unreal-t ... a6ea8.html
That map is especially interesting as it has a playerbot embedded into the map, but it's on the Red Team and it actually has a name. So I studied how that was setup to see if I could do it, while I did a review of more of ZenCoder's work to see if he'd done similar anywhere else.

As I've since learned, this method only works with one player model type at a time, you can setup multiple bots on the map this way but they each have to be a different model... which may explain why ZenCoder only had one on one team. But the basic code is pretty simple:
//=============================================================================
// Ronald.
//=============================================================================
class Ronald expands MaleOneBot;

function PostBeginPlay(){
PlayerReplicationInfo.PlayerName = "Ronald the Clone";
PlayerReplicationInfo.Team = 0;
}

With slight alterations, I've used that on 5 different player models for a few maps already... but as stated, I can only do that with one player model per team (if I've got a Boss model on 1 team I can't have one on the other team). Try to do 2 with that on any map, the map won't work and you'll have to start over from scratch.

I did find another map ZenCoder had done this on:
https://unrealarchive.org/maps/unreal-t ... ea07d.html
This time around it was the Abbey model and it was for more than one of the same model type.

That looks like this...
//=============================================================================
// Amazon.
//=============================================================================
class Amazon expands AbbeyBot;
var() int myTeam;

function PostBeginPlay(){

PlayerReplicationInfo.Team = myTeam;
if ( myTeam == 0 ) {
PlayerReplicationInfo.PlayerName = "Sheena";
multiskins[0] = texture'MyLevel.Amaz1T_0';
} else {
PlayerReplicationInfo.PlayerName = "Xena";
multiskins[0] = texture'MyLevel.Amaz1T_1';
}
}

The screenshot at the top of this post was my attempt to do it, and it worked. I'm doing a re-edit of the CTF-ColaWars map.

Now, I only know how to use it to the extent of making slight variables in what's there, but I'm no coder. I can't make them do auto-taunts, I can't alter their skill level (which is probably a good thing) but I can use them fairly basically for fillers.

Just wanted to share, and to those who told me this was impossible... I will have blood vengeance!

But, moving right along, there are still complications.

For the 1st version you have to skin the model after you place it on the map, but with the 2nd version you can skin it in the code so long as the skin is 1 texture for the entire model. However, if the model is a multi-texture deal then you're better off skinning it as with the 1st version...

...though those better at coding might be able to find work-around for that too.
Image
Have you hugged a Skaarj today?
Skaarj need love too!
http://unreal-games.livejournal.com/
User avatar
Kelly
Posts: 185
Joined: Fri Sep 29, 2017 1:54 pm
Location: Coos Bay Oregon

Re: ZenCoder's fix for PlayerBots

Post by Kelly »

Leaving a bookmark here for when Nels sees this and loses his shit.
I don’t wanna give the end away
but we’re gonna die one day
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Re: ZenCoder's fix for PlayerBots

Post by Nelsona »

Blah blah, no fix for state dying and no shadow. I feel something like n00b years 2001

Code: Select all

//=============================================================================
// Ronald.
//=============================================================================
class Ronald expands MaleOneBot;

function PreBeginPlay()
{
	Super.PrebeginPlay();
	Level.Game.AddDefaultInventory(Self); //Doesn't work right now, next time I'll write these different
}

simulated function PostBeginPlay()
{
	if ( ROLE == ROLE_Authority )
	{
		PlayerReplicationInfo.PlayerName = "Ronald the Clone";
		PlayerReplicationInfo.Team = 0;
	}
	if ( Level.NetMode != NM_DedicatedServer )
		Shadow = Spawn(class'PlayerShadow',self);
}

state Dying
{
ignores SeePlayer, EnemyNotVisible, HearNoise, Died, Bump, Trigger, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, Falling, WarnTarget, LongFall, SetFall, PainTimer;

	function ReStartPlayer()
	{
		if( bHidden && Level.Game.RestartPlayer(self) )
		{
			Velocity = vect(0,0,0);
			Acceleration = vect(0,0,0);
			ViewRotation = Rotation;
			ReSetSkill();
			SetPhysics(PHYS_Falling);
			GotoState('Roaming');
		}
		else
			GotoState('Dying', 'TryAgain');
	}
	
	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 
							Vector momentum, name damageType)
	{
		if ( !bHidden )
			Super.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
	}
	
	function BeginState()
	{
		SetTimer(0, false);
		Enemy = None;
		AmbushSpot = None;
		bFire = 0;
		bAltFire = 0;
	}

	function EndState()
	{
		if ( Health <= 0 )
			log(self$" health still <0");
	}

Begin:
	Sleep(0.2);
	if ( !bHidden )
	{
		SpawnCarcass();
		HidePlayer();
	}
TryAgain:
	Sleep(RandRange(1.00,3.5));
//	Sleep(0.25 + DeathMatchGame(Level.Game).NumBots * FRand()); //Virus destroyed ! Just like that.
	ReStartPlayer();
	Goto('TryAgain');
WaitingForStart:
	bHidden = true;
}
Actually that Ronald map has already these, but, as usual, we are posting only poorly written codes :tease: . To not forget that Bot can actually jump higher in initial stage being initialized by BotPack and not by nothing. Pawn needs a bit of love and then it will jump on a heavy pathed box or else it loops jumping, like here...
HardCore_Path.PNG
HardCore_Path.PNG (1.4 MiB) Viewed 4716 times
Boo !
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Re: ZenCoder's fix for PlayerBots

Post by Nelsona »

Next rant ? Of course, why not ?
Do the mapper really need to recompile a class for a stupid name of a clown unable to jump properly ?
Definitely not. All these can be a package dedicated for going in MyLevel and... having a configurable "UsedName" and "TeamNumber" variables in seconds.
The code should/could manage JumpZ for being aligned at original Bot-Type jumpy capability depending on game settings. May I ask where are these fixes ? Answer: Nowhere, exactly, no fix. It was only a lousy obsession about a Name and the rest... let's load f...g Accessed Nones trashing a good CTF session.
I had to pick between two things: Giving up at jumpy route because Clown was physically retarded, or teaching Clown to jump.
I picked the second option, ALL Pawns should jump, especially in Hard-Core setup - I went for adjusting value directly.

And now the maths lesson for dummies.
Engine says: GameInfo is waiting for a quick examination.

Code: Select all

function AddDefaultInventory( pawn PlayerPawn )
{
	local Weapon newWeapon;
	local class<Weapon> WeapClass;

	PlayerPawn.JumpZ = PlayerPawn.Default.JumpZ * PlayerJumpZScaling();
}
Resulting stupid Clown code:

Code: Select all

JumpZ = Default.JumpZ * Level.Game.PlayerJumpZScaling(); //357.5
And if we don't like FLOATING junks:

Code: Select all

JumpZ = int(Default.JumpZ * Level.Game.PlayerJumpZScaling()); //357
Here it's in account Level.Game which might need a check in a simulated function because a client doesn't have such things and it loads another crapped result of an invalid code execution.
Resulting

Code: Select all

	if ( Level.Game != None ) //Needed if it gets called in simulated fock-tions
		JumpZ = int(Default.JumpZ * Level.Game.PlayerJumpZScaling()); //357
Good ? Maybe not and it can be a bless fixing Roaming :: PickDestination as well... Without a weapon this dumb prick does only errors.

To summarize: As long as I'm trying harder to write my codes without errors as much as possible, I don't see why would I use other incomplete codes instead of my codes or messing up with bad settings. Bot placed over a weapon will fall and it picks weapon immediately before having any issue. Later if it respawns it will be loaded by GameInfo/DeathMatchPlus. Reminder: It's year 2021 not 2001. This is a reason for which I cannot be fooled that easy about a fix announced with whistles and bells like I was in 2007-2008...
As for naming sake of naming a Bot embedded inside a map, I already sent privately to a guy a map with a TBossBot which went called "Da Boss" using a little actor attached in map without other bot class. What a new Pawn can do internally, a closer actor can do to a stock pawn without any issue. Bot (not Bots) will follow game directives as well, not only roaming here and there without purpose.
Let's see what is about concerning original Bot stuff at this point...

Code: Select all

class MyInsBot expands Actor;

var() int ATeam;

Auto State() SettingMyBot
{
Begin:
	Sleep(0.2);
	CaptureAndSetMyBot();
	Sleep(0.5);
	GoToState('');
}

function CaptureAndSetMyBot()
{
	local Bot ABot;

	foreach RadiusActors(class'Bot',ABot,150)
	{
		if ( ABot.PlayerReplicationInfo != None )
		{
			ABot.PlayerReplicationInfo.PlayerName = string(ABot.Tag);
			if ( Level.Game.bTeamGame )
				ABot.PlayerReplicationInfo.Team = ATeam;
			Level.Game.AddDefaultInventory(aBot);
			break;
		}
	}
}
All it needs is adding this actor nearby Bot, defining team and Bot will have name identical with TAG used.

Now... let me know if you can make such a Clown (Bots-type not BotPack.Bot) to get Enemy Flag and bringing it at home in plain fields (no JumpSpots usage and other Bot specific tools). Eh ?
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
User avatar
evilgrins
Posts: 746
Joined: Fri Oct 13, 2017 12:14 am
Location: Palo Alto, CA
Contact:

Re: ZenCoder's fix for PlayerBots

Post by evilgrins »

Nelsona wrote: Tue Apr 27, 2021 5:32 amwe are posting only poorly written codes :tease:
Image Image
Perhaps someday I will learn to do better, but as for now... still not a coder.
Kelly wrote: Tue Apr 27, 2021 3:42 amLeaving a bookmark here for when Nels sees this and loses his shit.
Loses his shit in a happy way or in a reach thru the screen and try and kill me way?

Good to know in advance, so I can decide if I need to lean back.
Image
Have you hugged a Skaarj today?
Skaarj need love too!
http://unreal-games.livejournal.com/
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Re: ZenCoder's fix for PlayerBots

Post by Nelsona »

evilgrins wrote: Tue Apr 27, 2021 3:15 pm Perhaps someday I will learn to do better, but as for now... still not a coder.
Neither me, I'm a technician not a coder, and then... I was digging for a better solution at these embedded bots. DeathMatchPlus sends them in State Dying-WaitingForStart this way preventing lousy pawns from dodging out of normal settings assigned for Pawn (Inventory and Physics) - concerning Bot not old Bots. So what do we have here more exactly ? We have Pawn and external entity "DeathMatchPlus" managing this Pawn, not pawn itself and then I was doing things in the same way as UT does, not as "coders" do.
For older "Bots" code probably is the same but... Using string 'Bots' not 'Bot', state code having the similar labeling.
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
User avatar
Kelly
Posts: 185
Joined: Fri Sep 29, 2017 1:54 pm
Location: Coos Bay Oregon

Re: ZenCoder's fix for PlayerBots

Post by Kelly »

Nels can come across as confrontational but I don't think he's at all like that. It's more a cultural difference I think. Few people take more time to explain things than he does and he for sure knows what he is talking about. He just doesn't like broken things in maps and he's probably going to add a filter to kill these in his map fixer :lol: after he gets done telling you why they are not a good idea. (He's right, they aren't.) If you are REALLY nice to him he might even fix them for you so they won't break stuff. He's damn good at that.

And yeah, you might lean back a little. It wouldn't hurt.
I don’t wanna give the end away
but we’re gonna die one day
User avatar
evilgrins
Posts: 746
Joined: Fri Oct 13, 2017 12:14 am
Location: Palo Alto, CA
Contact:

Re: ZenCoder's fix for PlayerBots

Post by evilgrins »

Kelly wrote: Fri Apr 30, 2021 2:55 pmIf you are REALLY nice to him he might even fix them for you so they won't break stuff.
He already did, in the ut99.org forum.
Kelly wrote: Fri Apr 30, 2021 2:55 pmAnd yeah, you might lean back a little. It wouldn't hurt.
Eek!
Image
Have you hugged a Skaarj today?
Skaarj need love too!
http://unreal-games.livejournal.com/
Post Reply