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 → Interesting pair of discoveries in Cog yesterday..
Interesting pair of discoveries in Cog yesterday..
2001-07-02, 4:21 PM #1
At least, I *think* they're discoveries [http://forums.massassi.net/html/smile.gif]

I messed up in my kyle.cog and did this..
in init_kyle_multi: i have the following line..

if(pmodel)
{
}
else
{
pmodel=GetThingModel(player);
}

So my first playermodel was a Bwing.. but kyle.cog thought I was a TIE Fighter (thats my ky.3do).. however.. the weapons cogs thought I was a Bwing.

Now for the discovery: I exited the game and tried the Assault Gunboat model...
....and two of the weapons that the Gunboat and Bwing both can use (they fire different depending on the model)...

...were firing as if the Gunboat were a Bwing.

"WHAT THE @#$*?" But then it occured to me...

Apparently Cog variables are NOT RESET EVEN IF YOU EXIT AN MP/SP GAME AND START ANOTHER SP/MP GAME (unless you have the cog setup in, say, Startup: to have pmodel=-1;, or in symbols pmodel=-1).


Interesting, no?

Well, there's more. As per me messing with the Bwing's Eyeoffset (the bwing model is rather...well lets just say its about 6m to the left of the center of the model), I saw that the 3rd person camera apparently is fixed at a certain distance away from the eyeoffset. This coulda been found out before, but I don't remember hearing any of it.
2001-07-02, 4:48 PM #2
I also noticed this about two weeks ago. I made a weapon cog that tells JK that after 1 shot, the gun could not be selected.

Started a second game; no weapon selection.
Kinda bugged me, though. It only goes away after quitting JK. [http://forums.massassi.net/html/wink.gif]


Jedi_slayer_1
2001-07-02, 5:44 PM #3
Dynasty, if you wanna fix that, try looking at Spork 1.2. The Spork weapon (its the EMP thing) is like that, but you get a new one when you die or restart the lvl, or start a new one.

I bet this is similar to how you can use the slowmo code in MP, where you turn it on in SP, then goto MP w/o exiting.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-02, 7:05 PM #4
Yeah. I wasn't really trying to do it, I just forgot to finish the cog before I tested it [http://forums.massassi.net/html/wink.gif].

I tried it a second time, and was quite suprised.

Jedi_slayer_1
2001-07-03, 12:26 AM #5
Sorry to burst your bubble , but both of those *discoverys* were already known.
2001-07-03, 4:08 AM #6
By who? And then, why weren't they ever made public?
2001-07-03, 5:02 AM #7
Agree.

Is that *that* widely known?
I didn't know.

You always look smart Seifer.

------------------
http://millennium.massassi.net/ - Millennium
2001-07-03, 5:52 AM #8
Well, Jepman posted the eyeoffset thing in the news, didn't he?
2001-07-03, 11:35 AM #9
Yes Aglar ... True ..... Elven/Hideki .... I found that out in cog along time ago. It can become a problem sometimes ... it's not widley known. But I found out about it my self quite a while ago while working on my bots. Heck I think there was a problem about it just a while back where a person's cog woulden't reset until he went out of the whole game.
2002-02-11, 4:36 PM #10
hmm..

<dredges up old topic, for benifit of people who didn't see it, and for adding another widely unknown oddity of Cog>

This one's rather funny.. I first noticed it when someone wanted me to fix their cog (one of the guys that helped to do spork).

I got the cog fixed, and he said it worked, but there was something strange about it.. a rather essential feature of the cog was .. this

player=GetLocalPlayerThing();

Well, thats not odd, until you look at the symbols section..

.. player wasn't declared.

ie, there was not a:
int player local

or a:
thing player local

Nothing. Except the cog worked. Which apparently means cog supports some kind of global variable system.

Right now I'm working with Brian and oS to get JKA working, and the persistant variables are a crucial part of the code. However, because of the global variable system which apparently exists, the names need to be unique.

Just a heads up.
-Greven
2002-02-11, 5:29 PM #11
I dicsoved this glitch also when making a few menu cogs. When making the team select cog the player seemed to choise the player team I had previously choosen without me telling it to. But after closing jk it worked fine again.
Team Battle.
2002-02-11, 5:34 PM #12
Btw this is also the reason why when you host a game on a map, then quit to main menu then host it again you spawn in a different position.
Team Battle.
2002-02-11, 6:54 PM #13
Evil_Greven - The reason your cog still worked even if player wasn't defined is because the players thing number in levels is ussally 0 .... and an undefinded int from a verb comes back as a 0 ...

BTW I've been hearing statments about people saying that you don't need to define stuff in the symbols section, if you have it defined in another cog or something.... I dunno.
2002-02-12, 5:04 AM #14
It has been my expiriance that you can get away with it. Although, for the sake of clean code, and a measure of saftey, one should not.


Try this:

Code:
#02/2002 GBK
Symbols
Message Startup
End
Code
Startup:
A0=1;
A1=0.01;
A2=1.001;
Sleep(2.0);
For(I=0;I<3;I=I+1) {
Printflex(A0); }
Stop;
End



Now, test that cog in a new level. With no other cogs. It works, even though I did not define A0-2, or I in the symbols section.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2002-02-12, 5:11 AM #15
If you delcare the variable, like this:

A = 155;

Then test it,

Printint(A);

It will return 155.


I believe it is possible to declare variables post-symbol. (as the above cog CLEARLY indicates)


But, if you address a variable:

Teleportthing(Player, Ghost_pos);

When that position does not exist, JK will look through all of the other cogs in that JKL, loooking for that variable. If it doesnt find a match, it declares it as '0'.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2002-02-12, 6:30 AM #16
>I believe it is possible to declare variables post-symbol.

In much of the testing for my reference, I used variables that were not defined in the symbols, and I had no problems with them.

>JK will look through all of the other cogs in that JKL, loooking for that variable.

I have tested something like this, and I've not been able to make it work. Could you post some code demonstrating this?

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-02-13, 10:00 PM #17
GBK, you really like arrays, don't you? [http://forums.massassi.net/html/smile.gif]
2002-02-14, 4:46 AM #18
It could be that, or it could be that GBK was showing in the example that even array variables, which will crash if used incorrectly, don't have to be defined.


Well as long as we're on the subject, I have a discovery: JK not only allows new variables to be created in the code section, it allows a variable's symbol type to be changed. So if you defined an int in the symbols and assign it a vector value in the code, the int will become a vector. PrintInt() will not be able to print the value, but PrintVector() can.

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-02-14, 5:01 AM #19
Arrays in JK are not arrays at all. The bracketed integer marks the offset from the variable before the brackets. This is clearly demonstrated in force_saberthrow.cog:

These are the variables:
Code:
template    lightsaber=+force_saber          local
template    blueSaber=+fsab_blue             local
template    greenSaber=+fsab_green           local
template    yellowSaber=+fsab_yellow         local
template    orangeSaber=+fsab_orange         local
template    redSaber=+fsab_red               local
template    dredSaber=+fsab_dred             local
template    purpleSaber=+fsab_purple         local


...and this is how they are referenced:
Code:
FireProjectile(player, lightsaber[saberIndex], saberSound, 24, '0 0 0', '0 0 0', 1.0, 0, autoAimFOV, autoAimFOV);
Dreams of a dreamer from afar to a fardreamer.
2002-02-14, 5:06 AM #20
And a little thing about script parsing: the engine parses cogs only while a level is loading. Meaning that you can edit cogs while still in-game, and when you reload a level the changes will take effect. This works for all cogs except inventory cogs referenced in items.dat, those are parsed while the game loads.
Dreams of a dreamer from afar to a fardreamer.

↑ Up to the top!