How to make scriptedpawn attack each other?

Discussions about Coding and Scripting
User avatar
Deepu
Adept
Posts: 388
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India

How to make scriptedpawn attack each other?

Post by Deepu »

Is there anyway to make scriptedpawn attack each other like seenplayer function?

They only attack when set bIsPlayer=true, Is that possible to make without bIsPlayer option?
User avatar
papercoffee
Godlike
Posts: 10510
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: How to make scriptedpawn attack each other?

Post by papercoffee »

You mean in MonsterHunt?
User avatar
SilverSound
Adept
Posts: 344
Joined: Fri Nov 06, 2015 10:12 am
Personal rank: Curious
Location: St. Cloud, Florida

Re: How to make scriptedpawn attack each other?

Post by SilverSound »

Monsters won't attack each other unless you set their attitudeToCreature function to hate. They are hard coded to attack each other if they bump. Some monsters will always attack others based on their attitudeToCreature function.
Otherwise they are default set to ignore each other.
"Woah what?! I wish I was recording that...."
User avatar
Deepu
Adept
Posts: 388
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India

Re: How to make scriptedpawn attack each other?

Post by Deepu »

Correct, Sektor helped me to fix this. Thanks @sektor2111   
Auto merged new post submitted 1 minute later
papercoffee wrote: Thu Apr 04, 2024 1:57 am You mean in MonsterHunt?
In Monster Match, I'm still using the bIsPlayer option for this, Sektor helped me to fix this issue.
User avatar
EvilGrins
Godlike
Posts: 10212
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA

Re: How to make scriptedpawn attack each other?

Post by EvilGrins »

SilverSound wrote: Thu Apr 04, 2024 2:01 amMonsters won't attack each other unless you set their attitudeToCreature function to hate
That hasn't been my experience.

Monsters on their default settings attack each other all the time when they cross paths, except for monsters of the same class. Gasbags won't fight each other but they will fight a Giant Gasbag.

Same with Skaarj...

...though usually it has to be different classes of them.
User avatar
OjitroC
Godlike
Posts: 3746
Joined: Sat Sep 12, 2015 8:46 pm

Re: How to make scriptedpawn attack each other?

Post by OjitroC »

EvilGrins wrote: Thu Apr 04, 2024 6:36 pm Monsters on their default settings attack each other all the time when they cross paths, except for monsters of the same class. Gasbags won't fight each other but they will fight a Giant Gasbag.

Same with Skaarj...
...though usually it has to be different classes of them.
As SilverSound noted "They are hard coded to attack each other if they bump." That's what that video demonstrates - one Skaarj landed on top of another, which means they 'bumped'. Berserkers will attack anything anyway. Monsters of the same class will attack each other sometimes - I recently watched brutes exchanging 'punches', similarly with Skaarj Trooper types.

Interestingly subclasses of sektor's SHuman and Barbie's SBHumaneFixesV0 seldom attack each other, even when they do bump - presumably down to their code removing 'bump' though I haven't checked that.
User avatar
sektor2111
Godlike
Posts: 6438
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: How to make scriptedpawn attack each other?

Post by sektor2111 »

For your brain relaxing stuff, you can take in account that ScriptedPawn can recognize some Team position. Even if we have two Mercenaries, they can fight each-other if are on a different team. It's all about a timed control of pawns. Each pawn can claim a Team and then all turns into a bloody battle. The main problem of TEAM and ScriptedPawns are dumb projectiles coming from factory, SkaarjProjectiles are not hurting Skaarj, Rocks won't hurt any titans, Sliths are not corroded by other Sliths and so on. Here is needed a bit of work for different settings, mainly new types of monsters with new projectiles dedicated for certain game-type are better than trying to tweak that poorly written stock ScriptedPawn which in some points is out of any basic logic. You don't know how many things I had to change when I wrote "NsMonster"... SetEnemy code, Attitude problems, Projectiles, some firing stages, a bunch of sanity checks, etc. etc.
After solving damage issue of projectiles, another thing has came up. Some monsters could be hurt be their own projectiles due to their firing offset touching them right during combat states, I had to adjust firing methods using codes from other monsters which do not move during firing stage... I don't remember too many lines of ScriptedPawn code that did not need fixes.

Tweaking Monster for playing MonsterHunt was X times easier than educating them for a real Team-Work because yes, even for MonsterHunt certain things need changes not just plain habits.
User avatar
Barbie
Godlike
Posts: 2923
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: How to make scriptedpawn attack each other?

Post by Barbie »

OjitroC wrote: Thu Apr 04, 2024 7:45 pm Interestingly [...] Barbie's SBHumaneFixesV0 seldom attack each other, even when they do bump - presumably down to their code removing 'bump' though I haven't checked that.
Gunner and Recon are childs of Humangrant and this is child of SkaarjTrooper which is child of Skaarj. And Skaarj are friendly to all others of the Skaarj family, except Berserker, as you already stated.

Code: Select all

class Skaarj extends ScriptedPawn abstract;
...
function eAttitude AttitudeToCreature(Pawn Other)
{
	if ( Other.IsA('Skaarj') )
	{
		if ( Other.IsA('SkaarjBerserker') )
			return ATTITUDE_Ignore;
		else
			return ATTITUDE_Friendly;
	}
	else if ( Other.IsA('Pupae') )
		return ATTITUDE_Friendly;
	else if ( Other.IsA('Nali') )
		return ATTITUDE_Hate;
	else if ( Other.IsA('WarLord') || Other.IsA('Queen') )
		return ATTITUDE_Friendly;
	else
		return ATTITUDE_Ignore;
}
"If Origin not in center it be not in center." --Buggie
User avatar
sektor2111
Godlike
Posts: 6438
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: How to make scriptedpawn attack each other?

Post by sektor2111 »

You forgot "AttituteTo" where main things are rooted...

Code: Select all

function eAttitude AttitudeTo(Pawn Other)
{
...
	else if ( (TeamTag != '') && (ScriptedPawn(Other) != None) && (TeamTag == ScriptedPawn(Other).TeamTag) )
		return ATTITUDE_Friendly;
	else	
		return AttitudeToCreature(Other);
"AtitudeToCreature" it's not the first point of combat, for a memory refresh ask EG how Skaarj can also attack themselves - I think it was fixed in 469 because that bug was a total dumbness.
Target here is MMGame, there are used other sort of monsters and then, it's more easy to setup Attitude correctly and... because "SeePlayer" works only against player types, other external actor can develop this getting over Engine limitations because this type of game clearly needs some extra-control not just Pawns working in raw format guided only by Engine - that's not an answer. In a recent MH map which I touched I added an extra tweak for making monsters more active against players (ALL Players not only human Players) and such code I sent to Deepu for adjusting it a bit. There can be operated attacking tasks against the other team (monsters) working smoothly and making monsters to do what is expected. When Engine doesn't help it's not like we cannot do anything, to not forget that even for navigation subject certain things can be improved in a better way than Engine can do and... it works. Do we have a 800 UU limit for join into network ? So what ? We can point Pawn to the nearest node that has Paths, letting Engine to do sucks as it usually do. Monsters here can be educated in a similar format, forget Engine and write codes properly. For the record Not only Engine is capable to execute "SeePlayer", we can call that as well from our script using traces in certain range, exactly like fake touches and all sort of dummies that might help. After "SeePlayer" if memory is not cheating me next one is "SetEnemy" - here also we can have our deal and so on and so forth.