The problem with determining the position of the bot

Discussions about Coding and Scripting
User avatar
Gadavre
Experienced
Posts: 140
Joined: Sun Jan 18, 2015 7:55 am

The problem with determining the position of the bot

Post by Gadavre » Fri Dec 22, 2017 7:36 pm

I can't for a long time to solve this problem, please help!

the task such: to write the condition in function Timer() under which the bot will not perform a specific function. The bot has in its inventory only 2 weapons (SniperRifle and ImpactHammer) The bot should not perform the function, if he holds the ImpactHammer in his hands.

Code: Select all

if (...)
continue

It didn't help

Code: Select all

function Timer()
{
local Bot B;
ForEach AllActors(class'Bot', B)
{
        if ( SniperRifle(B.weapon) == None)
                        continue; 
}
}
How to write the condition?

User avatar
sektor2111
Godlike
Posts: 5336
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: The problem with determining the position of the bot

Post by sektor2111 » Fri Dec 22, 2017 8:56 pm

Inside Iterator continue means: skip this and move to the next
Translated it sounds like: If Bot weapon is not a SniperRifle check next Bot - nothing in common with ImpactHammer.

User avatar
Barbie
Godlike
Posts: 2107
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: The problem with determining the position of the bot

Post by Barbie » Sat Dec 23, 2017 1:03 am

Maybe you should explain more detailed what you want to achieve...
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

JackGriffin
Godlike
Posts: 3765
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: The problem with determining the position of the bot

Post by JackGriffin » Sat Dec 23, 2017 2:08 am

This is using the sledgehammer approach, you need a scalpel instead. Share what you are trying to do and we will help you get there.
So long, and thanks for all the fish

User avatar
sektor2111
Godlike
Posts: 5336
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: The problem with determining the position of the bot

Post by sektor2111 » Sat Dec 23, 2017 2:11 am

I think I got it.
He has that ShootTarget thing which... I don't know what version will use... However, a Bot should not aim enemies from far away locations with ImpactHammer - he has to Impactjump-ing to target not aiming enemies. Fix me if I'm wrong :mrgreen: .

User avatar
papercoffee
Godlike
Posts: 9869
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: The problem with determining the position of the bot

Post by papercoffee » Sat Dec 23, 2017 2:38 am

Hey ...maybe it's a new long range Impact Hammer? :ironic:

User avatar
Gadavre
Experienced
Posts: 140
Joined: Sun Jan 18, 2015 7:55 am

Re: The problem with determining the position of the bot

Post by Gadavre » Sun Dec 24, 2017 10:16 pm

sektor2111 wrote:I think I got it.
He has that ShootTarget thing which... I don't know what version will use... However, a Bot should not aim enemies from far away locations with ImpactHammer - he has to Impactjump-ing to target not aiming enemies. Fix me if I'm wrong :mrgreen: .
Yes you are right. The bot should not aim with ImpactHammer at the enemy at long range. And he does not. However, a Bot in rare cases presses the primary fire at long range from the player. The BOT should do it next to the player.
I do not understand why he does it...
It is not critical and playable. But it looks weird. I I've got to say that I can not without the help of a professional to go very deep into the code.

User avatar
sektor2111
Godlike
Posts: 5336
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: The problem with determining the position of the bot

Post by sektor2111 » Mon Dec 25, 2017 2:21 am

Can I write something a little changed for a general case ?

Code: Select all

function Timer()
{
	local Bot B;

	ForEach AllActors(class'Bot', B)
	{
		if ( B.Health > 0 && B.Weapon != None
		&& !B.bHidden && B.Enemy == None ) //Only a valid free Bot
		{
			if ( B.Weapon.bMeleeWeapon )
					continue;
			else
			{
				KillAllAliens(B); //must check ammo in here else quit blocking Bot
			}
		}
	}
}