PDA

View Full Version : Sleep, curse you! Sleep!



Wolfy
06-27-2004, 10:50 AM
More COG problems. In this case, Jedi Knight refuses to sleep when I tell it to.

You activate Ug, and he displays a few lines of text and adds a new mission objective.

You go to the train station, and talk to the teller. He tells you to buzz off and various levels (depending on how many times you bug him). However, Jedi Knight refuses to recognize any of my Sleep(); verbs. It simply runs through all of the appropriate displays of text and playing of sounds. Why?


# Jedi Knight Cog Script
#
# UgTicket.cog
#
# Description
#
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

message activated
message startup
message entered
message cyccam

thing Ug
thing scalper
thing scalpcam

sector sectcr

thing ticketseller

sound soundGoal=accomplish1.wav local
sound newGoal=activate01.wav local
sound traintalk1
sound traintalk2
sound traintalk3
sound traintalk4

int TicketTalk=0 local
int TicketBuy=0 local
int Sleep=0 local
int Bother=0 local
int entcred=0 local
int ScalpTalk=0 local

end

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

code

startup:
player = GetLocalPlayerThing();
return;

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

activated:
if ((GetSenderRef()==Ug) && (TicketTalk==0)) {
StopThing(player);
SetActorFlags(player, 0xa00000);
JKPrintUNIString(player, 10113);
Sleep(3.0);
JKPrintUNIString(player, 10114);
Sleep(3.0);
JKPrintUNIString(player, 10115);
JKPrintUNIString(player, 1020);
PlaySoundLocal(newGoal, 1.0, 0.0, 0x0);
SetGoalFlags(player, 10, 1);
SetGoalFlags(player, 11, 1);
ClearActorFlags(player, 0xa00000);
TicketTalk=1;
}

if ((GetSenderRef()==Ug) && (TicketTalk==1) && (TicketBuy==0) && (Sleep==0)) {
Sleep=1;
JKPrintUNIString(player, 10116);
Sleep(3.0);
Sleep=0;
}

if ((GetSenderRef()==Ug) && (TicketTalk==1) && (TicketBuy==1)) {
JKPrintUNIString(player, 10127);
jkPrintUNIString(player, 350);
PlaySoundThing(soundGoal, player, 1.0, -1, -1, 0);
SetGoalFlags(player, 11, 2);
}

if((GetSenderRef()==ticketseller) && (Bother==0)) {
Bother=500;
JKPrintUNIString(player, 10117);
PlaySoundThing(traintalk1, ticketseller, 1, -1, -1, 0x0);
Sleep(13.0);
Bother=1;
}

if((GetSenderRef()==ticketseller) && (Bother==1)) {
Bother=500;
JKPrintUNIString(player, 10118);
PlaySoundThing(traintalk2, ticketseller, 1, -1, -1, 0x0);
Sleep(3.0);
Bother=2;
}

if((GetSenderRef()==ticketseller) && (Bother==2)) {
Bother=500;
JKPrintUNIString(player, 10119);
PlaySoundThing(traintalk3, ticketseller, 1, -1, -1, 0x0);
Sleep(3.0);
Bother=3;
}

if((GetSenderRef()==ticketseller) && (Bother==3)) {
Bother=500;
JKPrintUNIString(player, 10120);
PlaySoundThing(traintalk4, ticketseller, 1, -1, -1, 0x0);
}

if((GetSenderRef()==scalper) && (ScalpTalk==0)) {
ScalpTalk=500;
setcamerafocus(0, scalpcam);
JKPrintUNIString(player, 10123);
Sleep(3.0);
TicketBuy=1;
jkPrintUNIString(player, 350);
PlaySoundThing(soundGoal, player, 1.0, -1, -1, 0);
ScalpTalk=1;
}

return;

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

cyccam:
if((GetCurrentCamera() != 0)) {
CycleCamera();
}
return;

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

end

------------------
<ubuu> does hitler have a last name?
<jipe> .. yes, Ubuu, we're racist commy nazi jews, and we hate male pattern baldness
<Professor`K> Sorry, but half-way through your logic, my head exploded

JediKirby
06-27-2004, 12:05 PM
Don't use sleep(). I don't know how many times I've heard someone say "don't use sleep()" but I don't know WHY.

JediKirby

------------------
-Proud Leader of the Minnessassian Council
<]-[ellequin> Nothing is quite as satisfying as placing a .177 lead pellet in between the eyes of a cat.
<]-[ellequin> I think I will leave it's corpse there, to warn all the other cats to keep out of my hibiscus patch

Live on, Adam.

Edward
06-27-2004, 02:55 PM
Could be that you have a value called sleep... Anyway, if all else fails, use timer...

SG-fan
06-27-2004, 04:10 PM
Ya, having a variable named the same as a function will screw up the cog. Always think of creative names like 'delay'

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

Descent_pilot
06-27-2004, 05:55 PM
<font face="Verdana, Arial" size="2">Originally posted by SG-fan:
Ya, having a variable named the same as a function will screw up the cog. Always think of creative names like 'delay'

</font>

What he said. You can't have any symbols that have the same name as a verb and/or message.

------------------
Major projects working on:
SATNRT
JK Pistol Mod
Aliens TC (http://www.massassi.net/levels/files/2967.shtml)

lucky_jackpot
06-28-2004, 02:31 AM
Yep, that'll be the cause (using JK's reserved word list as a variable name) alright http://forums.massassi.net/html/wink.gif http://forums.massassi.net/html/biggrin.gif

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX
"jackpot is an evil evil man... so evil, in fact, that he's awesome." - Seb

"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)

[SF]pjb
06-28-2004, 04:10 AM
<font face="Verdana, Arial" size="2">Originally posted by jEDIkIRBY:
Don't use sleep(). I don't know how many times I've heard someone say "don't use sleep()" but I don't know WHY.

JediKirby

</font>

Yea, i mean everyone told me when i was makeing my AJTD cutseen cogs that i shouldent use sleep.. but as far as i can tell sleep is a bugless command... so why not use it?

------------------
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?

The_New_Guy
06-28-2004, 05:40 AM
I think most of the problems with sleep() occur when you use it in a loop or section of cog that can be re-entered before the sleep timeout completes.

In those instances it seems like the Sleep time accumulates and makes the cog completely non-responsive.

------------------
- Wisdom is 99% experience, 1% knowledge. -

SG-fan
06-28-2004, 06:35 AM
Sleep() is ok to use IF and ONLY IF you make sure that the cog can NOT be reactivated while the sleep is still running.

Tis best to simply use timers, since they don't have that problem. However, as long as you prevent a double activation of the cog, there is no problem with sleep().

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"