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 → 'Tis but a flesh wound!
'Tis but a flesh wound!
2003-07-26, 5:26 AM #1
I've been trying to get a COG to work so that, should the player injure a civilian, police units around the area would react and attack and the player. The coding is rudimentary, yes, but here it is:

Code:
# Jedi Knight Cog Script
#
# filename.cog
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

message	startup
message	damaged
thing		civ1			linkid=1
thing		civ2			linkid=1
thing		civ3			linkid=1
thing		civ4			linkid=1
thing		civ5			linkid=1
thing		civ6			linkid=1
thing		civ7			linkid=1
thing		civ8			linkid=1
thing		civ9			linkid=1
thing		civ10			linkid=1
thing		civ11			linkid=1
thing		civ12			linkid=1
thing		civ13			linkid=1
thing		civ14			linkid=1
thing		civ15			linkid=1
thing		civ16			linkid=1
thing		civ17			linkid=1
thing		civ18			linkid=1
thing		civ19			linkid=1
thing		civ20			linkid=1
thing		civ21			linkid=1
thing		civ22			linkid=1
thing		civ23			linkid=1
thing		civ24			linkid=1
thing		civ25			linkid=1
thing		civ26			linkid=1
thing		civ27			linkid=1
thing		civ28			linkid=1
thing		civ29			linkid=1
thing		civ30			linkid=1
thing		pol1			linkid=1
thing		pol2			linkid=1
thing		pol3			linkid=1
thing		pol4			linkid=1
thing		pol5			linkid=1
thing		pol6			linkid=1
thing		pol7			linkid=1
thing		pol8			linkid=1
thing		pol9			linkid=1
thing		pol10			linkid=1
thing		pol11			linkid=1
thing		pol12			linkid=1
thing		pol13			linkid=1
thing		pol14			linkid=1
thing		pol15			linkid=1
int		dam=0			local

end

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

code

startup:
  AiSetMode(pol1, 0x2000);
  AiSetMode(pol2, 0x2000);
  AiSetMode(pol3, 0x2000);
  AiSetMode(pol4, 0x2000);
  AiSetMode(pol5, 0x2000);
  AiSetMode(pol6, 0x2000);
  AiSetMode(pol7, 0x2000);
  AiSetMode(pol8, 0x2000);
  AiSetMode(pol9, 0x2000);
  AiSetMode(pol10, 0x2000);
  AiSetMode(pol11, 0x2000);
  AiSetMode(pol12, 0x2000);
  AiSetMode(pol13, 0x2000);
  AiSetMode(pol14, 0x2000);
  AiSetMode(pol15, 0x2000);
return;

damaged:
  if ((GetSenderId()==1) && (dam==0)) {
    dam=1;
    AiClearMode(pol1, 0x2000);
    AiClearMode(pol2, 0x2000);
    AiClearMode(pol3, 0x2000);
    AiClearMode(pol4, 0x2000);
    AiClearMode(pol5, 0x2000);
    AiClearMode(pol6, 0x2000);
    AiClearMode(pol7, 0x2000);
    AiClearMode(pol8, 0x2000);
    AiClearMode(pol9, 0x2000);
    AiClearMode(pol10, 0x2000);
    AiClearMode(pol11, 0x2000);
    AiClearMode(pol12, 0x2000);
    AiClearMode(pol13, 0x2000);
    AiClearMode(pol14, 0x2000);
    AiClearMode(pol15, 0x2000);
    SetActorFlags(pol1, 0x200);
    SetActorFlags(pol2, 0x200);
    SetActorFlags(pol3, 0x200);
    SetActorFlags(pol4, 0x200);
    SetActorFlags(pol5, 0x200);
    SetActorFlags(pol6, 0x200);
    SetActorFlags(pol7, 0x200);
    SetActorFlags(pol8, 0x200);
    SetActorFlags(pol9, 0x200);
    SetActorFlags(pol10, 0x200);
    SetActorFlags(pol11, 0x200);
    SetActorFlags(pol12, 0x200);
    SetActorFlags(pol13, 0x200);
    SetActorFlags(pol14, 0x200);
    SetActorFlags(pol15, 0x200);
}
return;

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

end


Now, the police (pol1, pol2, etc.) are set to neutral toward the player at the beginning of the game. However, should I damage it or the civilians, the police actor just shrugs it off as nothing unusual. It's almost as though the game refuses to recognize the damaged: section of my COG.

------------------
"Six hundred and forty fish later, the only thing I know is everything you love will die. The first time you meet that someone special, you can count of them one day being dead and in the ground."
Jack Chick preaches it
NMGOH
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken
2003-07-26, 7:15 AM #2
try useing

AISetFireTarget(actor, jkGetLocalPlayer());

also, if that dosent work tell me if its MP or SP and ill rewrite the cog for you [http://forums.massassi.net/html/biggrin.gif]

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-07-26, 5:19 PM #3
I think Wolfy wants to use his own code.

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-07-26, 6:24 PM #4
Isn't Wolfy a she? That was my impression, anyway...

------------------
You'll just have to accept that some days you're the pigeon, and others the statue.

"Though I frequently half-jest that there should be a Jesus film starring Sean Connery: 'Yesh, I am in fakt the shon of Godd. Hyou shell oll be shaved.'"

- Dormouse
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2003-07-26, 6:31 PM #5
i think i have a cog somwhere that is for police units and they will only attack you if they see you hurting a civilian, if that would suit you better i can see if i can find it and you can modify it to your needs

------------------
roses are red, violets are blue, I am schizophrenic, and I am too!
roses are red, violets are blue, I am schizophrenic, and I am too!
2003-07-26, 6:43 PM #6
I think this is the perfect place to use an array.

------------------

[This message has been edited by Jon`C (edited April 1, 2003).]
2003-07-26, 7:48 PM #7
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Daft_Vader:
Isn't Wolfy a she? That was my impression, anyway...</font>


I'm quite male.

Jon - array?

------------------
"Six hundred and forty fish later, the only thing I know is everything you love will die. The first time you meet that someone special, you can count of them one day being dead and in the ground."
Jack Chick preaches it
NMGOH
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken
2003-07-26, 8:49 PM #8
name0 - name15 = name[16].
An array is a way of easily referencing a large amount of information. This would let you access all of the NPCs in one loop instead of a large list of statements (also makes adding new police / NPCs much easier).
The JK COG specs should have information about arrays.

------------------

[This message has been edited by Jon`C (edited April 1, 2003).]
2003-07-27, 1:24 AM #9
Jon, in cog you need to define each element in the array in the symbols section.

Also I am not sure what language you defined that array in but in my experience 0-15 is defined as name[15] as 0 is an included in that definition.

------------------
Team Battle.
Team Battle.
2003-07-27, 2:09 AM #10
Ok, it works. I dont really know much about ai... so yeah.

Code:
# Jedi Knight Cog Script
#
# filename.cog
#
# If a civilian or police guy is shot then the police
# will attack you.
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

message	startup
message	damaged

thing		civ0			mask=0x408
thing		civ1			mask=0x408
thing		civ2			mask=0x408
thing		civ3			mask=0x408	
thing		civ4			mask=0x408
thing		civ5			mask=0x408
thing		civ6			mask=0x408	
thing		civ7			mask=0x408	
thing		civ8			mask=0x408	
thing		civ9			mask=0x408	
thing		civ10			mask=0x408	
thing		civ11			mask=0x408	
thing		civ12			mask=0x408	
thing		civ13			mask=0x408	
thing		civ14			mask=0x408	
thing		civ15			mask=0x408	
thing		civ16			mask=0x408	
thing		civ17			mask=0x408	
thing		civ18			mask=0x408	
thing		civ19			mask=0x408	
thing		civ20			mask=0x408	
thing		civ21			mask=0x408	
thing		civ22			mask=0x408			
thing		civ23			mask=0x408
thing		civ24			mask=0x408
thing		civ25			mask=0x408
thing		civ26			mask=0x408
thing		civ27			mask=0x408
thing		civ28			mask=0x408
thing		civ29			mask=0x408

thing		pol0			mask=0x408
thing		pol1			mask=0x408
thing		pol2			mask=0x408
thing		pol3			mask=0x408
thing		pol4			mask=0x408
thing		pol5			mask=0x408
thing		pol6			mask=0x408
thing		pol7			mask=0x408
thing		pol8			mask=0x408
thing		pol9			mask=0x408
thing		pol10			mask=0x408
thing		pol11			mask=0x408
thing		pol12			mask=0x408
thing		pol13			mask=0x408
thing		pol14			mask=0x408

end

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

code

startup:

  //Sleep as to make sure the thing is created
  sleep(1);

  for(i=0; i < 15; i=i+1)
  {
      //Make sure the thing exists
      if(pol0 == -1) return;

      //set flags
      AiSetMode(pol0, 0x2000);
  }

return;

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

damaged:

  for(i=0; i < 15; i=i+1)
  {
      //Make sure the thing exists
      if(pol0 == -1) return;

      //set flags
      AiClearMode(pol0, 0x2000);
      SetActorFlags(pol0, 0x200);
  }

return;

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

end


If something isnt right post and someone will fix it for you.

------------------
Team Battle.

[This message has been edited by Hellcat (edited July 27, 2003).]
Team Battle.
2003-07-27, 6:07 PM #11
I always use different variables for different for loops. Perhaps that's just a habit of mine.

------------------
no reason to get excited..
2003-07-27, 7:00 PM #12
On a "for" it doesnt matter because you define it as i=num anyways. On a multidemensional array then it would probably be required.

------------------
Team Battle.
Team Battle.
2003-07-28, 9:08 AM #13
Quote:
<font face="Verdana, Arial" size="2">Jon, in cog you need to define each element in the array in the symbols section.

Also I am not sure what language you defined that array in but in my experience 0-15 is defined as name[15] as 0 is an included in that definition.</font>


I'm sure Jon knew that. 0-15 is 16 elements which is what he was pointing out, and there are arrays that start with 0 or 1.

Quote:
<font face="Verdana, Arial" size="2">The JK COG specs should have information about arrays.</font>


But the DM has a tutorial. [http://forums.massassi.net/html/wink.gif]

Hellcat, that code might work fine, but you might also clear 0x1000 and set 0x4.

And no reason to be so matter-of-fact, I'm sure Heeb knows how to write. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-28, 3:29 PM #14
Sorry, I wasnt intending on being matter-of-fact. I was just trying to be helpful [http://forums.massassi.net/html/frown.gif]

Guess I needed to put some smilies or something in [http://forums.massassi.net/html/smile.gif]

------------------
Team Battle.
Team Battle.

↑ Up to the top!