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 → Simple scenario..
Simple scenario..
2003-06-15, 6:00 AM #1
But I can't test at the moment..

Ok, I have an object that is activatable. Upon activating the object, stuff happens to the player1. If another player2 activates the object afterward, stuff happens to..player1 again! Now that isn't right!

What I've gome up with is to put Getsourceref() == -1; in the activated message after the effects. Should that work? And if not, any ideas?

------------------
Project leader of TDIR
Jedi Knight Enhanced
Freelance Illustrator
2003-06-15, 7:22 AM #2
Aahh.. a few tests later and I get the feeling this isn't going to work. I'm an artist not a programmer! Can you tell me whats wrong with this?

Code:
# Shred18 20002

symbols

thing        player                             local                         
thing        machine                                                          
thing        ghost                                                            
sector       checkpoint1                                                      
sector       checkpoint2 
surface      note                                                     
template     dummy
template     sky=roshihutbox			local                                                           
material     startmat=racestart.mat             local                         
material     arcademat=arcade.mat               local
material     hovermat=hovercar.mat              local                         
model        hovercar=hovercar.3do                                                                          
sound        beep1                                                            
sound        beep2                                                            
sound        beep3
sound        victory                                                            
sound        hoversnd                                                         
int          guy                                local
int	     attachment				local                         
flex         timecount                          local                         
flex         score                              local                                                 
int          weap1                              local   //I wish I knew arrays..I don't. What can ya do..                      
int          weap2                              local                         
int          weap3                              local                         
int          weap4                              local                         
int          weap5                              local                         
int          weap6                              local                         
int          weap7                              local                         
int          weap8                              local                         
int          weap9                              local                         
int          weap10                             local 
int		ki				local
int		charging			local
int		kaoken				local
int		throw				local
int		sense				local
int		melee				local                        
int          bact                               local                         
int          ir                                 local                         
int          field                              local                        
int          hs                                 local
int          speed=2                            local
int          name				local
int		reading=0			local
flex         mytime=4.0                         local                         
vector       thrust                             local                              
message      activated                                                        
message      pulse                                                            
message      trigger                                                          
message      entered                                                          
#message      user0                                                            
#message      killed                                                           

end                                                                           


code

activated:
   player = GetLocalPlayerThing();
   activator = GetSourceRef();
   If(machine == GetSenderRef())
  { 
   guy = CreateThingatPosNr(dummy,GetThingSector(player),GetThingPos(player),GetThingLVec(player)); 
   SetThingModel(guy, GetThingModel(player));
   SetThingLook(guy,machine); 
   SetMaterialCel(arcademat,1);
   TeleportThing(player, ghost);
   attachment = CreateThing(sky,player);  //eliminate hom from the track
   AttachThingtoThingEx(attachment, player, 0xc); 
   ParseArg(player, "puppet=cr.pup");
   SetThingModel(player, hovercar);
   SetActorFlags(player,0x200000);
   SetActorFlags(player,0x800000);
   SetActorFlags(player,0x80000000);
   hs = PlaySoundThing(hoversnd, player, 3, -1, -1, 0x81);
   GetSourceRef() == -1; //must remove player as the source so others can play.  
   SetMaterialCel(startmat,0);
   PlaySoundThing(beep3, player, 3, -1, -1, 0x80);
   Print("3");
   Sleep(1.0);
   SetMaterialCel(startmat,1);
   PlaySoundThing(beep1, player, 3, -1, -1, 0x80);
   Print("2");
   Sleep(1.0);
   SetMaterialCel(startmat,2);
   PlaySoundThing(beep1, player, 3, -1, -1, 0x80);
   Print("1");
   Sleep(1.0);
   SetMaterialCel(startmat,3);
   PlaySoundThing(beep2, player, 3, -1, -1, 0x80);
   Print("START!");
   ClearActorFlags(player,0x200000);

   weap1 = IsInvAvailable(player,1);  //get item and weapon info for later.
   weap2 = IsInvAvailable(player,2);
   weap3 = IsInvAvailable(player,3);
   weap4 = IsInvAvailable(player,4);
   weap5 = IsInvAvailable(player,5);
   weap6 = IsInvAvailable(player,6);
   weap7 = IsInvAvailable(player,7);
   weap8 = IsInvAvailable(player,8);
   weap9 = IsInvAvailable(player,9);
   weap10 = IsInvAvailable(player,10);
   ki = IsInvAvailable(player,21);
   charging = IsInvAvailable(player,25);
   kaoken = IsInvAvailable(player,22);
   throw = IsInvAvailable(player,30);
   sense = IsInvAvailable(player,31);
   melee = IsInvAvailable(player,32);
   bact =  IsInvAvailable(player,40);
   ir = IsInvAvailable(player,41);
   field = IsInvAvailable(player,42);

SetInvAvailable(player,1,0);    //disable it all.
SetInvAvailable(player,2,0);
SetInvAvailable(player,3,0);
SetInvAvailable(player,4,0);
SetInvAvailable(player,5,0);
SetInvAvailable(player,6,0);
SetInvAvailable(player,7,0);
SetInvAvailable(player,8,0);
SetInvAvailable(player,9,0);
SetInvAvailable(player,10,0);
SetInvAvailable(player,21,0);
SetInvAvailable(player,25,0);
SetInvAvailable(player,22,0);
SetInvAvailable(player,30,0);
SetInvAvailable(player,31,0);
SetInvAvailable(player,32,0);
SetInvAvailable(player,40,0);
SetInvAvailable(player,41,0);
SetInvAvailable(player,42,0);
SetInv(player,14,0);

   //SetPhysicsFlags(player,0x2);
   //SetPhysicsFlags(player,0x20);
   SetPhysicsFlags(player,0x400);
   SetPhysicsFlags(player,0x100);
   SetPhysicsFlags(player,0x40000);  
   AddThingVel(player, VectorScale(GetThingLVec(player), 2));
   SetPulse(0.5); 
   Sleep(1.0);
   SetMaterialCel(startmat,4);
}
If(note == GetSenderRef())
{ if(reading == 1)Return;

   reading = 1;
	//ChangeInv(player, 84, 1);  grab a key so i can test the dragonballs
   print("INSTRUCTIONS:");
   sleep(1.0);
   print("Time Trial");
   sleep(1.0);
   print("Press Foreward to Accelerate");
   sleep(1.0);
   print("Press Back to Decellerate");
   sleep(1.0);
   print("Use the Boost Pads to Stay Ahead");
   sleep(1.0); 
   jkStringConcatAsciiString("Best Time: ");
   jkStringConcatFlex(mytime);
   jkStringConcatAsciiString(" -Shred");
   jkStringOutput(player, -1);
   jkStringClear();
   reading = 0;
}
   Return;

pulse:
   AddThingVel(player, VectorScale(GetThingLVec(player), speed));
   timecount = timecount + 0.5;
   thrust = GetThingThrust(player);
   SetInv(player,14,0);            //get rid of ki to prevent levelup or misc glitches.
   if(GetThingHealth(player) < 1)  //prevent glitches if they kill themselves.
{
 SetThingModel(player, GetThingModel(guy));
TeleportThing(player, guy);
destroything(guy);  //more stable than destroy! how about that.
destroything(attachment);
ParseArg(player, "puppet=ky2.pup");
ClearPhysicsFlags(player,0x400);
ClearPhysicsFlags(player,0x100);
ClearPhysicsFlags(player,0x40000);
SetInvAvailable(player,1,weap1);
SetInvAvailable(player,2,weap2);
SetInvAvailable(player,3,weap3);
SetInvAvailable(player,4,weap4);
SetInvAvailable(player,5,weap5);
SetInvAvailable(player,6,weap6);
SetInvAvailable(player,7,weap7);
SetInvAvailable(player,8,weap8);
SetInvAvailable(player,9,weap9);
SetInvAvailable(player,10,weap10);
SetInvAvailable(player,21,ki);
SetInvAvailable(player,25,charging);
SetInvAvailable(player,25,kaoken);
SetInvAvailable(player,30,throw);
SetInvAvailable(player,31,sense);
SetInvAvailable(player,32,melee);
SetInvAvailable(player,40,bact);
SetInvAvailable(player,41,ir);
SetInvAvailable(player,42,field);
ClearActorFlags(player,0x800000);
StopSound(hs, 0);
SetMaterialCel(arcademat,0); 
SetPulse(0.0);
}
Return;

entered:
score = timecount/60;
If(checkpoint1 == GetSenderRef())
{PlaySoundThing(beep3, player, 3, -1, -1, 0x80);
jkStringConcatAsciiString("CheckPoint! ");
jkStringConcatFlex(score);
jkStringConcatAsciiString(" minutes");
jkStringOutput(player, -1);
jkStringClear();
}
If(checkpoint2 == GetSenderRef())
{
 //SendMessage(arcade, user0);
SetPulse(0.0);
AddThingVel(player, VectorScale(GetThingLVec(player), -7));
PlaySoundThing(beep3, player, 3, -1, -1, 0x80);
SetActorFlags(player,0x200000);
jkStringConcatPlayerName(player);
jkStringConcatAsciiString(" did The Canyon Run in ");
jkStringConcatFlex(score);
jkStringConcatAsciiString(" minutes");
jkStringOutput(player, -1);
jkStringClear();

If(score <= 1.41)
{ChangeInv(player, 84, 1); 
 print("Good Job! You win a key!");
 PlaySoundThing(victory, player, 3, -1, -1, 0x80);
}
else
If(score <= 2.0)
{ChangeInv(player, 84, 1);
 print("Good Job! You win a key!");
 print("Shred Craft Unlocked");
 PlaySoundThing(victory, player, 3, -1, -1, 0x80);
 SetMaterialCel(hovermat,2);
 speed = 7;
 mytime = 1.41;
}
else
If(score <= mytime)      
{ChangeInv(player, 84, 1);
 print("Good Job! You win a key!");
 print("Black Hawk Unlocked");
 PlaySoundThing(victory, player, 3, -1, -1, 0x80);
 SetMaterialCel(hovermat,1);
 speed = 5;
 mytime = 2.0;
}

ClearActorFlags(player,0x200000);
Sleep(2.0);
 SetThingModel(player, GetThingModel(guy));
 TeleportThing(player, guy);
 destroything(guy);
 destroything(attachment);
 ParseArg(player, "puppet=ky2.pup");
 //ClearPhysicsFlags(player,0x2);
 ClearPhysicsFlags(player,0x400);
 ClearPhysicsFlags(player,0x100);
 ClearPhysicsFlags(player,0x40000);
 ClearActorFlags(player,0x800000);
SetInvAvailable(player,1,weap1);
SetInvAvailable(player,2,weap2);
SetInvAvailable(player,3,weap3);
SetInvAvailable(player,4,weap4);
SetInvAvailable(player,5,weap5);
SetInvAvailable(player,6,weap6);
SetInvAvailable(player,7,weap7);
SetInvAvailable(player,8,weap8);
SetInvAvailable(player,9,weap9);
SetInvAvailable(player,10,weap10);
SetInvAvailable(player,21,ki);
SetInvAvailable(player,25,charging);
SetInvAvailable(player,22,kaoken);
SetInvAvailable(player,30,throw);
SetInvAvailable(player,31,sense);
SetInvAvailable(player,32,melee);
SetInvAvailable(player,40,bact);
SetInvAvailable(player,41,ir);
SetInvAvailable(player,42,field);
StopSound(hs, 0);
SetMaterialCel(arcademat,0);
timecount = 0;
}
Return;

end


------------------
Project leader of TDIR

[This message has been edited by Shred18 (edited June 15, 2003).]
Jedi Knight Enhanced
Freelance Illustrator
2003-06-15, 11:38 AM #3
If you want it only to happen to the local player, use "player=GetSourceRef()". That way it will only happen to whatever player activates it. You may also try adding "local" above "symbols" if that doesn't work.

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!
Catloaf, meet mouseloaf.
My music
2003-06-15, 11:39 AM #4
Also note that "GetLocalPlayerThing()" gets the host (except in weapon & inventory cogs) while "jkGetLocalPlayer()" actually gets the local player.

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!
Catloaf, meet mouseloaf.
My music
2003-06-15, 12:09 PM #5
Ahh, thank you! It may have been teleporting the host, although I'm not positive.

What I changed was:

player = jkGetLocalPlayer();
player = GetSourceRef();

got rid of "Getsourceref() = -1;" (Just chalk that up to ignorance :P, note: can't assign to functions)

and I added flags=0x240 before symbols, so hopefully that did the trick.

------------------
Project leader of Dbz:TDIR

[This message has been edited by Shred18 (edited June 15, 2003).]
Jedi Knight Enhanced
Freelance Illustrator
2003-06-15, 12:15 PM #6
Ahhh it burns *eyes turn to fire and smoke* Use the FOR loop man, the FOR loop. *wakes up*

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

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-06-15, 12:38 PM #7
/me points to the artist comment.

Lol, If you'r willing to elaborate, I'm willing to learn. ^^thats all a product of observation up there. I've yet to pick up a programming book.

------------------
Project leader of Dbz:TDIR
Jedi Knight Enhanced
Freelance Illustrator
2003-06-15, 12:46 PM #8
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Shred18:
What I changed was:

player = jkGetLocalPlayer();
player = GetSourceRef();</font>
Wha...?
You can only have one value at a time to a variable. Only the last one will take effect: "Player=GetSourceRef();"
You can probably figure any other problems from there, if there were any.
------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

[This message has been edited by DogSRoOL (edited June 15, 2003).]
Catloaf, meet mouseloaf.
My music
2003-06-15, 1:41 PM #9
He means he changed the top one to the bottom one I think. For good reason, too, jkGetLocalPlayer() borks in MP if it's not local. It gets the host I think.

------------------
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-06-15, 2:38 PM #10
Quote:
<font face="Verdana, Arial" size="2">Also note that "GetLocalPlayerThing()" gets the host (except in weapon & inventory cogs) while "jkGetLocalPlayer()" actually gets the local player.</font>

Quote:
<font face="Verdana, Arial" size="2">jkGetLocalPlayer() borks in MP if it's not local. It gets the host I think.</font>


Prove it. I've never had problems with either, and I'm willing to bet that they're the same verb.

Quote:
<font face="Verdana, Arial" size="2">Lol, If you'r willing to elaborate, I'm willing to learn. ^^thats all a product of observation up there. I've yet to pick up a programming book.</font>


Another plug. [http://forums.massassi.net/html/smile.gif] If you are really serious about learning Cog, read a book on C (in order of preference), C++, Pascal, Java, or Basic. A good book on any of those will teach you fundamentals that apply to almost all languages, just don't get caught up with things specific to that language/compiler.

I'm pretty sure the problem with your cog is that: your cog's event messages are running on the server only because you aren't using any cog flags, therefore the local player is the host (the first player). So it's not GetLocalPlayerThing() or jkGetLocalPlayer()'s fault.

A good trick is to put print()s under your event messages so that you can see which computers are running the messages.

To fix this, you have to decide which computer you want to run the message. You could have to server run the message and change the info on the clients computer, or you could have the client run the message and sync the changes with the server and everyone else.

Now since your doing a lot local things: like inv changes and prints, you should have the local player run the messages (cog flag 0x40), but you *will* want him to sync his changes with other players (so don't use 0x200). In this case, it really doesn't matter whether you use the local player or the source ref, either will work.

Now, I'm not entirely sure of all the things you're trying to do, but what I outlined should work. If you have the problem that all computers are running the messages even with the 0x40 flag, then reply again. BTW, It's always good to meet a Cog programmer from the 201st century now and then. [http://forums.massassi.net/html/smile.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-06-15, 3:49 PM #11
[http://nervecore.org:800/Shred18/media/stuff/canrun01.jpg]
[http://nervecore.org:800/Shred18/media/stuff/canrun02.jpg]

This is what the cog is for, It's a minigame inside a level.

Sabermaster: I'm not really that gung-ho about learning cog, as I've got HellRaiser on my side, and after Tdir releases, I'll likley never touch JK again. I'll pick up a book on C++ one of these days though..

Basically why I'm coding this is just to say I did [http://forums.massassi.net/html/biggrin.gif]

So let me get this straight.. 0x40 run messages locally, 0x200 means changes dont sinc.. so I wan't 0x40 instead of 0x240. (I had to read that a few times, lol)

------------------
Project leader of Dbz:TDIR
Jedi Knight Enhanced
Freelance Illustrator
2003-06-15, 6:29 PM #12
SM, I can't remember which one it was, but for MP it got the host instead of the correct player. About two years ago I was working on a ledge grabbing system, and it worked fine offline, but when I tested it online, anytime the client would try to grab a ledge, the server (me), would play the animations, sounds, etc., and the client would skip the ledge and fall to the ground. I changed it to GetSourceRef() or something and it worked fine.

Uber(HOV), whom I tested this with, could testify if you don't believe me. [http://forums.massassi.net/html/wink.gif]

------------------
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-06-18, 9:50 AM #13
That's right, Shred. [http://forums.massassi.net/html/wink.gif]

Emon, I've heard that a lot, but whenever I've tested those verbs, they seemed to work. [http://forums.massassi.net/html/confused.gif] I'll have to test them again with different cog types/flags.

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

↑ Up to the top!