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 → Using SyncThingPos()
Using SyncThingPos()
2001-11-02, 10:26 AM #1
MW is being delayed because I'm having trouble getting it to work in MP. I figured out how to get the template cogs working correctly on all comps, but the missile is not synced on the other player's machines.

I want it to work like this: The player fires a homing missile. When the template is created, the template cog will run on all comps in the MP game. Only the person-who-fired-the-missile's computer will run that cog's homing code. And this homing code will sync the missile with, SyncThingPos(missile); But this isn't working.

On the shooter's comp, the missile homes in and hits it's target perfectly. But on all the other comps, the missile just stays beside the shooter. (the missile's velocity is controlled by the homing code).

Any suggestions?

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-02, 11:42 AM #2
Why don't you try doing some of your MW code broadcasting locally dude, see if that works first [http://forums.massassi.net/html/smile.gif] ?
2001-11-05, 3:00 AM #3
What do you mean by "local code broadcasting"?

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-05, 10:12 AM #4
If the missile only homes on the shooter's comp, maybe the homing code needs to be on each player's computer.
COUCHMAN IS BACK BABY
2001-11-05, 11:30 AM #5
You can't do that because the missile might home in on a different person on each computer. The main reason it's on the shooter's comp is because each player needs his own missile cogs.

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-06, 9:49 AM #6
As far as I know, the only way to fix that would be to have the code on each side. Then use something like 'Syncthingpos'. It might cause lag, but it should solve your problem.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-11-07, 9:03 AM #7
What I want to do is have only one person run the homing code and sync the position.

I don't see any reason for all players to run the homing code for the same missile when the missile's position is going to be reset anyway.

The big problem is that SyncThingPos(missile) is not working. The missile homes on one computer and is not synced at all on the other. Is there something special you have to do to get SyncThingPos() to work? [http://forums.massassi.net/html/confused.gif]

I'll do some experimenting and let you know if I find anything. [http://forums.massassi.net/html/wink.gif]

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-07, 5:49 PM #8
Have you got it like this:

setpulse(0.5)

pulse:
syncthingpos(missle)
return

If you do and it works can you post... cause I cant get syncthingpos() to work on an attachment of some description. Is that what your trying to do?
Team Battle.
2001-11-10, 1:17 AM #9
Yeah, I've got it working something like that. I have SyncThingPos() running in a fast looping timer.

I'm trying to get SyncThingPos() to synchronize the position of my missile on all of the other computers. But it just doesn't work, nothing happens. [http://forums.massassi.net/html/frown.gif]

If you want an attachment to by synced, Hellcat, you need to use SyncThingAttachment(thing); I had no problems with that verb, it simply does what it says. [http://forums.massassi.net/html/smile.gif]

I am considering releasing MW as SP and Rbots only. Unless I can get SyncThingPos() to work, that's what I'll have to do. [http://forums.massassi.net/html/frown.gif]

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-10, 11:16 AM #10
SyncThingPos() does actually work. Rbots uses it the sync the bot position across all computers.

The difference could be in the way the cog is actually called. Rbots has a separate cog for each 'thing' that needs to be synched, where it seems like you use a template that calls the cog when the 'thing' is created.

Raynar


------------------
... the Jedi I admire the most, met up with Darth Maul, now he's toast ...
Rbots - a project to develop a working Bot for Jedi Knight... download the latest development version here
Pagewizard_YKS: "making your own lightsaber doesn't make you a nerd... "
Raynar - the man with a 10.75" ePenis
2001-11-11, 11:57 PM #11
If you try to Sync something really fast, like in a really short pulse, that will cause major lag. (Though I'm not sure about SyncThing***, I never used it)

Have you tried to manage the homing missile to be launched on every local machine using SendTrigger in the fire message and see if it does follow same people on all machines?
Or does the slight lag in between all network make those cogs to go find someone else on each computers?

If it doesn't work having it all local, this may be the logic to do.

Shoot the homing missile using SendTrigger, so it runs on all clients' own cogs.
Code:
 #---------------------------


  created:


       missile0[numMissile] = GetSenderRef();
       player = GetLocalPlayerThing();
       if(GetThingParent(missile0[numMissile]) == player) shooterCog0[numMissile] = 1;


       numMissile = numMissile + 1;


       if(numMissile == 1) SetPulse(0.01);


   return;


#---------------------------


   pulse:


   for(x=0; x<numMissile; x=x+1)
   {
      if(shooterCog0[x]) //if the shooter himself
      {
         target0[x] = -1;

         pot = FirstThingInView(missile0[x], angle, dist, 0x404);
         prevDot = 0;


         while(pot != -1)
         {
            dot = ThingViewDot(missile0[x], pot);


            if(dot > prevDot && pot != player)
            {
               target0[x] = pot;
               prevDot = dot;
            }


            pot = NextThingInView();
         }

 
         if(target0[x] != prevTarget0[x])
         {
             SendTrigger(-1, id, target0[x], x, 0, 0);
             prevTarget0[x] = target0[x];
         }
      }


      //suppose the code for changing the velocity is like this
      if(target0[x] != -1)
      {
         targetVel = VectorSub(GetThingPos(target0[x]), GetThingPos(missile0[x]));
         someForce = VectorScale(targetVel, power);

         ApplyForce(missile0[x], someForce);
         SetThingLook(missile0[x], targetVel);
      }
   }


   return;


#---------------------------


   trigger:


   if(GetSourceRef() != id) return;


   target0[GetParam(1)] = GetParam(0);


   return;


#---------------------------


   removed:


      for(x=0; x<numMissile; x=x+1)
      {
          if(missile0[x] == GetSenderRef())
          {
             for(y=x; y<numMissile; y=y+1) missile0[y] = missile0[y+1];
             missile0[numMissile] = -1;


             x = numMissile;


             numMissile = numMissile - 1;
          }
      }


      if(numMissile == 0) SetPulse(0);


      return;



I actually wrote the whole damn cog! Use it if it works for you or parts of the above cog.

You should have arrays set properly in the symbols section. Alot of them. (Cog sucks at creating array entries. missile0[0], missile0[1], and so on...) Should have them about 12, considering max number of players as 4 and firing 3 missiles as max in terms of missile velocity, have more if you need.

It puts all fired missile in arrays having them fired locally. Missiles that is responsible for the shooter tries to find the target, if new target is found it will broadcast which missile has what target, and gets out of array when removed. So no need to send trigger every so often. Hope this does help.

------------------
http://millennium.massassi.net/ - Millennium

[This message has been edited by Hideki (edited November 12, 2001).]
2001-11-12, 4:05 AM #12
OMG, you used a WHILE LOOP, in a FOR LOOP, in a PULSE of 0.01.

Im not gonna test it but I'd be willing to bet there are major framerate issues there.

I might be wrong though.



[This message has been edited by The_New_Guy (edited November 12, 2001).]
- Wisdom is 99% experience, 1% knowledge. -
2001-11-12, 5:57 AM #13
But that's how a homing can be done. "while" loop won't get called much anyway for most of the time 1 or 2 for each pulse. "for" may go as much as the number of missiles existing. Don't think this can be any framerate issue, the problem is sending packets than thousand calculation on local computers.

------------------
http://millennium.massassi.net/ - Millennium
2001-11-13, 7:34 AM #14
Yeah, I'm sure SyncThingPos() works and I'm using it in just about the same way as the CTF cogs. But my pulse might just be too fast.

The hardest thing to do with a homing missile is make it remember its target. And if you can't use the user-data, then you have to make an array. -Right there, you limit how many missiles that can run at once. My arrays are 1 through 20 so no more than 20 missiles will work at once.

The main reason I want the cogs to run locally is so each player can keep track of his missiles. But like you guys said, syncing them would cause a lot of lag. Plus if the shooter was not the server, it would double the lag.

So, what I'm going to do is make the homing code run on all computers. -There is a chance that the missile will get a different target on different computers, but it's better than no MP at all.

New Guy: I'll take that bet.

I used to wonder how the engine could handle fast pulses and timers, but I found that JK can handle some amazingly complex code with no apparent drop in framerate.

However, when you try to make something graphical like several fine particle trails, you get a major drop in framerate (Though I suppose that wouldn't happen if you had an accelerator). But my point is that the cog coding isn't that much compared to the graphics processing.

In fact, my homing code gets up to 40 times more complex than Hideki's example and there's little or no drop in framerate.

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-13, 11:55 AM #15
Yeah I didnt look to closely at the his code, the for and while loops wont run long.

Now I see why previous homing weapons used LEC projectiles.
- Wisdom is 99% experience, 1% knowledge. -

↑ Up to the top!