Posted by Osan`gar on March 15, 1998 at 21:40:18:
In Reply to: Re: Cog help, CK... posted by CogKing on March 15, 1998 at 21:32:03:
> > Ok, I've been about to scream for the past week over this cog that I am developing. When I began, I thought I could pop it out in no time. I knew that I would find a couple of bugs in the first version of it, and I did, but there is one bug that has been consistent throughout. Well, during development, I switched the cog around because I realized that it was doing the reverse of what I expected to happen. It has continued to work in this manner. The problem is, I don't understand why it is doing this! I have went over this cog along with Pele who I asked to look it over as well, and neither one of us has figured out why this cog is doing what it is doing. I am going to include it below for you to take a look at CK. I'll add comments to illustrate my point and tell you what I believe should be happening.
> > symbols
> > surface switch linkid=1
> > surface switch0
> > surface glassfloor1 nolink,desc=glassfloor1
> > surface glassfloor2 nolink,desc=glassfloor2
> > flex time_on=10.0 desc=time_on
> > flex delay=5.0 desc=delay
> > int trap_is_on=0 local
> > int gl_sound local
> > sound buttnsnd=Activate04.wav local
> > message startup
> > message activated
> > end
> > # ========================================================================================
> > code
> > startup:
> > SetWallCel(switch0, 0);
> >
> > Return;
> > # ........................................................................................
> > activated:
> > if (trap_is_on == 1) Return;
> >
> > else if (GetWallCel(switch0) == 0)
> > {
> > trap_is_on = 1;
> > Print("Floor Dissolved");
> > PlaySoundPos(butnsound, SurfaceCenter(switch0), 1, -1, -1, 0);
> > SetWallCel(switch0, 1);
> > SetFaceGeoMode(glassfloor1, 0);
> > SetFaceGeoMode(glassfloor2, 0);
> > SetFaceLightMode(glassfloor1, 3);
> > SetFaceLightMode(glassfloor2, 3);
> >
> > ClearAdjoinFlags(glassfloor1, 0x16); //take away passable flags and other flags that go along with it
> >
> > ClearAdjoinFlags(glassfloor2, 0x16);
> > SetAdjoinFlags(glassfloor1, 0x402); //render past adjoin, non passable
> > SetAdjoinFlags(glassfloor2, 0x402);
> > SetSurfaceFlags(glassfloor1, 0x12); //floor and impassable
> > SectorLight(switch0, 1.0, 0.0);
> >
> > Sleep(time_on); // Let the trap active
> >
> > SectorLight(switch0, 0.0, 0.0);
> >
> > SetFaceGeoMode(glassfloor1, 4);
> > SetFaceGeoMode(glassfloor2, 4);
> > SetFaceLightMode(glassfloor1, 0);
> > SetFaceLightMode(glassfloor2, 0);
> > ClearAdjoinFlags(glassfloor1, 402); //clear render past adjoin and nonpassable
> > ClearAdjoinFlags(glassfloor2, 402);
> > SetAdjoinFlags(glassfloor1, 0x16); //render past adjoin, does not block sound, passable
> >
> > SetAdjoinFlags(glassfloor2, 0x16);
> > ClearSurfaceFlags(glassfloor1, 0x12); //clear floor
> > SetSurfaceFlags(glassfloor1, 0x1);
> >
> > Sleep(delay);
> > trap_is_on = 0;
> > SetWallCel(switch0, 0);
> > }
> >
> > Return;
> > end
> > Ok, what I am trying to do is have a glass floor. When the player activates the switch, the floor disappears. After a few moments, the floor reappears. When I activate the switch, the floor disappears, but when it reactivates, it remains passable and gives the skating effect when it is walked on. Why is this cog acting in this way? It seems as though the cog should be reversed, but the first part works for some reason! Help me CogKing, you're my only hope!
> This is NOT setting the floor bit as the comment seems to imply.
> > SetSurfaceFlags(glassfloor1, 0x12); //floor and impassable
> and I think that it is reversed, you should ClearSurfaceFlags(..., 0x5) there,
> not set it. You should however SetSurfaceFlags(..., 0x5); at the end, when the
> trap resets itself. BTW, how did you come up with a value of 0x12 ?
> Floor (0x1) + Impassable (0x4) = 0x5, isn't it ?
That was what I thought the first time. I tried that, and then it didn't work. Then I began thinking, "Well, what if I'm wrong about counting the flags? Maybe they're like the respawn masks." So I went in and set bits 1 and 4 and then converted to Hex and got 12. I did all the other numbers the same way and stuff starting happening but in reverse order, so I thought may I was right. I also thought I was right because how would the engine know which flags you added together to get 0x5. Or at least that was my thought at the time. Let me go back and redo this in this format. I was doing it right in the first place! grrr.... That makes me mad when I think of all the time I have spent screaming over this and why it wasn't working!!!
> A few remarks btw :
> You don't have to change the light mode (that generates 4 useless messages
> everytime the trap is sprung PER CLIENT CONNECTED !) since the face disappears
> totally (GEO 0 = not drawn implies that the light mode is irrelevant).
Thanks for the tip. That will cut down on lag a bit.
> Finally, this script SCREAMS to be converted to SendTrigger()/trigger: !
> You are sending 15+ network messages per client connected per trap use...
I may do that once I get this thing to work without the SendTrigger(). I'll work with SendTrigger() in the Jailbreak cogs (which are almost finished and ready for beta), so that will allow me to go back and look at this one. Thanks again, CK.
-Osan`gar