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 → Stormtrooper squad...
Stormtrooper squad...
2002-02-28, 8:12 AM #1
Okay, i made a stormtrooper squad cog for jk. It's supposed to make four stormtroopers attack your target, just not you. Now there's a lil problem: Sometimes when the stormies have killed the enemy and see no one else, they attack you. This is pretty weird... Oh, and if anyone can be bothered, (i couldn't) make it so that the stormies attack their own target, just not each others or the player.
Code:
# Jedi Knight Cog Script
#
# strike_main.COG
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

int		player		local
thing		storm1
thing		storm2
thing		storm3
thing		storm4

thing		victim		local

message startup
message pulse
message killed

end

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

code
startup:
player = GetLocalPlayerThing();

AIClearMode(storm1, 0x1206);
AIClearMode(storm2, 0x1206);
AIClearMode(storm3, 0x1206);
AIClearMode(storm4, 0x1206);

		AISetMoveThing(storm1, player);
		AISetLookPos(storm1, GetThingPos(player));
		AISetMode(storm1, 0x1);

		AISetMoveThing(storm2, player);
		AISetLookPos(storm2, GetThingPos(player));
		AISetMode(storm2, 0x1);

		AISetMoveThing(storm3, player);
		AISetLookPos(storm3, GetThingPos(player));
		AISetMode(storm3, 0x1);

		AISetMoveThing(storm4, player);
		AISetLookPos(storm4, GetThingPos(player));
		AISetMode(storm4, 0x1);

victim = FirstThingInView(player, 170, 12, 0x004);

if( victim == storm1)
{
victim = -1;
}
else
if( victim == storm2)
{
victim = -1;
}
else
if( victim == storm3)
{
victim = -1;
}
else
if( victim == storm4)
{
victim = -1;
}
else
if( victim == player)
{
victim = -1;
}

SetPulse(1);

Return;

pulse:

	victim = FirstThingInView(player, 170, 12, 0x004);

if( victim == player)
{
victim = -1;
}

		if(victim == storm1 || victim == storm2 || victim == storm3 || victim == storm4 || victim == player) 
		{
		call follow;
		}


		AISetMoveThing(storm1, player);
		AISetLookPos(storm1, GetThingPos(player));
		AISetMode(storm1, 0x1);

		AISetMoveThing(storm2, player);
		AISetLookPos(storm2, GetThingPos(player));
		AISetMode(storm2, 0x1);

		AISetMoveThing(storm3, player);
		AISetLookPos(storm3, GetThingPos(player));
		AISetMode(storm3, 0x1);

		AISetMoveThing(storm4, player);
		AISetLookPos(storm4, GetThingPos(player));
		AISetMode(storm4, 0x1);

if( victim != -1 && victim != storm1 && victim != storm2 && victim != storm3 && victim != storm4 && victim != player)
{
call strike;
}

if(IsThingMoving(player) == 0)
{
AiSetMovePos(storm1, GetThingPos(storm1));
AiSetMovePos(storm2, GetThingPos(storm2));
AiSetMovePos(storm3, GetThingPos(storm3));
AiSetMovePos(storm4, GetThingPos(storm4));
}

Return;

killed:
if(GetSenderRef() == victim)
{
SetPulse(0.005);
}
Return;

strike:
SetPulse(0);
if( GetThingTemplate(victim) == GetThingTemplate(player) || GetThingTemplate(victim) == GetThingTemplate(storm1) )
{
victim = -1;
SetPulse(0.005);
}
else
if( GetThingTemplate(victim) != GetThingTemplate(player) && GetThingTemplate(victim) != GetThingTemplate(storm1) )
{
	CaptureThing(victim);
	AISetFireTarget(storm1, victim);
	AISetMoveThing(storm1, victim);
	AISetLookPos(storm1, GetThingPos(victim));
	AISetMode(storm1, 0x202);
	AIClearMode(storm1, 0x1000);

	CaptureThing(victim);
	AISetFireTarget(storm2, victim);
	AISetMoveThing(storm2, victim);
	AISetLookPos(storm2, GetThingPos(victim));
	AISetMode(storm2, 0x202);
	AIClearMode(storm2, 0x1000);

	CaptureThing(victim);
	AISetFireTarget(storm3, victim);
	AISetMoveThing(storm3, victim);
	AISetLookPos(storm3, GetThingPos(victim));
	AISetMode(storm3, 0x202);
	AIClearMode(storm3, 0x1000);

	CaptureThing(victim);
	AISetFireTarget(storm4, victim);
	AISetMoveThing(storm4, victim);
	AISetLookPos(storm4, GetThingPos(victim));
	AISetMode(storm4, 0x202);
	AIClearMode(storm4, 0x1000);
}
Return;

follow:

AIClearMode(storm1, 0x1206);
AIClearMode(storm2, 0x1206);
AIClearMode(storm3, 0x1206);
AIClearMode(storm4, 0x1206);

		AISetMoveThing(storm1, player);
		AISetLookPos(storm1, GetThingPos(player));
		AISetMode(storm1, 0x1);

		AISetMoveThing(storm2, player);
		AISetLookPos(storm2, GetThingPos(player));
		AISetMode(storm2, 0x1);

		AISetMoveThing(storm3, player);
		AISetLookPos(storm3, GetThingPos(player));
		AISetMode(storm3, 0x1);

		AISetMoveThing(storm4, player);
		AISetLookPos(storm4, GetThingPos(player));
		AISetMode(storm4, 0x1);
Return;

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

end





------------------
Life is like... skating... yeah, skating is a good example. You see someone skating and think "Hey, that looks like fun and easy!". You go and buy a skateboard and try, you get a few broken bones, asphalt-face and stuff... But hey, i'm not the one who gets hurt!
Last edited by mb; today at 10:55 AM.
2002-02-28, 9:08 AM #2
Can you just change their alignment in the *.ai file to 0?

------------------
Dead Reckoning and Dead Reckoning 2
Dead Reckoning
2002-02-28, 3:11 PM #3
ahhh you cog like me you crazy person.... ok first please use arrays makes things much simpler
second you must change the alin to 0 in the ai
third use arrays and that is about it, if you need i can correct your cog and fix array things and make your code much smaller and simpler
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-28, 3:24 PM #4
But Han, havent you heard? Using arrays in cog is a violation of the Jon`C clean-code directive, circa 2002.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-03-01, 6:00 AM #5
Was that a joke? or is it true?
Producer->Prey->Predator
2002-03-01, 6:54 AM #6
Arrays are like heprew to me... I don't understand a word... [http://forums.massassi.net/html/smile.gif]

------------------
Life is like... skating... yeah, skating is a good example. You see someone skating and think "Hey, that looks like fun and easy!". You go and buy a skateboard and try, you get a few broken bones, asphalt-face and stuff... But hey, i'm not the one who gets hurt!
Last edited by mb; today at 10:55 AM.

↑ Up to the top!