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 → Stupid Party Crashers
Stupid Party Crashers
2002-08-22, 2:56 AM #1
Yes, I know that writing most of the cog and then testing it is a really bad habit that I must break myself of, but what's done is done, and I'm stuck with this dilemma. The cog initialises, but after that none of the members do anything.

Code:
# Party.cog
#  Allows for the formation and manipulation of a party. (Up to 3 members)
# [Grismath]
#======================================================================================#
symbols
message		startup
message		pulse
message		touched
message		activated
message		killed
thing		mem0
thing		mem1
thing		mem2
thing		mem3
int		act0		// The status of each party member
int		act1
int		act2
int		act3		
int		ptnum	local	// The size of your party
int		X=0	local
flex		sltime		// The following pulse interval
flex		watime		// The auxiliary waiting time
thing		player	local
int		debug=0

end
#======================================================================================#
code
#--------------------------------------------------------
startup:

Sleep(0.5);
if(debug==1) print("Party Cog Initialised");
for(X=0; X>4; X=X+1) {
 if(act[X]==1) {
  ptnum=ptnum+1;
}}
if(ptnum>=1) SetPulse(sltime);
player=GetLocalPlayerThing;
if(debug==1) print(ptnum);

return;
#--------------------------------------------------------
pulse:

for(X=0; X>ptnum; X=X+1) {
 if(act[X]==1) {
  AISetLookPos(mem[X], GetThingPos(player));
  AISetMovePos(mem[X], GetThingPos(player));
  if(debug==1) print("Follow");
}}

return;
#--------------------------------------------------------
touched:

for(X=0; X>ptnum; X=X+1) {
 if(act[X]==1) {
  if(GetSenderRef()==player && GetSourceRef()==mem[X]) {
   if(debug==1) print("Touched");
   SetPulse(0.0);
   Sleep(watime);
   SetPulse(sltime);
   }
}}

return;
#--------------------------------------------------------
activated:

for(X=0; X>ptnum; X=X+1) {
 if(GetSenderRef()==mem[X]) {
  if(debug==1) print("Activated");
  if(act[X]==0) {
   act[X]=1;
   ptnum=ptnum+1;
   if(ptnum==1) SetPulse(sltime);
   if(debug==1) print("Join Party");
  } else {
   act[X]=0;
   ptnum=ptnum-1;
   if(ptnum==0) SetPulse(0);
   if(debug==1) print("Hold Position");
  }
 }}

return;
#--------------------------------------------------------
killed:

for(X=0; X>ptnum; X=X+1) {
 if(GetSenderRef()==mem[X]) {
  if(act[X]==1) {
   act[X]=0;
   ptnum=ptnum-1;
   if(ptnum==0) SetPulse(0);
   if(debug==1) print("Party Member Killed");
}}}

return;
#--------------------------------------------------------

end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-22, 4:55 AM #2
Two things I can see right now. Can't use // to comment in symbols, have to use # only! Secondly, in all of your for loops, try using less then ( < ) instead of greater then ( > ). [http://forums.massassi.net/html/wink.gif] It helps.

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

The Magician Saber System.

[This message has been edited by Descent_pilot (edited August 22, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-22, 8:41 AM #3
Actully, you can use bolth # and // in the symbols, but only // in the code.

------------------
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.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-22, 9:55 AM #4
tsk, tsk, tsk GBK, you forgot this topic?

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

The Magician Saber System.

[This message has been edited by Descent_pilot (edited August 22, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-22, 11:47 AM #5
From that topic:

Quote:
<font face="Verdana, Arial" size="2">While I was working on Dash's cogs, I discovered an interesting difference between commenting symbols. The '#' is for commenting anywhere in the cog, but the '//' symbol can only be used in the symbols or code section. If it's used anywhere else, JK counts it as a syntax error.</font>


And so Grismath's commenting is fine.

So have you given up on Parsec, Grismath? You have some classic syntax errors there.

1)The variables, act and mem, used in the code should have a '0' after them so that they match the variables defined in the symbols section.

2) print(ptnum); should be PrintInt(ptnum);

3) Your GetLocalPlayerThing() is missing its set of parentheses.

Fix those errors and then test it. [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.
2002-08-22, 12:52 PM #6
Did I mis-remember/mis-read that.

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

The Magician Saber System.

[This message has been edited by SaberMaster (edited August 22, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-22, 1:05 PM #7
Please respect the forum rules, Pilot.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-22, 1:19 PM #8
Sorry, Bear just p***ed me off as I was going through the EC, so much defience! Just makes me mad. [http://forums.massassi.net/html/mad.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
2002-08-22, 3:53 PM #9
Wow, I'm having fun with EditPlus 2. :]

Code:
# Partymaster.cog
#  Allows for the formation and manipulation of a party. (Up to 3 members)
# [Grismath]
#======================================================================================#
symbols
message		startup
message		pulse
message		touched
message		activated
message		killed
thing		mem0
thing		mem1
thing		mem2
thing		mem3
int		act0		// The status of each party member
int		act1
int		act2
int		act3		
int		ptnum	local	// The size of your party
int		X=0	local
flex		sltime		// The following pulse interval
flex		watime		// The auxiliary waiting time
thing		player	local
int		debug=0

end
#======================================================================================#
code
#--------------------------------------------------------
startup:

Sleep(0.5);
if(debug==1) print("Party Cog Initialised");
for(X=0; X<4; X=X+1) {
 if(act0[X]==1) {
  ptnum=ptnum+1;
}}
if(ptnum>=1) SetPulse(sltime);
player=GetLocalPlayerThing;
if(debug==1) printint(ptnum);

return;
#--------------------------------------------------------
pulse:

for(X=0; X<ptnum; X=X+1) {
 if(act0[X]==1) {
  AISetLookPos(mem0[X], GetThingPos(player));
  AISetMovePos(mem0[X], GetThingPos(player));
  if(debug==1) print("Follow");
}}

return;
#--------------------------------------------------------
touched:

for(X=0; X<ptnum; X=X+1) {
 if(act0[X]==1) {
  if(GetSenderRef()==player && GetSourceRef()==mem[X]) {
   if(debug==1) print("Touched");
   SetPulse(0.0);
   Sleep(watime);
   SetPulse(sltime);
   }
}}

return;
#--------------------------------------------------------
activated:

for(X=0; X<ptnum; X=X+1) {
 if(GetSenderRef()==mem0[X]) {
  if(debug==1) print("Activated");
  if(act0[X]==0) {
   act0[X]=1;
   ptnum=ptnum+1;
   if(ptnum==1) SetPulse(sltime);
   if(debug==1) print("Join Party");
  } else {
   act0[X]=0;
   ptnum=ptnum-1;
   if(ptnum==0) SetPulse(0);
   if(debug==1) print("Hold Position");
  }
 }}

return;
#--------------------------------------------------------
killed:

for(X=0; X<ptnum; X=X+1) {
 if(GetSenderRef()==mem[X]) {
  if(act0[X]==1) {
   act0[X]=0;
   ptnum=ptnum-1;
   if(ptnum==0) SetPulse(0);
   if(debug==1) print("Party Member Killed");
}}}

return;
#--------------------------------------------------------

end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-24, 10:25 AM #10
That may work, but I still see a few things wrong with it. Namely, GetLocalPlayerThing and mem[x]. I would write the cog like this:
Code:
# partymaster.cog
#
# Allows for the formation and manipulation of a party. (Up to 4 members)
#
# [Grismath + SM]
#==============================================================#
symbols

message   startup
message   pulse
message   activated

thing     member      local
thing     member0     linkid=0
thing     member1     linkid=1
thing     member2     linkid=2
thing     member3     linkid=3
thing     player      local

flex      stayDist
flex      checkInterval

int       active0
int       active1
int       active2
int       active3
int       id          local
int       debug=0

end
#==============================================================#
code
#------------------------------------------------------
startup:
	Sleep(1);
	player = GetLocalPlayerThing();
	if(debug) Print("Cog Initializing");
	for(id = 0; id < 4; id = id + 1) if(active0[id]) SetThingPulse(member0[id], checkInterval);

Return;
#------------------------------------------------------
pulse:
	member = GetSenderRef();
	if(VectorDist(GetThingPos(member), GetThingPos(player)) > stayDist)
	{
		if(debug) Print("Member following.");
		AISetMovePos(member, GetThingPos(player));
		AISetLookPos(member, GetThingPos(player));
	}
	else
	{
		if(debug) Print("Member staying.");
		AIClearMode(member, 0x1);
		StopThing(member);	// they tend to slide...
	}

Return;
#------------------------------------------------------
activated:
	id = GetSenderID();
	member = member0[id];
	if(!active0[id])
	{
		if(debug) Print("Member joining.");
		active0[id] = 1;
		SetThingPulse(member, checkInterval);
	}
	else
	{
		if(debug) Print("Member leaving.");
		active0[id] = 0;
		SetThingPulse(member, 0);
	}

Return;
#------------------------------------------------------
end


Quote:
<font face="Verdana, Arial" size="2">Wow, I'm having fun with EditPlus 2. :]</font>


Yeah, it's a great program. [http://forums.massassi.net/html/smile.gif] Have you tried my syntax files, BTW?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 24, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-24, 10:49 AM #11
Yep, I'm using them.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-25, 3:09 AM #12
[http://forums.massassi.net/html/biggrin.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.
2002-08-25, 3:31 AM #13
I rigged up syntax files for "Synedit" awhile back, if anyone is interested...

------------------
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.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!