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 → "Flag" sentence in COGs
"Flag" sentence in COGs
2002-01-15, 4:45 AM #1
I've worked hard on a MOD for months and have a multiplayer problem I can't solve. Could someone please explain me values and meanings for the "flags=NNN" sentence in COGs? JKSpecs is not enaugh clear imho.

I have flagged a cog called by a sendtrigger() sentence with 0x240 but only the host sees the explosion effect. The COG linked with the explosion template is flagged with 0x040 but I'm not sure this is right. Are possible values only 0x040, 0x080, 0x100 and 0x200?

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-15, 7:52 AM #2
You're right, the Specs aren't clear enough. But I have not done much work with them so I can't really give you a better description of how they work. But basically, Cog Flags control how a cog functions - most control how a cog runs in MP.

The Specs say that 0x200 stops a cog from "broadcasting" a cog's "results." That's pretty cryptic, but I take it to mean that the verbs' effects will not by synced on other computers. So when you fire a projectile, it shouldn't appear on other computers - note that I have *not* tested that.

The explosion's cog has nothing to do with the explosion's appearance on other computers. If the explosion is not being created on the other comps, try putting a print() in the trigger message. If nothing prints on the other players' comps, the trigger is not reaching them - so check your SendTrigger() command. If it does print on their comps, there's some problem with your
code in the trigger message.

Quote:
<font face="Verdana, Arial" size="2">
Are possible values only 0x040, 0x080, 0x100 and 0x200?
</font>


Cog Flags act like normal flags, and it is unusual that they should start at 0x20 and not 0x1 like the other flags. Either the first flags were discarded or they perform functions yet unknown. The 0x20 Cog Flag (not in the Specs) is a default for all class cogs - I don't know what it does.

If this doesn't help you any, you'll need to post your cogs.

[This message has been edited by SaberMaster (edited January 15, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-15, 9:58 PM #3
It's funny that who's answering is again you, SaberMaster. Many thanks.

The MOD is still the same of the other time. I finally found that I was using SetPulse() instead of SetThingPulse().

The 0x200 value was useful for less lag but now I think this is also the cause the explosion (the returning item, do you remember) isn't created on client PCs. I didn't know that defualt cog flag was 0x20. This is quite useful for understanding cogging. I have to do more tests with different flag values...

I'm quite sure the trigger IS reaching everyone, 'cause everyone can fire and see his projectile and the othwers', but not everyone sees the item created (host sees all, client sees the host's but not his own).

The other problem I have is that other's PCs don't see the item picked by the owner but probably this is related with the first problem.

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-16, 6:35 AM #4
Ok, I see your problem. From what you're saying, it seems that JK lets the server create the explosion for the clients and does not create it locally.

The creation of static.jkl templates does not sync in multiplayer. So I guess that the host tells the clients to create the explosion, and it is not created because JK does not look in the static.jkl. -Only problem with that theory is the client does see the hosts explosion.

Email me your patch, and I'll see what I can do. [http://forums.massassi.net/html/wink.gif]

---

And about that 0x20 flag: I discovered it in MotS and it may not work the same in JK. And as I remember, clearing it when it was set by the engine crashed the game.

------------------
More matter with less art.

[This message has been edited by SaberMaster (edited January 16, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-16, 11:01 AM #5
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
Ok, I see your problem. From what you're saying, it seems that JK lets the server create the explosion for the clients and does not create it locally.

The creation of static.jkl templates does not sync in multiplayer. So I guess that the host tells the clients to create the explosion, and it is not created because JK does not look in the static.jkl. -Only problem with that theory is the client does see the hosts explosion.
</font>


Exactly! The MOD is coming...


------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-17, 2:25 AM #6
I changed the technology behind it and am currently testing it. Maybe I'll fix every template problem but please, continue to test you too. I'd prefer the first solution... did it arrived?

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-17, 4:11 AM #7
Yeah, it arrived. I'll look through it... [http://forums.massassi.net/html/wink.gif]

[This message has been edited by SaberMaster (edited January 17, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-19, 5:40 AM #8
I see what your problem is, Nemios. I'll work on it over the weekend. [http://forums.massassi.net/html/wink.gif]

------------------
More matter with less art.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-19, 10:44 AM #9
Ok, I just made a system to create the saber powerup locally on all computers when the
saber-proj is removed. When the player receives his saber, he sends a trigger out to
the other players so they destroy the saber on their computers.

The main difficulty in making this system work is that the powerup has different thing
numbers on different computers because it's managed locally.

Here's the modified client_saber.cog:
Code:
# Jedi Knight Cog Script
#
# Client_Saber.COG
#
# Client cog for multiplayer
#
# by Nemios

flags=0x240

symbols

thing		oldsaber				local
thing		itemsaber				local
thing		player				local
thing		powsaber			local

template    saberThrow=+force_saber          local

flex        autoAimFOV=10                    local

message     trigger
message	removed

end

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

code

trigger:
   if(GetSourceRef()==111)
   {
      FireProjectile(GetParam(0), saberThrow, -1, -1, '0 0 0', '0 0 0', 1.0, 0, autoAimFOV, autoAimFOV);
   }
   else if(GetSourceRef() == 112)
   {
	powsaber=GetThingUserData(GetParam(0));
	if(powsaber == 0) Return;		// Don't let the game destroy the player.
	DestroyThing(powsaber);
	SetThingUserData(GetParam(0), 0);
   }
   Return;


removed:
	oldsaber=GetSenderRef();
	player=GetThingParent(oldsaber);
	if(GetThingUserData(player) != 0) Return;
	itemsaber=CreateThingAtPos(LoadTemplate("+fsaberreturns"), GetThingSector(oldsaber), GetThingPos(oldsaber), GetThingLVec(oldsaber));
	SetThingUserData(itemsaber, player);
	SetThingUserData(player, itemsaber);
Return;

end


And here's the modified return_saber.cog:
Code:
# Jedi Knight Cog Script
#
# Return_Saber.COG
#
# Class cog for the returning saber
#
# by Nemios

flags=0x40

symbols

thing       powerup                          local
thing       player                           local
sound       pickupsnd=thrmlpu2.wav           local

message     created
message     timer
message     touched
message     taken
message     pulse

end

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

code

created:
   powerup = GetSenderRef();
   player = GetThingUserData(powerup);
   SetThingPulse(powerup,0.2);
   SetTimerEx(5,GetSenderRef(),GetThingSignature(GetSenderRef()),0);
   return;

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

timer:
   // if this object is still the same (could have been taken and reassigned)
   if(GetThingSignature(GetSenderID()) == GetParam(0)) DestroyThing(GetSenderID());
   return;

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

touched:
	powerup = GetSenderRef();
	player=GetThingUserData(powerup);
	if(player == GetSourceRef()) SendTrigger(-1, 112, player, 0, 0, 0);
	if(player == jkGetLocalPlayer()) call taken;

Return;
# ........................................................................................

taken:
   powerup = GetSenderRef();
   player = GetSourceRef();
   // Do effects.
   PlaySoundThing(pickupsnd, powerup, 1.0, -1, -1, 0);
   AddDynamicTint(player, 0.0, 0.0, 0.2);
   // Cleanup in the saber cog because we tried very hard
   // NOT to call its selected: event just above to avoid
   // playing the mount animation, etc.
   SendMessage(GetInvCog(player,22),user0);   // Deactivate saber throw...
   SendMessage(GetInvCog(player,10),user1);    // Fast mount...
   return;

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

pulse:
   powerup = GetSenderRef();
   player = GetThingUserData(powerup);
   // Returning the saber now...
   // Much faster if both the player and the saber is in the water
   if((GetSectorFlags(GetThingSector(player)) & 2) && (GetSectorFlags(GetThingSector(powerup)) & 2))
      SetThingVel(powerup, VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(powerup))), 4));
   else
   // Faster if only one of the parent or the saber is in the water
   if((GetSectorFlags(GetThingSector(player)) & 2) || (GetSectorFlags(GetThingSector(powerup)) & 2))
      SetThingVel(powerup, VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(powerup))), 3));
   // Normal speed of return if both are out of the water
   else
      SetThingVel(powerup, VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(powerup))), 2));
   return;

end


I also took the explode and fleshhit template settings out of +force_saber.

This would be a much nicer system if the powerup were synced. You might try working on
another system that would take an existing template like the shield powerup and
ParseArg() the settings to make it just like the saber powerup. That way, you'd be using a
template that was sure to be in the level and it's creation would be synced.

Because the system I made runs locally and is dependent on triggers, it's going to be prone
to MP problems. If the triggers don't make it over the net, the saber won't be destroyed.

Good luck, Nemios. [http://forums.massassi.net/html/wink.gif]

------------------
More matter with less art.

[This message has been edited by SaberMaster (edited January 19, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-22, 1:09 AM #10
I tryed something similar in the new technology. I modified the projectile template to create a common powerup (a saber powerup but could be anything) modifying only its cog (pow_saber.cog) and adding a created: message:

Code:
created:
   if(GetSourceType()==3)   // The caster is an actor, not placed by the level designer...
   {
      powerup = GetSenderRef();
      parent =  GetSourceRef();
      SendTrigger(-1,222,powerup,parent,0,0); // To save the pos of powerup and the caster...
      DestroyThing(powerup); // Nomore useful...
   }
   Return;

Then in a trigger I create the real powerup at the same pos and passing the parent as a parameter. I think this way should work exactly as the projectile and since that one is created everywhere this should too. In single player it works.

I'll try both solutions in multi. Many thanks for your help.

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.


[This message has been edited by Nemios (edited January 22, 2002).]
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-22, 3:18 AM #11
So you created a new cog (pow_saber) to run when the powerup is created. Then a trigger
is sent to all comps to create a new powerup while the old one is destroyed?

It would be much simpler to create the powerup in the removed message of the saber-
proj. The saber-proj cog runs on all computers so creating it there has the same
effect as sending a trigger to create it locally.

Also, there is no sourceref for the created message and GetSourceType() does not return
regular thing type values like GetThingType(). The Specs says that 3 is
returned for things.


You're welcome, Nemios. [http://forums.massassi.net/html/wink.gif]

[This message has been edited by SaberMaster (edited January 22, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-22, 4:23 AM #12
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
So you created a new cog (pow_saber) to run when the powerup is created. Then a trigger
is sent to all comps to create a new powerup while the old one is destroyed?

It would be much simpler to create the powerup in the removed message of the saber-
proj. The saber-proj cog runs on all computers so creating it there has the same
effect as sending a trigger to create it locally.
</font>


Yes, you are right. But I haven't linked any COG to the projectile. I saw you thought that client_saber was linked to +force_saber in your reply (you put in a removed: message and deleted fleshhit and explode). Actually I put it there only to "register" the COG, but the template, if you notice, isn't flagged as "COG linked". Anyway I could change that. I didn't think a trigger COG could be any COG.
POW_SABER isn't new. I only modified it to serve as a two-purpose cog.
Are you sure you can still retrieve projectile informations in the removed: message (the parent, the position)? So the object is removed AFTER the code you put there?

Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
Also, there is no sourceref for the created message and GetSourceType() does not return
regular thing type values like GetThingType(). The Specs says that 3 is
returned for things.
</font>


Well, I'm not at home and haven't checked jkspec. I don't exactly remember what I've used but it works in SP. I tryed it with the level where you fight Sariss, in which there's a saber powerup. At first it disappeared nearly instantly, so I fixed it checking the type of the source. Maybe I used GetThingType(GetSourceRef())... [http://forums.massassi.net/html/wink.gif]
Now, if only any of my friends decide to help me to test MP... would you? My ICQ is 67115961

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-22, 8:08 AM #13
I did test my cog system in multiplayer, and it works fine.

Quote:
<font face="Verdana, Arial" size="2">But I haven't linked any COG to the projectile.</font>


The cog is linked because it is listed in the projectile's template. I'm not sure what the "cog linked" flag is supposed to do, but the thing will be linked without it.

Quote:
<font face="Verdana, Arial" size="2">Are you sure you can still retrieve projectile informations in the removed: message (the parent, the position)?</font>


Positive. The thing isn't technically removed until after the removed message has run.

Quote:
<font face="Verdana, Arial" size="2">..,so I fixed it checking the type of the source.</font>


There is no sourceref for the created message.

Quote:
<font face="Verdana, Arial" size="2">Now, if only any of my friends decide to help me to test MP... would you?</font>


Sorry, Nemios, but my schedule is too erratic. I just know I'd have to do something just as the game loaded... For that reason, I'm not very dependable in real time.

I already tested my system in MP, but if you want, you can send me the patch, and I'll test it in MP when I get the time. I have a network [http://forums.massassi.net/html/biggrin.gif]

------------------
More matter with less art.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-22, 12:51 PM #14
if(powsaber == 0) Return; // Don't let the game destroy the player.

In this part, you may need to do this rather because other players in multiplayer are not all having ID as 0.

if(GetThingType(powsaber) == 10) Return;

The MotS engine must somehow be different on networking as the powerups can be picked up without asking the host in multiplayer whereas for JK it takes the lag to pickup items, or is it just scripted so? Sorry my knowledge is getting really limited already.

------------------
http://millennium.massassi.net - Millennium
Sniper Arena! - Enhancement Pack!

↑ Up to the top!