Re: SendTrigger() Params


[ Follow Ups ] [ Post Followup ] [ Jed Messages ]

Posted by CogKing on March 15, 1998 at 19:26:17:

In Reply to: SendTrigger() Params posted by Osan`gar on March 15, 1998 at 18:51:03:

> Ok CogKing or whoever else is reading this. I've been trying to figure out the parameters for the SendTrigger() verb, and I can't. What are the parameters and how exactly does it interact with the other cogs? Does it just send the information it has aquired in the particular cog it is in and make that info available to all the other cogs or what? I'm thinking it goes SendTrigger(CogSentTo, ?, FirstVariableSent, SecondVariableSent, ?, ?); How's that for a start? Thanks to whoever gets this one. ;)


SendTrigger(destinationPlayer, triggerID, param0, param1, param2, param3);

destinationPlayer is the reference of a player, in which case a trigger:
message is sent to ALL the cogs of that player
OR
destinationPlayer is -1 in which case a trigger: message is broadcast to ALL
the cogs of ALL the players in the game

triggerID is simply an integer ID that you define so you know what trigger is
being sent and can decide if a particular cog wants to handle it or not
Use GetSenderID() to retrieve this in the trigger: handler.

param0... param3 are 4 user parameters into which you can pass any information
you want.
Use GetParam(0)...GetParam(3) to retrieve these values in the trigger: handler.

The use of this is VERY important to
1) reduce network traffic -- in the breaking glass example, you certainly don't
want to send information about 50 glass shards over the internet, so instead a
trigger is sent and each machine handles it and manages its own shards locally.
NOTE: I'm currently rewriting doors for instance to use triggers to reduce the
bandwidth in multiplayer games (imagine that we currently send a message for
changing the switch cel, for playing a switch sound, for moving the 3do, for
changing the sector adjoins,... then all the rever messages a few seconds later.
That is 8 messages PER PLAYER CONNECTED (minus 1, you don't send to yourself).
By using triggers we could reduce this to 1 message per player connected and
possibly raise the number of players who can play at the same time. Especially
in cunjunction with the better bandwidth in MoTS obtained by reducing the
powerup messages (you don't have to ASK the server for the powerup anymore in
MoTS, in effect gaining 2 messages per powerup taken, gaining the lag before
you receive the answer, and also gaining a sound message BTW).

2) to execute accross the network things that are not possible in other ways.
For instance the CTF script (running on the server) sends a trigger to ask a
client to display an icon (the flag) on its screen. This is not directly
feasible in cog, since issuing the command to display the icon on the server
would simply display it... on the server !

Hope this wasn't too long... :-)

-CogKing



Follow Ups:



Post a Followup

Name:
E-Mail:
Subject:
Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ Jed Messages ]