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 → cog to alert enemies if you have selected a weapon
cog to alert enemies if you have selected a weapon
2002-10-30, 5:08 AM #1
I am trying to make a cog that sets certain actors to neutral or friendly alignment at startup, then checks whether the player has selected any weapon other than fists, and if so, alerts the actors to revert to enemies. I thought that I had found a similar cog by David McHale in his Sigma 51A level and tried modifying it, but no luck. I have no idea what the AI Mode 0x2000 flag does (I was assuming it changed AI Alignment).

So, what should I change?/Should I try a totally different way?

Code:
#  MotS COG
# Using the code of alerted.COG by David McHale in 'Escape from Sigma 51A'
# 
# This COG should let the player wander past selected enemies unmolested, unless
# the player has selected one of several forbidden weapons.  It will also change the actors to enemies when a certain thing is touched, e.g. a door to a forbidden area.
#
# This COG is not supported by Lucasarts
#

symbols

message         startup
message 	entered
message         damaged

sector	        EnterSector

thing           enemy1
thing           enemy2
thing           enemy3
thing           enemy4
thing           enemy5
thing           enemy6
thing           enemy7
thing           enemy8

thing           lockeddoor	linkid=1

int          attacked=0
int		hl1
int		hl2
int		hl3
int		hl4
int		hl5
int		hl6
int		hl7
int		hl8

int		start=0

end

code

startup:

h11 = GetThingHealth(enemy1);  // Don't know meaning of this
h12 = GetThingHealth(enemy2);
h13 = GetThingHealth(enemy3);
h14 = GetThingHealth(enemy4);
h15 = GetThingHealth(enemy5);
h16 = GetThingHealth(enemy6);
h17 = GetThingHealth(enemy7);
h18 = GetThingHealth(enemy8);

	AISetMode(enemy1, 0x2000);
	AISetMode(enemy2, 0x2000);
	AISetMode(enemy3, 0x2000);
	AISetMode(enemy4, 0x2000);
	AISetMode(enemy5, 0x2000);
	AISetMode(enemy6, 0x2000);
	AISetMode(enemy7, 0x2000);
	AISetMode(enemy8, 0x2000);

player = GetLocalPlayerThing();

return;

//  This code is supposed to check if the player has activated a weapon other than fists when they enter a sector
entered:

	if (GetCurWeapon(player) !=1)

		{

AIClearMode(enemy1, 0x2000);
AIClearMode(enemy2, 0x2000);
AIClearMode(enemy3, 0x2000);
AIClearMode(enemy4, 0x2000);
AIClearMode(enemy5, 0x2000);
AIClearMode(enemy6, 0x2000);
AIClearMode(enemy7, 0x2000);
AIClearMode(enemy8, 0x2000);

		}

 if (GetSenderId() == 1)
      
		{

AIClearMode(enemy1, 0x2000);
AIClearMode(enemy2, 0x2000);
AIClearMode(enemy3, 0x2000);
AIClearMode(enemy4, 0x2000);
AIClearMode(enemy5, 0x2000);
AIClearMode(enemy6, 0x2000);
AIClearMode(enemy7, 0x2000);
AIClearMode(enemy8, 0x2000);

		}

Return;

end
2002-10-30, 6:43 AM #2
My god man! Use arrays!!


From the Datamaster...
Quote:
<font face="Verdana, Arial" size="2">
Creature has a saber and is able to block attacks.
</font>


In other words, that flag has absolutely NOTHING to do with alignment. Sorry.


The easiest way to do this, would be to swap out their AIs. One for the friendlyness, and one for the meanness. . . . Because Im in a really good mood, Ill do it for you.

Code:
# 10/2002 GBK
Symbols
Message Startup
Message Entered
Thing Player			Local
Sector Entersector
Thing Enemy0
Thing Enemy1
Thing Enemy2
Thing Enemy3
Thing Enemy4
Thing Enemy5
Thing Enemy6
Thing Enemy7
Thing Lockeddoor
AI Friendly
AI Mean
Int I=0			Local
End
Code
Startup:
Sleep(0.5);
For(I=0;I<8;I=I+1) AIsetclass(Enemy0, Friendly);
Player = JKgetlocalplayer();
Stop;
Entered:
If(Getcurweapon(Player) != 1) 
For(I=0;I<8;I=I+1) AIsetclass(Enemy0, Mean);
If(Getsenderref() == Lockeddoor) 
For(I=0;I<8;I=I+1) AIsetclass(Enemy0, Mean);
Stop;
End



Credit me... [http://forums.massassi.net/html/smile.gif]


------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

GBK oNline. Cogs, tuts, and total w00tage.
And when the moment is right, I'm gonna fly a kite.
2002-10-31, 12:04 AM #3
Thanks GBK!

The stormies still seem to have an anger management problem. Any advice? I have assigned an AI with an alignment of 1.0 as the 'Friendly' AI but no luck yet; I also tried setting all their Instincts to nothing to try to stop them fighting, but ...
2002-10-31, 7:13 AM #4
Give it a peddie's AI, that should fix it.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

GBK oNline. Cogs, tuts, and total w00tage.
And when the moment is right, I'm gonna fly a kite.
2002-11-01, 12:26 AM #5
w00t, I was meaning to make a cog like this eventually, but voila.

I shall soon release something of a similar nature.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-11-01, 12:42 AM #6
I've been meaning to make this for a while, but I've finally gotten around to it, thanks to inspiration derived from this topic.

Code:
# CivFlee.cog
#  This cog gives civilians an aversion to armed gunmen roaming amongst them.
# [Grismath]
#======================================================================================#
symbols
message		startup
message		pulse
message		timer
thing		player		local
thing		civ0
thing		civ1
thing		civ2
thing		civ3
thing		civ4
thing		civ5
thing		civ6
thing		civ7
ai		regular
ai		flee
flex		fTime		// Length of fleeing period
int		X=0		local
int		Y=0		local
end
#======================================================================================#
code
#--------------------------------------------------------
startup:
Sleep(0.5);
for(X=0;X<8;X=X+1) AISetClass(civ0[X], regular);
player=GetLocalPlayerThing();
SetPulse(1);
return;
#--------------------------------------------------------
pulse:
for(X=0;X<8;X=X+1) {
 if(HasLOS(civ0[X], player)) {
  if(GetCurWeapon(player) != 1) {
   AISetClass(civ0[X], flee);
   SetTimerEx(fTime, 1337, X, 0);
}}}
return;
#--------------------------------------------------------
timer:
 if(GetSenderID()==1337) {
  Y=GetParam(1);
  AISetClass(civ0[Y], regular);
 }
return;
#--------------------------------------------------------
end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-11-01, 6:58 AM #7
Well, I don't know what I've done wrong, but I guess the new cogs aren't working for me in my level(this happened before with a cog Sabermaster wrote, and there seemed to be no explicable cause, as regobbing and copying the level five times seemed to clear the problem up). Thanks for all your help, anyway! I'll keep regobbing/renaming the cog files until something clicks! And I'll look forward to your next level, Grismath!

... P.S. But if anyone has any idea why I can't get certain COGs to function in a level, any thoughts would be welcome!

[This message has been edited by rob_whatman (edited November 02, 2002).]

↑ Up to the top!