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 → Simple cog error
Simple cog error
2002-02-25, 2:21 PM #1
it is prolly some little error that i just looked over but then there is the occasion when my cogs are completely wrong. HOpe you guys can find my error. Thanks

Code:
# Jedi Knight Cog Script
#
# FORCE_SEEING.COG
# 
# [Scortar]
# This Cog is Not supported by LucasArts Entertainment Co

symbols

thing        victim                             local                         
thing        player                             local     
int          x                                  local                         
int          maxX                               local                         
int          damage=10000000000000000           local                         

message      activated                                                        
message      deactivated                                                      
message      pulse                                                            
end                                                                           

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

code

activated:
SetInvActivated(player, 23, 1);
player = GetLocalPlayerTHing();
x = 0;
SetPulse(.5);
return;

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

pulse:
PrintInt(maxX);
PrintInt(x);
maxX = GetThingCount(GetThingSector(player));
If (x == 0);
{
victim = FirstThingInSector(GetThingSector(player));
x = x + 1;
DamageThing(victim, damage, 0x2, player);
}
else
if (x != 0 && x <= maxX);
{
victim = NextThingInSector(GetThingSector(player));
x = x + 1;
DamageThing(victim, damage, 0x2, player);
}
else
if (x > maxX)
{
x = 0;
}
return;

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

deactivated:
SetInvActivated(player, 23, 0);
return;
end
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-26, 3:18 AM #2
oh yeah the cog isn't working at all so the error is prolly with my activated message
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-26, 4:18 AM #3
Since Im in a hurry, I cant realy examine the cog, but I do see one thing wrong: 'Getthingcount()' gets the thing count for the entire level. 'Getsectorthingcount()' counts things in sector..

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-02-26, 4:58 AM #4
thanks that will help i wrote this one whithout jkspecs so that might be part of it. ok i'll fix that and i think i can figure out my other problem
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-26, 6:34 AM #5
There's a lot wrong with that cog... [http://forums.massassi.net/html/frown.gif]

NextThingInSector() takes a thing parameter, not a sector. It will return the thing with the next lowest thing number.

Setting an integer that high is stupid. It's too large to be a valid integer anyway.

Your code would be a lot easier to debug if you indented it properly. It's a mess as it is.

Never end a conditional statement with a semicolon. That will end the condition before JK checks to see if there is any associated code.

Try fixing those problems and see what happens. [http://forums.massassi.net/html/wink.gif]

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-02-26, 6:38 AM #6
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
...easier to debug if you indented it properly...</font>


If the man doesnt want to indent, he doesnt have to indent! I never do, and I have no difficulty debugging cogs.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-02-26, 7:04 AM #7
sorry i don't indent, and thanks for pointing out all my probs its easy for me to write code but not debug it so i always get stuck. i fixed everything and ya know what it still don't work, i want it to replace force seeing but it just won't work

Code:
# Jedi Knight Cog Script
#
# FORCE_SEEING.COG
# 
# [Scortar]
# This Cog is Not supported by LucasArts Entertainment Co

symbols
thing        victim                             local                         
thing        player                             local                         
thing        oldvictim                          local                       
int          x                                  local                         
int          maxX                               local                         
int          damage=10000                       local                         
message      activated                                                        
message      deactivated                                                      
message      pulse                                                            
end                                                                           
# ========================================================================================
code
activated:
SetInvActivated(player, 23, 1);
player = GetLocalPlayerTHing();
x = 0;
SetPulse(.5);
return;
# ........................................................................................
pulse:
PrintInt(maxX);
PrintInt(x);
maxX = GetSectorThingCount(GetThingSector(player));
If (x == 0)
{
victim = FirstThingInSector(GetThingSector(player));
oldvictim = victim;
x = x + 1;
DamageThing(victim, damage, 0x2, player);
}
else
if (x != 0 && x <= maxX)
{
victim = NextThingInSector(GetThingSector(player),oldvictim);
x = x + 1;
DamageThing(victim, damage, 0x2, player);
}
else
if (x > maxX)
{
x = 0;
}
return;
# ........................................................................................
deactivated:
SetInvActivated(player, 23, 0);
return;
end
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-26, 8:27 AM #8
NextThingInSector() has one thing parameter. Like this:
Code:
nextVictim=NextThingInSector(lastVictim);


Sorry if I was ambiguous.

>>If the man doesnt want to indent, he doesnt have to indent!

You really should indent your code. This makes it easier for other people to read and easier to debug. Indenting will also help you avoid simple syntax mistakes.

You may not like neat code, GBK, but you'll be hard-pressed to find a programmer that agrees with you. And I imagine Jon'C would have something to say about it... [http://forums.massassi.net/html/smile.gif]

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-02-26, 10:29 AM #9
according to jkspecs it has 2 parameters like
Code:
NextThingInSector(sector,lastThing);

but i'll look at it again your prolly right, the problem that i am worried about though is the code doesn't work at all. when i use force seeing nothing happens and i don't know why, do i need more that just setinvactivated()? and should i define player in a startup message or is it fine in the activated, its been a while since i've cogged trying to remember everything

this is what jkspecs has to say which is different from your DataMaster(which is pretty nice by the way)

Quote:
<font face="Verdana, Arial" size="2">
NextThingInSector() Info

Gets the next thing in sector. After FirstThingInSector finds something. Also see PrevThingInSector.

Use: Next = NextThingInSector(sector, previous thing ); Thing should be the last thing found or the return value of FirstThingInSector()

</font>


[This message has been edited by Han5678 (edited February 26, 2002).]
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-27, 4:16 AM #10
please help me
roses are red, violets are blue, I am schizophrenic, and I am too!
2002-02-27, 9:45 AM #11
Ok. I just read through your code carefully. Several things:

1) Using a loop would be a lot better than a pulse and counter.

2) SetInvActivated only makes the bin activated. That's what shows the icon. AFAIK, it has no effect on the cog.

3) It doesn't matter where you define player.

4) If you want to find targets for the player, you should be using FirstThingInView() instead of FirstThingInSector(). Your cog would not be able to find targets right in front of the player because of sector borders.

Here's a modified version of the cog:

Code:
# force_seeing.cog
#
# Damage all things in the player's view every half second.
#
# [Scortar + SM]
#======================================================================================#
symbols

thing		target			local
thing		player			local

int		damage=1000		local

flex		jku_dist=0.5		local

message	activated
message	deactivated
message	pulse

end
#======================================================================================#
code
#--------------------------------------------------------
activated:
	SetInvActivated(player, 23, 1);
	player=GetLocalPlayerThing();
	SetPulse(0.5);

Return;
#--------------------------------------------------------
pulse:
	target=FirstThingInView(player, 180, 2, 0x404);
	if(target == -1) Return;
	do
	{
		if(VectorDist(GetThingPos(player), GetThingPos(target)) < jku_dist && target != player) DamageThing(target, damage, 0x2, player);
		target=NextThingInView();
	}
	while(target != -1);

Return;
#--------------------------------------------------------
deactivated:
	SetInvActivated(player, 23, 0);
	SetPulse(0);

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


Does that do what you want?

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-02-27, 10:43 AM #12
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
You really should indent your code.</font>


Ive never indented my code. Infact, I have difficutly reading code that IS indented.

Quote:
<font face="Verdana, Arial" size="2"> And I imagine Jon'C would have something to say about it... [http://forums.massassi.net/html/smile.gif]
</font>[/quote]

I couldnt care less.

 

If someone wants to study a cog of mine, all they have to do is ask, and Ill space it out and add nice little comments. Otherwise, I will make the cog as short as possible.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-02-27, 12:25 PM #13
How you know it's simple if you couldn't fix it? huh? [http://forums.massassi.net/html/tongue.gif]

------------------
Life is like... skating... yeah, skating is a good example. You see someone skating and think "Hey, that looks like fun and easy!". You go and buy a skateboard and try, you get a few broken bones, asphalt-face and stuff... But hey, i'm not the one who gets hurt!
Last edited by mb; today at 10:55 AM.
2002-02-27, 1:42 PM #14
it should work thanks, i having been playing with cogs again and am remembering how to use them, about a year ago i would have been able to fix it and it would be simple
roses are red, violets are blue, I am schizophrenic, and I am too!

↑ Up to the top!