Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Ai Friendly (mass) cog need.
Ai Friendly (mass) cog need.
2003-02-22, 6:59 AM #1
I working for friendly ai cog, based on cog downloaded from massassi temple, but those cog have simple bug: Actors with that cog attack other friendly actors... So i wrote something like this:


Code:
symbols

message	startup
message	touched
message	killed
message	pulse

thing		friendly0		mask=0x408
thing		friendly1		mask=0x408
thing		friendly2		mask=0x408
thing		friendly3		mask=0x408
thing		friendly4		mask=0x408
thing		friendly5		mask=0x408
thing		friendly6		mask=0x408
thing		friendly7		mask=0x408
thing		friendly8		mask=0x408
thing		friendly9		mask=0x408
thing		friendly10		mask=0x408
thing		friendly11		mask=0x408

thing		player		local
thing		enemy			local

ai		passive_ai=pednarsh.ai
ai		angry_ai

int            i              local

end

# ========================================================================================

code

startup:
	player = GetLocalPlayerThing();

For(i=0; i<11; i=i+1)
{
	AISetClass(friendly, passive_ai);
}
	return;

touched:
	if(GetSourceRef() != player) return;

	SetPulse(1.0);
	return;

killed:

	SetPulse(0.0);
	return;

pulse:

For(i=0; i<11; i=i+1)
{
	enemy = FirstThingInView(friendly0, 170, 12, 0x4);

	if((enemy == friendly0) || (enemy == friendly1) || (enemy == friendly2) || (enemy == friendly3) ||  (enemy == friendly4) || (enemy == friendly5) || (enemy == friendly6) ||  (enemy == friendly7) || (enemy == friendly8) || (enemy == friendly9) || (enemy == friendly10) || (enemy == friendly11) || (enemy == player) || (!enemy))
	{
		AISetClass(friendly, passive_ai);
		return;
	}

	AISetClass(friendly, angry_ai);		
	AISetFireTarget(friendly, enemy);
	AISetMoveThing(friendly, GetThingPos(enemy));
	AISetLookPos(friendly, GetThingPos(enemy));
	AISetMode(friendly, 0x202);
	AIClearMode(friendly, 0x1000);
}
	return;

end	


but its bugged, when level starts game break to windows..

Also i will need battle cog - ie enemies attack friendly actors and vice versa. It will not work on this cog and that downloaded from massassi - enemies dont attack frendly, so this cog is unusefoul.. help need

------------------
2003-02-22, 7:36 AM #2
Your arrays were screwed. Try this one:

Code:
symbols

message startup
message touched
message killed
message pulse

thing friendly0 mask=0x408
thing friendly1 mask=0x408
thing friendly2 mask=0x408
thing friendly3 mask=0x408
thing friendly4 mask=0x408
thing friendly5 mask=0x408
thing friendly6 mask=0x408
thing friendly7 mask=0x408
thing friendly8 mask=0x408
thing friendly9 mask=0x408
thing friendly10 mask=0x408
thing friendly11 mask=0x408

thing player local
thing enemy local

ai passive_ai=pednarsh.ai
ai angry_ai

int i local

end

# ========================================================================================

code

startup:
player = GetLocalPlayerThing();

For(i=0; i<=11; i=i+1) ISetClass(friendly0, passive_ai);

return;

touched:
if(GetSourceRef() != player) return;

SetPulse(1.0);
return;

killed:

SetPulse(0.0);
return;

pulse:

For(i=0; i<=11; i=i+1)
{
enemy = FirstThingInView(friendly0, 170, 12, 0x4);

if((enemy == friendly0) || (enemy == friendly1) || (enemy == friendly2) || (enemy == friendly3) || (enemy == friendly4) || (enemy == friendly5) || (enemy == friendly6) || (enemy == friendly7) || (enemy == friendly8) || (enemy == friendly9) || (enemy == friendly10) || (enemy == friendly11) || (enemy == player) || (!enemy))
{
AISetClass(friendly0, passive_ai);
return;
}

AISetClass(friendly0, angry_ai);
AISetFireTarget(friendly0, enemy);
AISetMoveThing(friendly0, enemy);
AISetLookPos(friendly0, GetThingPos(enemy));
AISetMode(friendly0, 0x202);
AIClearMode(friendly0, 0x1000);
}
return;

end 



------------------
Createthingatpos(GBK, 0, '0 0 0', '0 0 0');
And when the moment is right, I'm gonna fly a kite.
2003-02-22, 9:16 AM #3
GBK, for the love of boB, tab! [http://forums.massassi.net/html/tongue.gif]

------------------
-Hell Raiser
Remember kiddies, trial and error.
Without struggles there is no progress
DBZ: The Destruction is Real
-Hell Raiser
2003-02-22, 10:45 AM #4
hmm.. bugged.. somewhere (not Ai at startup i correct this and it bugged also)

------------------
2003-02-23, 3:09 PM #5
Okay, my class cogs work just as well, um I mean better.
Code:
# Jedi Knight COG Script
#
# ACTOR_FRIEND2.COG
#
# A cog for a friendly actor.
# Kinda like Max, just better.
# Class Cog - Guard/Stationary version.
#
# [DP]
#

symbols

thing		friend				local
thing		player		nolink	local
thing		target				local
int		count=0				local

message	created
message	killed
message	pulse

end

# ========================================================================================

code

Created:
	player = GetLocalPlayerThing();
	SetThingPulse(GetSenderRef(), 1);
	AIClearMode(GetSenderRef(), 0x1206);
	Return;

# ........................................................................................

Killed:
	If(GetThingClassCog(GetSenderRef()) != GetSelfCog()) Return;
	SetThingPulse(GetSenderRef(), 0);
	AIClearMode(GetSenderRef(), 0x1206);
	AISetMode(GetSenderRef(), 0x1);
	Return;

# ........................................................................................

Pulse:
      count = 0;
	friend = GetSenderRef();
	// Search for baddie to attack us
	target = FirstThingInView(friend, 360, 12, 0x4);
	If((GetThingClassCog(target) == GetSelfCog())||(target == player)) target = -1;
	While(count < GetThingCount())
	{
		If(AIGetMode(target) == 0x202) Return;		// So it keeps on the same target
		If(target != -1)
		{
			CaptureThing(target);
			AISetFireTarget(target, friend);
			AISetMoveThing(target, friend);
			AISetLookPos(target, GetThingPos(friend));
			AISetMode(target, 0x202);
			AIClearMode(target, 0x1000);
		}
		target = NextThingInView();
		count = count + 1;		// Incase there isn't anything in view
	}
	// Search for friendly to attack something
      count = 0;
	If(AIGetMode(friend) == 0x202) Return;		// So it keeps on the same target
	target = FirstThingInView(friend, 170, 12, 0x4);
	If((GetThingClassCog(target) == GetSelfCog())||(target == player)) target = -1;
	While((target == -1)&&(count < GetThingCount()))
	{
		target = NextThingInView();
		If(count == GetThingCount()) target = -1;
		If((GetThingClassCog(target) == GetSelfCog())||(target == player)) target = -1;
		count = count + 1;		// Incase there isn't anything in view
	}
	If(target != -1)		// If there's a target
	{
		CaptureThing(target);
		AISetFireTarget(friend, target);
		AISetMoveThing(friend, target);
		AISetLookPos(friend, GetThingPos(target));
		AISetMode(friend, 0x202);
		AIClearMode(friend, 0x1000);
	}
	Else AIClearMode(friend, 0x1206);
	Return;

end
The baddie attack part is untested, but it should work. Credit me in the readme (when it works if it doesn't right now [http://forums.massassi.net/html/wink.gif] ).

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!