PDA

View Full Version : Key problems!



Edward
10-06-2003, 10:05 AM
Hi!
The code is for a movie thingy...


# En dag var Belman ute och hoppade på en brunnlock och räcknade:
# "22, 22, 22, 22, 22..."
# Då kom en polisman till honom och frågade:
# "Hurru, vad håller du på med?"
# "Det är kul!" svarade Belman "Vill du pröva?"
# "Visst!" sa polismannen och började hoppa:
# "22, 22, 22..."
# Då ryckte Belman bort brunnlocket och polismannen föll.
# Belman satte tillbaka locket och fortsatte hoppa:
# "23, 23, 23, 23, 23..."
symbols

message startup
message pulse
message touched

thing belman mask=mask=0x405
thing polisman
thing brunnlock

thing narbildcam
thing hoppcam

keyframe hoppandebelman
keyframe hoppandepolisman

keyframe gaendepolisman
keyframe pratandepolisman

keyframe belmandraratsig
keyframe belmanlaggertillbaka

int belmanrorelse=-1 local
int polisrorelse=-1 local

int nummer=10 local

sound brakna1_0
sound brakna1_1
sound brakna1_2
sound brakna1_3
sound brakna1_4
sound brakna1_5
sound brakna1_6
sound brakna1_7
sound brakna1_8
sound brakna1_9

sound brakna10_0
sound brakna10_1
sound brakna10_2
sound brakna10_3
sound brakna10_4
sound brakna10_5
sound brakna10_6
sound brakna10_7
sound brakna10_8
sound brakna10_9


sound prakna1_0
sound prakna1_1
sound prakna1_2
sound prakna1_3
sound prakna1_4
sound prakna1_5
sound prakna1_6
sound prakna1_7
sound prakna1_8
sound prakna1_9

sound prakna10_0
sound prakna10_1
sound prakna10_2
sound prakna10_3
sound prakna10_4
sound prakna10_5
sound prakna10_6
sound prakna10_7
sound prakna10_8
sound prakna10_9

sound praknaf_0
sound praknaf_1
sound praknaf_2
sound praknaf_3
sound praknaf_4
sound praknaf_5
sound praknaf_6
sound praknaf_7
sound praknaf_8
sound praknaf_9

sound rakna100

sound p_vadgordu
sound b_kul
sound p_visst

sound plask

int hoppar=0 local

thing urvagen
thing tittahit

thing tillbelman
thing ner

end
#
code
startup:
SetActorFlags(GetLocalPlayerThing(),0x840000);
SetCurrentCamera(1);
SetCameraFocus(0,hoppcam);
SetCameraFocus(1,polisman);
SetPulse(GetKeyLen(1));
sleep(1);
nummer=20+(rand()*80);
if(nummer>=100) nummer=99;
thinglight(tittahit,100,2);
hoppar=1;
SetCurrentCamera(0);
sleep(1);
AISetMoveThing(polisman,tillbelman);
sleep(1);
while(IsMoving(polisman))
{
print("*");
sleep(0.1);
}
StopThing(polisman);
AISetMoveThing(polisman,belman);
AISetLookPos(polisman,GetThingPos(belman));
sleep(1);
while(IsMoving(polisman))
{
print("*");
sleep(0.1);
}
hoppar=0;
StopKey(belmanrorelse,1);
PlaySoundLocal(p_vadgordu,1,0,0xC0);
print("What are you doing?");
AISetLookPos(belman,GetThingPos(polisman));
sleep(GetSoundLen(p_vadgordu));
StopKey(belmanrorelse,1);
PlaySoundLocal(b_kul,1,0,0xC0);
SetCameraFocus(0,narbildcam);
print("It's fun! Wanna try?");
sleep(GetSoundLen(b_kul));
StopKey(belmanrorelse,1);
PlaySoundLocal(p_visst,1,0,0xC0);
print("Sure!");
sleep(GetSoundLen(p_visst));
AISetLookPos(belman,GetThingPos(urvagen));
AISetMoveThing(belman,urvagen);
AISetMoveThing(polisman,brunnlock);
sleep(1);
while(IsMoving(polisman))
{
print("*");
sleep(0.1);
}
AISetLookPos(belman,GetThingPos(polisman));
AISetLookPos(polisman,GetThingPos(tittahit));
sleep(1);
SetCameraFocus(0,hoppcam);
hoppar=2;
sleep(5);
belmanrorelse=PlayKey(belman,belmandraratsig,1,0x4 );
sleep(0.4);
TeleportThing(polisman,ner);
SetCameraFocus(1,belman);
hoppar=0;
PlaySoundLocal(praknaf_0[y],1,0,0xC0);
sleep(3);
PlaySoundLocal(plask,.25,0,0xC0);
sleep(1);
StopKey(belmanrorelse,1);
belmanrorelse=PlayKey(belman,belmanlaggertillbaka, 1,0x4);
MoveToFrame(brunnlock,0,2);
sleep(GetKeyLen(belmanlaggertillbaka));
StopKey(belmanrorelse,1);
Sleep(0.1);
AISetMoveThing(belman,brunnlock);
sleep(1);
AISetLookPos(belman,GetThingPos(tittahit));
sleep(1);
nummer=nummer+1;
if(nummer<100)
{
hoppar=1;
}
else
{
hoppar=3;
}
sleep(5);
thinglight(tittahit,0,5);
sleep(5);
JKEndlevel(1);
return;
pulse:
x=nummer%10;
y=(nummer%100)/10;
StopKey(polisrorelse,0.01);
StopKey(belmanrorelse,0.01);
printint(nummer);
sleep(0.01);
if(hoppar==1)
{
belmanrorelse=PlayKey(belman,hoppandebelman,0,0x4) ;
PlaySoundThing(brakna10_0[y],belman,1,-1,10,0xC0);
sleep(GetSoundLen(brakna1_0[y]));
PlaySoundThing(brakna1_0[x],belman,1,-1,10,0xC0);
}
else if(hoppar==2)
{
polismanrorelse=PlayKey(belman,hoppandepolisman,0, 0x4);
PlaySoundThing(prakna10_0[y],belman,1,-1,10,0xC0);
sleep(GetSoundLen(prakna1_0[y]));
PlaySoundThing(prakna1_0[x],belman,1,-1,10,0xC0);
}
else if(hoppar==3)
{
belmanrorelse=PlayKey(belman,hoppandebelman,0,0x4) ;
PlaySoundThing(rakna100,belman,1,-1,10,0xC0);
}
return;
touched:
If((GetSenderRef()!=belman) && (GetSourceRef()!=polisman)) return;
StopThing(polisman);
retrun;
end

After a few hops from belman, he stops, and after I can't stop the key or make him move properly... Help!

/Edward
PS.
I'm not done with my other problems. This is a side job.

[This message has been edited by Edward (edited October 06, 2003).]

lucky_jackpot
10-06-2003, 03:41 PM
Hi there http://forums.massassi.net/html/smile.gif

Just after a cursory glance, I couldn't help but notice that in your "touched" message (at the end), you have misspelt return http://forums.massassi.net/html/wink.gif Easy mistake to make http://forums.massassi.net/html/smile.gif

Other than that, at which particular point in the script do things go "belly-up" (wonderful technical description)? Just a suggestion you may try (if you're trying to avoid my "blank-it-out-line-by-line" approach http://forums.massassi.net/html/wink.gif ) - check your arrays; in this particular example, your keys; as well as setting up a continuous "pulse" Print() line message, so you can check that your cog is still alive at key points in its execution...?

Hope this helps http://forums.massassi.net/html/biggrin.gif

-Jackpot

------------------
Are you feeling lucky, cuz if you are, get your hands off me... ;)

"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)

Edward
10-06-2003, 11:59 PM
At which particular point?
Well, it starts, belman starts jumping, but his hight decreases at every jump. 4dm, 2dm, 1dm, stop. Then at the StopKey(), he still holds that jumping position but like a statue, and no other keys can play!

/Edward


[This message has been edited by Edward (edited October 07, 2003).]

Edward
10-08-2003, 07:48 AM
OK! I've found the problem. I set every jump key for 0x0, and I found a problem in my StopKeys.
Now the only problem left is:
nummer=20+(rand()*80);
When I start the Test bat file, and click on SP, Debug, This Episode, That Level, it always starts with 65. After I restart the level without going out of the game, it is another number. Can anyone tell me why at first it starts at 65?

/Edward

DogSRoOL
10-09-2003, 12:54 PM
Random numbers aren't really random. They're generated from a table (or something like that). If you move an object, gob the level and test it, does it still turn up 65? (I'm not sure what means jk uses to create random numbers.)

------------------
"The Just shall live by faith." - Galatians 3:11
I am DogSRoOL; Lord of the Onion Rings
The Giant Internet IC Masturbator (http://www.ionpool.net/arcade/giicm/GIICM.html)

[Anoying posts] + 1.

Edward
10-09-2003, 01:40 PM
Well, I didn't move anything when I turned it into a GOB, and still same number. BUT! It has been the same number ever since I pressed Test for the first time on this level/movie/whatever.

OK, I've changed the random code a bit.
nummer=rand()*100;
if(nummer>=100) nummer=99;
if(nummer<=20) nummer=20;
And now it no longer says 65 everytime I start for the first time. It says 56.

So... It seems to choose a number acoording to COG... something...

/Edward
------------------
"God never plays dice." - Einstein

Dash
10-10-2003, 05:06 AM
You come from Sweden !?

------------------
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code

[This message has been edited by Dash (edited October 10, 2003).]

Edward
10-10-2003, 08:05 AM
<font face="Verdana, Arial" size="2">Originally posted by Dash:
You come from Sweden !?

</font>

JA! A'm Fron Sveden.
Vad har det och göra med min slumpesige problem?
Just help me, OK?
------------------
En dag, var en Engelsk man, en Frans man, och Belman ute på en prommenad. De mötte en tjej, och de gillade henne. Hon sa "Kom med mej", och så gjorde de det. De gick till toppen av en klippa. Så sa tjejen till Engelsk mannen: "Om du älskar mig, så hoppar du över stupet.", och Engelsk mannen hoppade och dog. Så sa tjejen till Frans mannen: "Om du älskar mig, så hoppar du över stupet.", och Frans mannen hoppade och dog. Så sa tjejen till Belman: "Om du älskar mig, så hoppar du över stupet.", och Belman funderade lite, och sen sa: "Damerna först!"

Edward
10-23-2003, 12:58 AM
Any more help you can give me?