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 → Touched trigger Syncing Things
Touched trigger Syncing Things
2002-07-28, 8:29 AM #1
Since getting such great feed-back on some other cog probs, I thought It would be to ask about this other prob. Exploding crates are created which are set like throwable objects. They are nudgable. Im trying to complete a multiplayer match in which these crates will be basically in the same spot on all machines. Adding SyncThing has strange effects by itself, like making barrels moving backwards. I thought maybe somehow i could send a trigger when these crates are touched locally to have the server add that velocity to all the machines as its syncing the pos, after first getting the thouched thing's velocity (speed and direction?) ...

I have difficult time cause I dont fully understand all the server client stuff...I was thinking of adding the touched message here but then im not sure.
This is cog is called up like the exploding crate from within its template:

flags=0x80

symbols

message created
message damaged
message timer
message pulse
message touched
template barrel_exp=+xtank4_exp local
thing barrel local
vector getvector
int type
int yon
flex barrelhealth local
flex damage local
end

#=======================================================#
code

created:
barrel = GetSenderRef();
SetThingUserData(barrel, 35); // set initial user data ("health")
SetTimerEx(60.0, barrel, GetThingSignature(barrel), 0); // kill the barrel in 60 secs
SetThingPulse (barrel, 0.05);
Return;
#=======================================================#
damaged:
barrel = GetSenderRef();
damage = GetParam(0);
type=GetParam(1);
barrelhealth = GetThingUserData(barrel);
if(type ==0x1) Return;
else if (barrelhealth <= damage) //enough damage to kill barrel ?
SetTimerEx(0.5, barrel, GetThingSignature(barrel), 0);
else SetThingUserData(barrel, barrelHealth - damage);
Return;
#=========================================================#
touched:
barrel = GetSenderRef();
getvector=GetThingVel(barrel);


#=========================================================#
timer:
barrel=GetSenderId();
if(GetThingSignature(barrel) != GetParam(0)) Return;
CreateThing(barrel_exp, GetSenderID());
DestroyThing(GetSenderID());
Return;
#=========================================================#
pulse:
barrel = GetSenderRef();
yon=Isthingmoving(barrel);
If (yon==0) Return;
SyncThingPos(barrel);
Return;
end


[This message has been edited by Gelatinous_Drool (edited July 28, 2002).]
2002-07-28, 9:12 AM #2
  • You need a return; on the touched message.
  • getvector isn't used.
  • SaberMaster know the most about MP cogs
that's my 1ยข

------------------
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-07-28, 9:46 AM #3
I just added the getvector up above and I left the touched message unfinished because i know something needs to go there. A few months ago SM advised me how to do that Pulse message with SyncThingPos. But, like I said above, the barrels do some weird things. Its been several months since I tested it though & I dont member all the circumstances involved,...like host or client differences..blah,blah.
2002-07-28, 11:18 AM #4
So your problem is that SyncThingPos() is working, but the velocity is not being synced, right? Why exactly do you need to sync them?

A pulse of 0.05 is way too fast to send information to the clients. A pulse of about a second would do better. As for syncing the velocity, you'd have to use a trigger system to send the server's crate's velocity out to the clients. A client portion of the cog would recieve the trigger and set the local crate's velocity.

Because it's been a while since you last tested that cog, you should test it again before deciding what you need to change. Then if you want, I'll write the trigger system to sync the velocity.

------------------
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-07-28, 2:44 PM #5
Well, I tested it. And what happens is on either the host OR the client barrels go backwards. The reason Im trying to do this is because I have these barrels going down conveyer belts and sliding down ramps and shooting up lift tubes. They are dispersed thru the level and end up in different areas. Without syncing them they can end up in very different places depending on how they bounce around or how a player nudges them off the conveyer belt.
So, the syncing is necessary for the game play Im trying to get out of it.
I suppose I should post the cog that creates these barrels in case that sheds some light on whats happening:

symbols

surface switch desc=switch
thing console desc=console

thing xcrate0 nolink
thing xcrate1 nolink
thing xcrate2 nolink
thing xcrate3 nolink
thing xcrate4 nolink
thing xcrate5 nolink

int rounds=4 desc=rounds
int i local
int alarm=58.0 local

flex rate=0.01
flex delay=61.0

int cur_round=0 local
int dummy local

template proj_tpl=+xtank1a local

sound on_snd=set_hi2.wav local
sound off_snd=lgclick1.wav local
sound alarmsound


int active=0 local

message activated
message timer

end

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

code

activated:
if(active == 1) Return;
active = 1;

dummy = SetWallCel(switch, 1);
dummy = PlaySoundPos(on_snd, SurfaceCenter(switch), 1.0, 5.0, 10.0, 0);

SetTimer(alarm);

cur_round = 0;

while(cur_round < rounds)
{
for( i = 0 ; i<=5 ; i = i + 1 )
{
dummy = CreateThing(proj_tpl, xcrate0);
SetThingParent(dummy, GetParam(0));
Sleep(rate);
}
cur_round = cur_round + 1;
}

Sleep(delay);

dummy = SetWallCel(switch, 0);
dummy = PlaySoundPos(off_snd, SurfaceCenter(switch), 1.0, 5.0, 10.0, 0);

active = 0;

Return;


#--------------------------------------------------------------------------------------------
Timer:
PlaySoundGlobal(alarmsound, 1.0, 0.0, 0);

Return;



end

By the way. The results are the same wether I have 1 round or more than one round. It appears maybe one barrel of the group DOES seem synced.
2002-07-29, 1:58 PM #6
Host and client computers have the same problem? SyncThingPos() should use the host's position for the barrels - so there wouldn't be any discrepancy on the host's computer. What happens if you play the level by yourself? Do the barrels move backwards then?

In the barrel creation cog, the parent of the barrel is set to the first param of the activated message. But the activated message has no parameters. What are you trying to do there?

------------------
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-07-29, 5:54 PM #7
Oh, That was originally suppose to give credit to who hit the button for any kill the barrels cause, I think. I am very unclear on the declaring and passing of paramaters like that.

When I play the level alone the barrels act and move in their normal desired way.
2002-07-30, 2:44 PM #8
Well, I won't be able to solve this problem with just the cogs. Could you zip your level and email it to me? The zip would have to be under 3MB.

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