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 → Checksum Related Discovery
Checksum Related Discovery
2005-06-13, 5:48 PM #1
I doubt any of you do anything checksum related, but I thought I would post this anyway.

When working on my template project, I discovered that in a bunch of cogs, the following happened:

When breaking down a line into basic objects, and putting the broken down code right underneath the commented out equivilent, it passes checksum just fine. However, if you try to move the broken down equivilent of the commented line to somewhere else, like at the end of a cog, such as with all the other broken down lines from other sections of the cog, it checksums.

It's seemingly random, too. Take a cog like weap_concrifle.cog, you can move broken down code around anywhere. But take item_irgoggles.cog for example, when breaking down certain lines in the activated: section, I had the problem.

I was all done with my templates and then I discovered this, sheesh. Just more work :rolleyes:

Oh well, there are only a few here who can follow what I just said. I hope it made sense.

ReT
2005-06-13, 6:02 PM #2
Scrounge around for my "toolbox" sometime. I have the Event Horizons (what I named the uneditable areas) commented in for all major COGs. In some COGs, the's a point sort of near the end of a COG where stuff can't be moved from above to below that point or vice versa even though it can be modified heavily within their own area.

The problem you encountered is the Event Horizon occurs within a set of curly brackets, which means you can edit the code up until the closing curly bracket, but cannot move stuff into or out of that set of curly brackets. Basically, there's a seperate character count inside the brackets and outside in the rest of the COG. In my toolbox I labeled these as the Event Horizon and Effective Event Horizon.

QM

Edit: Here's my personal version of item_ irgoggles.cog. Take note of the Event Horizon and Effective Event Horizon.
Code:
# Jedi Knight Cog Script
#
# ITEM_IRGOGGLES.COG
#
# INVENTORY SCRIPT - Gravity Boots
#
# [QM]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing       player                           local
int         effectHandle=-1                  local

message     activated
message     pulse
message     killed

sound       goggleActivate=activate01.wav    local
sound       goggleDeactivate=deactivate03.wav local

message     startup
message     newplayer

flex        cost=-25                         local
flex        modone=150                       local
flex        modtwo=-214.3                    local

int         negone=-1                        local

end

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

code

activated:
   player = GetSourceRef();

   if(GetInv(player, 41))
   {
      if(IsInvActivated(player, 41) == 0)
      {
         if(GetInv(player, 13) > 0)
         {
            // Print("IR Goggles ON");
            jkPrintUNIString(player, 254);
            SetInvActivated(player, 41, 1);
            PlaySoundThing(goggleActivate, player, 1.0, -1, -1, 0x80);
            effectHandle = newColorEffects(0, 1, 0, 0, 0, 0, 0, 0, 0, 1.0);
// Event Horizon
            call make;
            SetPulse(0.1);
            Return;

            1, 1;
         }
         else
         {
            // Print("IR Goggles Out Of Power");
            jkPrintUNIString(player, 256);
            PlaySoundThing(goggleDeactivate, player, 1.0, -1, negone, 0x80);
            Return;
         }
      }
      else
      {
         // Print("IR Goggles OFF");
         jkPrintUNIString(player, 255);
         PlaySoundThing(goggleDeactivate, player, 1.0, negone, negone, 0x80);
raze:
         ClearPhysicsFlags(player, 0xB0);
         SetPhysicsFlags(player, 0x800);
         SetInvActivated(player, 41, 0);
         SetPulse(0);
         Return;

info:
         player = GetLocalPlayerThing();
         Return;

         1, 1, 1;
      }
   }
// Effective Event Horizon
   Return;

# ........................................................................................

   1, 1;
   Return;

# ........................................................................................

make:
   ChangeInv(player, 13, cost);
   ClearPhysicsFlags(player, 0x800);
   SetPhysicsFlags(player, 0xB0);
   SetInvActivated(player, 41, 1);
   Return;

# ........................................................................................

pulse:
   if(!GetThingAttachFlags(player))
   {
      SetThingRotVel(player, VectorSet(
         VectorY(GetThingThrust(player)) * modone,
         VectorY(GetThingRotVel(player)),
         VectorX(GetThingThrust(player)) * modtwo
      ));
   }
   else
   {
      SetThingRotVel(player, VectorSet(0, VectorY(GetThingRotVel(player)), 0));
   }
   Return;

# ........................................................................................

startup:
   call info;
   call raze;
   Return;

# ........................................................................................

newplayer:
   if(IsInvActivated(player, 41))
   {
      call raze;
   }
   Return;

# ........................................................................................

killed:
   call info;
   if((GetSenderRef() == player) && IsInvActivated(player, 41))
   {
      call raze;
   }
   Return;

end
2005-06-13, 7:03 PM #3
This is the one I finished and got to pass checksum this morning, but only after figuring out the unmovable sections, as I call them.

Code:
# Goggles Template for the Cog Template Pack      
# Private Release v1.0                            
# 6/12/2005 by EAH_XxHeReTiKxX               

# Jedi Knight Cog Script
#
# ITEM_IRGOGGLES.COG
#
# INVENTORY SCRIPT - IR Goggles
#
# [CYW & YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing       player
int         effectHandle=-1

message     activated
message     pulse
message     killed

sound       goggleActivate=activate01.wav
sound       goggleDeactivate=deactivate03.wav

end

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

code

activated:
   player = GetSourceRef();

   if(GetInv(player, 41))
   {
      if(IsInvActivated(player, 41) == 0)
      {
         if(GetInv(player, 13) > 0)
         {
            // Print("IR Goggles ON");
            jkPrintUNIString(player, 254);
            SetInvActivated(player, 41, 1);
            PlaySoundThing(goggleActivate, player, 1.0, -1, -1, 0x80);
            effectHandle = newColorEffect(0, 1, 0, 0, 0, 0, 0, 0, 0, 1.0); // UNTOUCHABLE
//            EnableIRMode(0.3, 1);
-1; 1; 1; // Moving Causes Checksum
//            SetPulse(1.5);
-1; 1; // Moving Causes Checksum
         }
         else // UNTOUCHABLE
         {
            // Print("IR Goggles Out Of Power");
//            jkPrintUNIString(player, 256);
-1; 1; 1; // Moving Causes Checksum
//            PlaySoundThing(goggleDeactivate, player, 1.0, -1, -1, 0x80);
-1; -1; -1; -1; -1; 1; // Moving Causes Checksum
         }
      }
      else // UNTOUCHABLE
      {
         // Print("IR Goggles OFF");
//         jkPrintUNIString(player, 255);
 -1; 1; 1; // Moving Causes Checksum
//         SetInvActivated(player, 41, 0);
           -1; -1; -1; // Moving Causes Checksum
//         if(!IsInvActivated(player, 23)) DisableIRMode();
//         PlaySoundThing(goggleDeactivate, player, 1.0, -1, -1, 0x80);
//         if(effectHandle!=-1) freeColorEffect(effectHandle);
-1; -1; -1; -1; -1; -1; -1; -1; -1; -1; -1; -1; -1; 1; 1; // Moving Causes Checksum
         SetPulse(0); // UNTOUCHABLE
      }
   }

//   Return;

# ........................................................................................

pulse:
//   ChangeInv(player, 13, -5);
//  if(GetInv(player, 13) == 0)
   {
      // Print("IR Goggles Out Of Power");
//      jkPrintUNIString(player, 256);
//      SetInvActivated(player, 41, 0);
//      PlaySoundThing(goggleDeactivate, player, 1.0, -1, -1, 0x80);
//      if(!IsInvActivated(player, 23)) DisableIRMode();
//      if(effectHandle!=-1)
//         freeColorEffect(effectHandle);
//      SetPulse(0);
   }

//   Return;

# ........................................................................................

killed:
//   player = GetLocalPlayerThing();
//   if(GetSenderRef() != player) Return;

//   if(IsInvActivated(player, 41) == 1)
   {
//      SetPulse(0);
//      SetInvActivated(player, 41, 0);
//      DisableIRMode();
//      if(effectHandle!=-1) freeColorEffect(effectHandle);
   }
//   Return;

# ........................................................................................

Leftovers:
-1; -1; -1; -1; -1; -1; -1; -1; -1; -1; 
-1; -1; -1; -1; -1; -1; -1; -1; -1; -1;
-1; -1; -1; -1; -1; -1; -1; -1; -1; -1; 
-1; -1; -1; -1; -1; -1; -1; -1; -1; -1; 
-1; -1; -1; -1; -1; -1; -1; -1; 1; 

end


So as you can see, everything untouchable is left alone, everything removable that can be moved is commented out and it's broken down equivilent is places in the Leftovers section.

Question, areas with lines that can be edited, or removed/broken down, you call Event Horizons, and areas that can be entirely removed and their equivilent placed anywhere you call Effective Event Horizon? Do I have that right?

I'm going to take a look at your toolbox, that will be a huge help.

What I had done is I took all the common cogs and gone section by section, line by line, commenting out and breaking down. When I finished all of them, I had a lot of spacing and all other kinds of crap so I extracted fresh cogs, commented out the removable areas I had figured out, and put all the objects at the end of the cog, only to find out that it failed checksum.

ReT
2005-06-13, 9:32 PM #4
I call the very last line that absolutely cannot be edited/reduced the Event Horizon. The Effective Event Horizon only occurs if the Event Horizon is inside of curly brackets. The Effective Event Horizon is when you get outside the curly brackets that affect the checksum.

Here's my version of a template for the irgoggles file. I made this 10 minutes ago (I mention this so you wouldn't ask if I had templated all the COGs already ^_^). My style is a little different than yours; the main rules I follow are always have the messages listed in the symbols section (that can't be striped down) down in the code section (activated, pulse and killed in this case), and always make sure there's a "Return;" before the "end" in the code section. If at all possible I reduce everything down to 1. If I wind up with a half character left, I change it to a "Return;" and slap it at the end of the 1's. If I have to split a 1 into two halves to add a "Return;" before the "end" of the code section, I use the leftover half as a "Return;" to contain the messages as a seperate little section (otherwise, I just put the displaced messages at the end of the large clump of 1's just before the final "Return;"). I break the 1's up into lines of 20.

After the Event Horizon, EVERYTHING is reducible (so long as they aren't moved outside of the curly brackets, and they aren't an "else" that's connected to an "if" that occurs before the Event Horizon). You have a few things marked as untouchable that actually aren't.
Code:
# Jedi Knight Cog Script
#
# ITEM_IRGOGGLES.COG
#
# INVENTORY SCRIPT - Template
#
# [QM]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing       player                           local
int         effectHandle=-1                  local

message     activated
message     pulse
message     killed

sound       goggleActivate=activate01.wav    local
sound       goggleDeactivate=deactivate03.wav local

end

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

code

   player = GetSourceRef();

   if(GetInv(player, 41))
   {
      if(IsInvActivated(player, 41) == 0)
      {
         if(GetInv(player, 13) > 0)
         {
            // Print("IR Goggles ON");
            jkPrintUNIString(player, 254);
            SetInvActivated(player, 41, 1);
            PlaySoundThing(goggleActivate, player, 1.0, -1, -1, 0x80);
            effectHandle, X(0, 1, 0, 0, 0, 0, 0);
// Event Horizon
            1, 1, 1, 1, 1, 1, 1, 1, 1;
            Return;
         }
         else
         {
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
         }
      }
      else
      {
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
      }
   }
// Effective Event Horizon

# ........................................................................................

   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
   Return;

activated:
pulse:
killed:
   Return;

end
QM
2005-06-14, 1:48 PM #5
Hm I think I understand what you mean.

For my templates I commented out lines that can be removed, so that it can be better seen what is removable or what isn't. If you code a cog and you don't always want to remove a lot of code, it's nice to be able to see what you can take out easily.

I like your system of categorizing Event Horizons/Effective Event Horizons.

I haven't touched any of the symbols in my templates, I figure the average person probally won't be doing too much in there, and can add all the userx messages he/she wants.

I did all the item, force, weapon, and kyle.cog cogs.

Too bad I didn't realize certain code can't be moved out of a curly bracket section, I was looking around for a long time trying to figure out what was going on, and then I realized, duh, although you can break code down you can't nessecarily move it out of an if() statement. I'm going to have fix about 15 cogs. Fortunately more than half of the templates I did(about 30-40, I forgot) did not have areas that failed checksum if you moved around code, even if it wasn't untouchable.

I thought about ending all my cogs with a Return; before end, but I didn't think it really made a difference. I break down as much stuff as I can to -1(same as -x) which is 1.5 objects.

Now l will always make sure I have a Return before end. :)

ReT
2005-06-14, 2:02 PM #6
I was glad to see you using -1 instead of -x. My reasoning is 1 is a fixed value while x is a variable, and I'd like to think 1 takes a tiny bit less processing by JK than x does. My reasoning for breaking everything down into a bunch of 1s rather than -1s (I used to do -1s actually) is it's much easier to count how many whole characters you have to work with. A row of ten -1s would be 15 characters, but that takes more thinking to realize than a row of ten 1s where you can count pretty quickly what you have to work with. There's also the chance that -1, -1 takes up more processing time than 1, 1, 1, but I have no evidence to support that either.

The only place I use X() is if I can change the name of a verb but can't move it. This way I can disable it but leave it obvious that it's semi-usable for later use.

The place in a COG where you can't move code from above to below a certain point or vice versa is the "stop_power:" line in quite a few Force Power COGs. I label this as a "Weird Event Horizon" in the COGs in my "toolbox" project. Speaking of which, I need to submit my newest version to the JK Hub sometime...

QM
2005-06-14, 2:10 PM #7
A slightly off topic question: Is there any way to make something like Seifer's weapon cog pass checksum? Otherwise we have to redo a LOT of weapon models in order to make it so our mod can be used with the original JK.

JediKirby
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2005-06-14, 2:11 PM #8
I miss checksum passing, it was my favorite puzzle.
Now I just play tetris :(
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2005-06-14, 2:31 PM #9
Quote:
Originally posted by jEDIkIRBY
A slightly off topic question: Is there any way to make something like Seifer's weapon cog pass checksum? Otherwise we have to redo a LOT of weapon models in order to make it so our mod can be used with the original JK.

JediKirby

Weapon 3 in my Tool Box has a checksum passing Seifer'd internal model. I'll update my Tool Box at the hub later today as I don't even remember what version is there now and I may have made improvements.

It's doable, and not even that messy. If you load a saved game, you won't have an internal model until you re-equip your weapon, but that's not even that bad of a glitch.

I didn't use the exact same style in the aforementioned COG (the gun doesn't align with your PoV except when you fire) but it can be made to do so. Finding room for the waggle animation code might be asking a little much though.

QM
2005-06-14, 2:32 PM #10
Quote:
Originally posted by Quib Mask
I was glad to see you using -1 instead of -x. My reasoning is 1 is a fixed value while x is a variable, and I'd like to think 1 takes a tiny bit less processing by JK than x does.

Hmm...well, I've never thought about it that way, I guess your right.

I can see why you would use 1 instead of -1, but the little extra math dosen't bother me.

Now you say you use X() if you can change the name of a verb but can't move it? Why change the name of the verb instead of breaking it down entirely? Wouldn't it work just as well?

Quote:
The place in a COG where you can't move code from above to below a certain point or vice versa is the "stop_power:" line in quite a few Force Power COGs.

Yeah, I'm pretty sure that's true for most of them, I don't have them handy on this computer but I'll take another look at that.

I would love to see your latest version of Toolbox.

So you have not made your own templates?

ReT
2005-06-14, 2:37 PM #11
Quote:
Originally posted by ReT
Now you say you use X() if you can change the name of a verb but can't move it? Why change the name of the verb instead of breaking it down entirely? Wouldn't it work just as well?

In a few COGs, you can break down part of the line one above the Event Horizon, but can't strip it down entirely. Sometimes you can modify the verb, but can't edit/move all the values that are within the verb's parenthesis. Look at the line above the Event Horizon in the irgoggles COG template I posted. It look like:
effectHandle, X(0, 1, 0, 0, 0, 0, 0);

effectHandle cannot be changed/moved.
0, 1, 0, 0, 0, 0, 0 cannot be changed or moved outside of the X() verb's parenthesis but X() itself can be changed; just not moved.

This sort of thing happens pretty rarely.

I DO NOT have my own set of templates. I've labeled the Event Horizons in all the COGs in my Tool Box though. They're 99% accurate; I might be able to snag 1 or 2 loose objects from the line above the Event Horizon, but didn't double check that thoughroughly in every COG.

QM
2005-06-14, 2:43 PM #12
Well when I went through and did my templates, I commented out and saw if the broken down equivilent would pass checksum or not. If it didn't, then I would just label it as untouchable.

It seems kind of pointless to want to change the X verb you are talking about, right? I can't think of any reason to change it, and even if you could, what verb has (0, 1, 0, 0, 0, 0, 0); params besides newColorEffect()?

Anyway on my templates, I could kind of tell on most of them when I got to a certain point and started encountering a lot of untouchable lines, that probally everything thereon up was untouchable.

I'll be sure to send you my templates when I finish. ;)

ReT
2005-06-14, 2:49 PM #13
Quote:
Originally posted by ReT
It seems kind of pointless to want to change the X verb you are talking about, right? I can't think of any reason to change it, and even if you could, what verb has (0, 1, 0, 0, 0, 0, 0); params besides newColorEffect()?

I THINK (I haven't double checked this) if you had say SetPulse(0, 1, 0, 0, 0, 0, 0); it'd be the same as SetPulse(0); because a 0 is at the end of the list of values inside the verb. So if you wanted to save 1.5 objects by converting X() to SetPulse() and then wanted, say, a pulse of 0.5, you'd change it to:
SetPulse(0, 1, 0, 0, 0, 0, 0, 0.5);
You'd tack the 0.5 on the end since you can't edit the 6 zeroes or the 1 inside the verb already.

Again, I haven't done testing in years on this sort of thing; I'm pretty sure JK reads right to left when passing variables to verbs, and since something like SetPulse() only takes 1 variable, it'd use the far right one. The first 7 values would be ignored.

QM
2005-06-14, 2:54 PM #14
Ooh, interesting discovery.

You would have to be pretty damn tight to want to do that though, it dosen't seem real logical to do that because there are what, 250 possible cogs to hack in Res2.gob, and any one of them could be a potential hack through the use of triggers or message sending or w/e. At least, I think, I might be wrong on that.

Btw if you don't have an extra computer and you ever need to test for checksum, just use the dedicated server.

Are you going to upload your toolbox soon?

ReT
2005-06-14, 3:40 PM #15
Quote:
Originally posted by ReT
Btw if you don't have an extra computer and you ever need to test for checksum, just use the dedicated server.

Are you going to upload your toolbox soon?

I appreciate that. I have a 5 computer network at home though so I'm fine in that regard.

I've uploaded it to the JK Hub, it'll just be a bit before it's approved I think. Don't download the "Toolbox" or "Toolbox0" (notice they're 1 word) as they're pretty old. Wait until "Tool Box" and "Tool Box (with 3do addon GOB)" get approved. They'll be in the resource and addon sections, respectively.

QM

P.S. - I actually haven't been able to connect to your dedicated server. =( I'll try again later as some classic JK multiplayer sounds fun, and aside from the occasional cheaters, the thread in the discussion forum sounds like there's been some great action.
2005-06-14, 4:06 PM #16
I think I'm going to make a page with possible network problems and solutions. Did you try the direct IP, and are you able to connect to other games just fine?

ReT
2005-06-14, 4:19 PM #17
Yes and yes. I'm not behind a router or hardware firewall either and can go to your normal website just fine. I'll give it another go when I have the chance, as I hadn't restarted the computer I was using in a week, so maybe that was the issue (as others had reported).

QM
2005-06-14, 6:29 PM #18
Wow, your noting of Event Horizons and Effective Event Horizons is fantastic. This helps me a ton, thank you very much.

ReT

↑ Up to the top!