Author Topic: Getting a hostile bot to spawn, obviously I'm doing something wrong  (Read 1295 times)

Code: [Select]
%player = new AIPlayer()
{

dataBlock = "ZombieHoleBot";
position = %col.getPosition();

};

I'm trying to get a hostile bot to spawn, and this is probably the closest I've got using the default Bot addon. It's just spawning a regular immobile player object, yet it's "enabled". Is there a better way to do this?

I've been trying to make them spawn at player spawns for a project of mine, and they work but I can't get them to shoot anything.

It's easiest to look at fxDtsBrick::spawnHoleBot and copy that. It's in Bot_Hole/holes.cs.

They're spawning now, but they seem to be deleted immidiately.

Code: [Select]
%player = new AIPlayer()
{
dataBlock = ZombieHoleBot;
path = "";
spawnBrick = %col;
position = %col.getPosition();

//Apply attributes to Bot
Name = ZombieHoleBot.hName;
hType = ZombieHoleBot.hType;
hSearchRadius = ZombieHoleBot.hSearchRadius;
hSearch = ZombieHoleBot.hSearch;
hSight = ZombieHoleBot.hSight;
hWander = ZombieHoleBot.hWander;
hGridWander = ZombieHoleBot.hGridWander;
hReturnToSpawn = ZombieHoleBot.hReturnToSpawn;
hSpawnDist = ZombieHoleBot.hSpawnDist;
hMelee = ZombieHoleBot.hMelee;
hAttackDamage = ZombieHoleBot.hAttackDamage;
hSpazJump = ZombieHoleBot.hSpazJump;
hSearchFOV = ZombieHoleBot.hSearchFOV;
hFOVRadius = ZombieHoleBot.hFOVRadius;
hTooCloseRange = ZombieHoleBot.hTooCloseRange;
hAvoidCloseRange = ZombieHoleBot.hAvoidCloseRange;
hShoot = ZombieHoleBot.hShoot;
hMaxShootRange = ZombieHoleBot.hMaxShootRange;
hStrafe = ZombieHoleBot.hStrafe;
hAlertOtherBots = ZombieHoleBot.hAlertOtherBots;
hIdleAnimation = ZombieHoleBot.hIdleAnimation;
hSpasticLook = ZombieHoleBot.hSpasticLook;
hAvoidObstacles = ZombieHoleBot.hAvoidObstacles;
hIdleLookAtOthers = ZombieHoleBot.hIdleLookAtOthers;
hIdleSpam = ZombieHoleBot.hIdleSpam;
hAFKOmeter = ZombieHoleBot.hAFKOmeter + getRandom( 0, 2 );
hHearing = ZombieHoleBot.hHearing;
hIdle = ZombieHoleBot.hIdle;
hSmoothWander = ZombieHoleBot.hSmoothWander;
hEmote = ZombieHoleBot.hEmote;
hSuperStacker = ZombieHoleBot.hSuperStacker;
hNeutralAttackChance = ZombieHoleBot.hNeutralAttackChance;
hFOVRange = ZombieHoleBot.hFOVRange;
hMoveSlowdown = ZombieHoleBot.hMoveSlowdown;
hMaxMoveSpeed = 1.0;
hActivateDirection = ZombieHoleBot.hActivateDirection;

isHoleBot = 1;
};

echo(%player);

EDIT: I think it's because I'm deleting the block it spawns from right after the bot spawns?

EDIT 2: Yep, line 479 of holes.cs
Code: [Select]
//if we somehow got here and you or your spawnbrick doesn't exist anymore, then poof
if( !isObject(%obj.spawnBrick) ) // isObject(%obj) &&
{
%obj.delete();
return;
}
ugh.
« Last Edit: June 30, 2013, 01:28:45 AM by TheBlackParrot »

Yes they need to have a spawn brick defined. It is checked for every intelligence tick, and if it's not found the bot will be deleted.

Edit: oh I see your edit. Let me know if you fix the problem where they don't attack.
« Last Edit: June 30, 2013, 01:31:35 AM by Greek2me »

Code: [Select]
%spawnBrick = new fxDTSBrick()
{

client = $Mining::Host;
dataBlock = "brick4xCubeData";
position = "0 0 -100";
rotation = "0 0 0 0";
colorID = 0;
scale = "1 1 1";
angleID = 0;
colorfxID = 0;
shapefxID = 0;
isPlanted = 1;
stackBL_ID = $Mining::Host.bl_id;
isBotHole = 1;

};

%spawnBrick.plant();
%spawnBrick.setTrusted(1);

$Mining::Host.brickgroup.add(%spawnBrick);

%player = new AIPlayer()
{
dataBlock = ZombieHoleBot;
path = "";
spawnBrick = %spawnBrick;
position = %col.getPosition();
Even after this, it's still being deleted. %spawnBrick does exist.

It takes a second for bricks to be registered, so you'll have to put a schedule of 0ms on the bot creation.

Code: [Select]
%spawnBrick = new fxDTSBrick()
{

client = $Mining::Host;
dataBlock = "BrickZombie_HoleSpawnData";
position = "0 0 -100";
rotation = "0 0 0 0";
colorID = 0;
scale = "1 1 1";
angleID = 0;
colorfxID = 0;
shapefxID = 0;
isPlanted = 1;
stackBL_ID = $Mining::Host.bl_id;
isBotHole = 1;

};

%spawnBrick.plant();
%spawnBrick.setTrusted(1);

$Mining::Host.brickgroup.add(%spawnBrick);

echo(%spawnBrick);

%colPos = %col.getPosition();
schedule(33,0,miningSpawnBot,%spawnBrick,%colPos);

asusming I'm doing something completely wrong because they're still being deleted :x

I figured out that this
Code: [Select]
if( %spawnBrick.itemPosition != 1 && !hBrickClientCheck( %brickGroup ) )
{
//%pos = %obj.spawnBrick.getPosition();
//%pos = vectoradd(%pos,"0 0 0.15");
//%rot = getwords(%obj.spawnBrick.getTransform(),3,6);
// other options delete the bot until user comes back? ##
//%obj.setTransform(%pos SPC %rot);

//%obj.stopHoleLoop();
%obj.delete();
echo("it's calling this!");
echo(%brickgroup);
//%obj.hSched = %obj.scheduleNoQuota(%tickrate+getrandom(0,750),hLoop);
return;
}
is what's causing them to be deleted. If I make hBrickClientCheck only return 1, they spawn and stay, but I can't appear to hurt them, nor do they appear to notice me.

EDIT: Fixed them not being able to hurt anyone. nvm that.
« Last Edit: June 30, 2013, 11:39:19 AM by TheBlackParrot »

EDIT: Fixed them not being able to hurt anyone. nvm that.
How?

How?
$DefaultMinigame.BotDamage = 1;

or just $Minigame::BotDamage 1 in the gamemode file