Compartilhe

terça-feira, 18 de janeiro de 2011

Unreal Script – Bots podem te ferir

Ever played a game of Unreal Tournament? Notice how the bots manage to shoot and kill you? Pretty essential behaviour for a game really – being able to kill, and be killed by, your enemies. For a while developing my game I had enemies who could be killed, but couldn’t use the weapons that I had provided them. As it turns out, this was an issue with my Weapon class, only pawns that were controlled by my PlayerController:

simulated function StartFire(byte FireModeNum)
{
local PlayerController plr;
plr = PlayerController(Instigator.Controller);

if(plr == none || bIsReloading) //You can't shoot while reloading
return;

if(DuraCount > 0)
{
super.StartFire(FireModeNum);
}
}


After a helpful post on the UDK forums by Blade[UG], I was pointed in the right direction, which was as simple as creating a new weapon specifically for bots, extending UTWeapon, rather than my ZombiesWeapon class. This weapon doesn’t have any extra functions happening in it, only the setting up of the models. In order to assign the correct weapons to our pawns, we need to do the following in our GameInfo class:

function AddDefaultInventory( pawn PlayerPawn )
{
local int i;

//Is the pawn a "Human" or a "Zombie"
if (PlayerPawn.IsA('ZO_PAWN_Base') )
{
//Humans get a gun and a knife (and fists)
DefaultInventory[0]=class'ZO_WEAP_Pistol';
DefaultInventory[1]=class'ZO_WEAP_Knife';
DefaultInventory[2]=class'ZO_WEAP_Fists';
}
else
{
//Zombies don't get a "weapon" per-se, they do get fists though... woo
DefaultInventory[0]=class'ZO_WEAP_ZFists';
}

for (i=0; i {
// Ensure we don't give duplicate items
if (PlayerPawn.FindInventoryType( DefaultInventory[i] ) == None)
{
// Only activate the first weapon
PlayerPawn.CreateInventory(DefaultInventory[i], (i > 0));
}
}

PlayerPawn.AddDefaultInventory();
}

Once this is done, I simply re-compiled the game and gave it a bit of a test. The only issue that I’m having at the moment is that the Zombie likes to try and attack you from far away, while only using their fists. Also, I’m able to headshot them from sniper distance while using a pistol, which hardly seems fair…

0 comentários:

Postar um comentário

Seu comentário é importante para a manutenção do BLOG.

Não será publicado comentários que infringirem as seguintes regras:

01- ofensas gratuitas aos membros da UDKBrasil
02- descrédito para com a postagem
03- links com malwares ou qualquer tipo de fraude
04- palavras de baixo calão contra participantes
05- links de download não serão permitidos, a não ser que sejam gratuitos (freeware ou software de teste) e relacionados a UDK ou Computação Grafica.

Pedimos a gentileza de não USAR CAPS LOCK ligado.

OBS; assim que seu comentário for publicado,se junto dele NÃO houver uma resposta para sua dúvida,é porque não sabemos te responder...infelizmente, não sabemos de tudo!!

Seja bem vindo.

Fórum UDKBrasil

Top View Semanal

Top View Mensal

Top View de todos os Tempos

 
UDK BRASIL | by TNB ©2010