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 → Whats wrong with this cog?
Whats wrong with this cog?
2002-01-24, 12:36 PM #1
It should check to see if your first 3 objectives are complete if so, it ends the level...it does nothing..

Code:
# Jedi Knight Cog Script
#
# endlevelat01.COG
#
# Level 1 End Level Cog
#
# Ends level when trapdoor surface touched if all objectives are complete.
# By frantik.

symbols

message	 		touched
sound             	goalsnd=Accomplish1.wav      local 
thing				player		local
surface			trapdoor

end

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

code

touched:
//checks to see if all objectives are completed. If they are end level.
If (GetGoalFlags(player,0)== 2) && (GetGoalFlags(player,1)== 2) && (GetGoalFlags(player,2)== 2)
{
PlaySoundThing(goalsnd, player, 1.0, -1, -1, 0);
Print("Mission Objective Complete!");
Sleep(2);
jkEndLevel(1);
}
  Return;
end


------------------
Save a tree, Kill a beaver!
Save a tree, Kill a beaver!
2002-01-24, 12:49 PM #2
I think these are the probs:

You haven't defined 'player'.

I think you'll want to add:

player = GetSenderRef(); but not sure...

and im not sure if that 'If' statement is structured right...

I think Lucasarts does it like this in their cogs...

if((GetGoalFlags(player,0)== 2) && (GetGoalFlags(player,1)== 2) && (GetGoalFlags(player,2)== 2))

An extra set of ( ), although I might be wrong there I've seen alot of flexibility in if() statements.
- Wisdom is 99% experience, 1% knowledge. -
2002-01-24, 1:14 PM #3
seems to work.
Also, I can kill you with my brain.
2002-01-24, 3:51 PM #4
Hah! CA got you! There is no GetGoalFlags().

Instead use:
Code:
GetInv(player, 100 + goal_num);


[edit]

And of course, as New Guy said, you'll need to include your conditions inside parentheses. An if statement works like this:
Code:
if(condition) //do action

For multiple conditions use this form:
Code:
if(condition && condition) // do action

&& is the logical operator meaning "AND". You could also use || for "OR".

[This message has been edited by SaberMaster (edited January 24, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-24, 4:00 PM #5
Quote:
<font face="Verdana, Arial" size="2">I think you'll want to add:
player = GetSenderRef(); but not sure...</font>


The senderref would be the surface that was touched. The sourceref is the thing that touched it.

------------------
More matter with less art.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-24, 4:13 PM #6
DoH!

Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
The senderref would be the surface that was touched. The sourceref is the thing that touched it.

</font>

- Wisdom is 99% experience, 1% knowledge. -
2002-01-26, 7:05 AM #7
oh and btw , pwned. (:
Also, I can kill you with my brain.
2002-01-26, 11:23 PM #8
The problems stated above + for flags you need to use the bitwise AND operator &, which checks whether a certain bit is on. EQUALS TO operator checks the value as a whole.

E.g. if FLAGS = 0x13 (19 in hex) and you wanted to check whether bits 1 and 16 are on, you'd use
Code:
if ((FLAGS & 0x1) && (FLAGS & 0x10))

or even better, combine the two and do only one bitwise operation:
Code:
if (FLAGS & 0x11)


The two statements above return TRUE. However, this statement:
Code:
if (FLAGS == 0x11)

...would return false, because it checks whether (0x11 == 0x13), or (17 == 19), which is obviously wrong.

Hope that's clear.
Dreams of a dreamer from afar to a fardreamer.
2002-01-27, 9:40 AM #9
Ugh..twas fixed a looong time ago
Save a tree, Kill a beaver!

↑ Up to the top!