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 → Small little cog.
Small little cog.
2002-06-28, 2:59 PM #1
Don't you just hate it when all the Imperial officers and commandos look alike? Hate it when you have to make new templates for everyone and add them in seperatly?

I have a solution to your problems. With this cog, all you have to do is skin, and you will have random people (to a certain degree [http://forums.massassi.net/html/wink.gif] ). You could also modify this to do random enemies. So its not all the same. [http://forums.massassi.net/html/cool.gif]

Here it is. I'm going to release this on Massassi.
Code:
# Jedi Knight Cog Script
#
# PEOPLE.COG
#
# Goes through the level, searching for the base model, and picks every thing with that model
# and changes it to one of five models, one of which being the default.
#
# [DP]
#
# Good for IO and IC, that way they don't all look the same.


symbols
model       base
model       other1
model       other2
model       other3
model       other4
int         i                               local
int         j                               local

message     startup

end

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

code
   Startup:
   For(i=0; i<=GetThingCount(); i=i+1)
   {
      j = rand * 4;
      If((GetThingModel == base) && (j >= 1)) SetThingModel(i, other[j]);
   }
   Return;
end
[http://forums.massassi.net/html/biggrin.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

[This message has been edited by Descent_pilot (edited June 28, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-06-28, 5:01 PM #2
Now, in the official Massassi tradition, we will all ignore this topic and let it die... [http://forums.massassi.net/html/wink.gif]

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-06-28, 5:47 PM #3
So mean. *sighs and looks up, wondering why the world can't be kinder*

------------------
The Sniper Missions. Current project, The Sniper Missions
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-06-28, 6:28 PM #4
Ive posted cogs before.... Nobody ever responded.... [http://forums.massassi.net/html/frown.gif]

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-06-28, 9:17 PM #5
Probally because there's no pictures to drool over.

My Comment: Nice, it's good to see some new cogs being submited to massassi.
2002-06-29, 4:43 AM #6
You really should use Cogwriter or Parsec to check your syntax. And you should always
test a cog before you submit it. In this case, you made some bad syntax errors.

Here's the cleaned code:
Code:
# Jedi Knight Cog Script
#
# PEOPLE.COG
#
# Goes through the level, searching for the base model, and picks every thing
# with that model and changes it to one of five models, one of which
# being the default.
#
# [DP]
#
# Good for IO and IC, that way they don't all look the same.
#==============================================================#
symbols

model     base
model     other0
model     other1
model     other2
model     other3

int       i         local
int       j         local

message   startup

end
#==============================================================#
code
#------------------------------------------------------
startup:
	for(i = 0; i <= GetThingCount(); i = i + 1)
	{
		j = Rand() * 4;
		if(GetThingModel(i) == base) SetThingModel(i, other0[j]);
	}

Return;
#------------------------------------------------------
end


  • Rand should be Rand()
  • GetThingModel should be GetThingModel(i)
  • other should have been other0.


Now, other0[0] will refer to other0 in the symbols. So that condition you had of
(j >= 1)would not allow the first model to be used. And there are only four other0
models there, not five.

So test this cog in a level before submitting it. It is a good idea, and
Massassi does need new cogs to be submitted. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited June 29, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-06-29, 5:04 AM #7
Perhaps I should submit my "Ultimate door cog" and "Universal door cog"... The latest versions, of course.. [http://forums.massassi.net/html/smile.gif]

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-06-29, 5:58 AM #8
Actually, the reason that no one replies is that they don't want to be caught taking the code. [http://forums.massassi.net/html/wink.gif]

Interesting idea, even more interesting implentation.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-06-29, 10:03 AM #9
I did check it, it worked, after a bit of tinkering. Forgot to update this one. [http://forums.massassi.net/html/redface.gif] Thanks for the Double Check SaberMaster.

This is as good of time as any to argue about the 0 thing. If there's no 0 in the symbols part, there can't be a 0 in the code. It works, I've done it both ways. Ex.
Code:
symobls
thing0
thing1

code
Thing0

or
Code:
symbols
thing
thing1

code
thing


------------------
The Sniper Missions. Current project, The Sniper Missions

[This message has been edited by Descent_pilot (edited June 29, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-06-29, 2:47 PM #10
There's not really any argument there, Pilot. I put the zero in because it's a common convention to put the array access number after the variable name.

Cog's arrays are a type of 'variable offset.' For example:
Code:
int red
int green
int blue

red[0] refers to red. red[1] refers to green. green[1] refers to blue. The access number is like an offset from the given variable.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-06-30, 2:21 PM #11
Never thought of it that way. [http://forums.massassi.net/html/redface.gif]
Here's the updated cog.
Code:
# Jedi Knight Cog Script
#
# PEOPLE.COG
#
# Goes through the level, searching for the base model, and picks every thing with that model
# and changes it to one of five models, one of which being the default.
#
# [DP]
#
# Good for IO and IC, that way they don't all look the same.


symbols
model       base
model       other
model       other1
model       other2
model       other3
int         i                               local
int         j                               local

message     startup

end

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

code
   Startup:
   For(i=0; i<=GetThingCount(); i=i+1)
   {
      If(GetThingModel(i) != base) Return;

      j = rand() * 3;
      If(j < 4) SetThingModel(i, other[j]);
   }
   Return;
end

Much nicer, but one problem with this, it always returns the base model. Normally its j = rand * 4, but even after I changed it, I still get the same problem. [http://forums.massassi.net/html/frown.gif] There is another cog that does work, but it doesn't get the same effect I want.
------------------
The Sniper Missions. Current project, The Sniper Missions

[This message has been edited by Descent_pilot (edited July 01, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-06-30, 5:34 PM #12
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
There's not really any argument there, Pilot. I put the zero in because it's a common convention to put the array access number after the variable name.

Cog's arrays are a type of 'variable offset.' For example:
Code:
int red
int green
int blue

red[0] refers to red. red[1] refers to green. green[1] refers to blue. The access number is like an offset from the given variable.

[/b]</font>


Aren't technically all arrays just that? I know that an array in c++ is nothing else than a pointer to the first element and an offset...

And GBK, what about uploading a small demo level that shows the working of your showcased cogs? Not everyone here is able and has enough endurance to follow your code.
It could also prove as a waste of time, of course...


------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-07-01, 11:04 AM #13
Pilot:
Code:
j = rand() * 3;


With this code, j will have a value of 0 to 3. When JK expects an integer and you give a flex, it will ignore the decimal portion. So 0.1 becomes 0. 3.9 becomes 3. There is only about a 1/75,000 chance of j ever being exactly 0 or 3, so other[3] would never be used. You should change that line to:

Code:
j = rand() * 4;


That way, there's only a small chance that j will ever be 4. And if it is, the condition of (j < 4) will prevent any errors.

Zagibu:
Quote:
<font face="Verdana, Arial" size="2">Aren't technically all arrays just that? I know that an array in c++ is nothing else than a pointer to the first element and an offset...</font>


They're not the same. In compiled languages, a variable is either in an array or not. You don't have a single list of variables as in cog.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-01, 12:12 PM #14
I understand Flexs to Int. The problem is, it won't give any of the 'other' models. It always gives the base model.

------------------
The Sniper Missions. Current project, The Sniper Missions

[This message has been edited by Descent_pilot (edited July 01, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-01, 12:39 PM #15
Hmmm, ok.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-07-01, 2:48 PM #16
I just tested this cog, and it works correctly:

Code:
# Jedi Knight Cog Script
#
# PEOPLE.COG
#
# Goes through the level, searching for the base model, and picks every thing with that model
# and changes it to one of five models, one of which being the default.
#
# [DP]
#
# Good for IO and IC, that way they don't all look the same.
#==============================================================#
symbols

model     base
model     other0
model     other1
model     other2
model     other3

int       i         local
int       j         local

message   startup

end
#==============================================================#
code
#------------------------------------------------------
startup:
	Sleep(1);
	for(i = 0; i <= GetThingCount(); i = i + 1)
	{
		j = Rand() * 4;
		if(GetThingModel(i) == base && j < 4) SetThingModel(i, other0[j]);
	}

Return;
#------------------------------------------------------
end


The sleep() is added because JK has trouble doing some things on startup when you restart a level from the escape menu.

If the cog still won't work, check the level settings for the cog and make sure the models are correct. There's nothing wrong with the cog.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-01, 3:11 PM #17
I don't get this, I just don't.

Ran it through the first time. Worked, but the player model was changed.Base everytime after a restart, player model still changed.

Moved verbs around, didn't do s**t.

Did what you said to do agian, worked perfectly every time.

I don't get it. *Walks off away wondering. Then Sleeps()*

------------------
The Sniper Missions. Current project, The Sniper Missions

[This message has been edited by Descent_pilot (edited July 01, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!