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 → Make a COG
Make a COG
2003-12-29, 6:22 AM #1
Can somebody make a cog that does the following: Activate switch or thing to play a sound or voice and spawn an enemy.

I stink at the COG language so please help [http://forums.massassi.net/html/smile.gif]


------------------
-"Thank the Maker!"-
-"Thank the Maker!"-
2003-12-29, 6:49 AM #2
I get more rusty as the days go by . . .but here goes...

Code:
# 12/2003 gbk
Symbols
Message Activated
Message Timer
Surface Switch0
Thing Switch1
Thing Ghost
Template Type
Sound Beep
End
Code
Activated:
Playsoundthing(Beep, Switch1, 1, 0, 10, 0);
Playsoundpos(Beep, Surfacecenter(Switch0), 1, 0, 10, 0);
Createthingatpos(Type, Ghost);
Setwallcel(Switch0, 1);
Settimer(1);
Stop;
Timer:
Setwallcel(Switch0, 0);
Stop;
End



..That should work... Credit me. [http://forums.massassi.net/html/smile.gif]

------------------
Fight the future.
And when the moment is right, I'm gonna fly a kite.
2003-12-29, 7:11 AM #3
Why is their a timer in there?
NightFire
2003-12-29, 2:09 PM #4
The timer is in there so as that once the sound has played, there is a brief pause, before the animated cell material switches back to its first cell (cell 0 - when it's activated, it switches to the second cell (cell 1).

GBK is effectively just activating a switch which alters the surface switch to look as if it has been used/activated. Once the sound has played, he resets the surface cell back to its original appearance - ie: "not in use" [http://forums.massassi.net/html/smile.gif]

Have I missed anything there GBK? [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

There's also the fact that:
Timer > Sleep [http://forums.massassi.net/html/smile.gif]
TimerEx > Timer (in MHO [http://forums.massassi.net/html/wink.gif] - obviously if you've got two timers going, this isn't an issue - TimerEx should be used anyways... [http://forums.massassi.net/html/tongue.gif] )

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX

"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)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2003-12-29, 7:10 PM #5
Quote:
<font face="Verdana, Arial" size="2">Originally posted by TQBinfinity:
Why is their a timer in there?</font>


Because Sleep() sucks.

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2003-12-30, 4:33 AM #6
lol
NightFire
2003-12-30, 4:56 AM #7
Thank You. I will try it out.

[http://forums.massassi.net/html/smile.gif]

------------------
-"Thank the Maker!"-
-"Thank the Maker!"-
2003-12-30, 5:10 AM #8
Quote:
<font face="Verdana, Arial" size="2">Originally posted by GBK:
Because Sleep() sucks.
</font>


True, so very true.



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

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-12-30, 11:12 AM #9
ok, when did i miss the sleep(); starting to suck?

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
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?
2003-12-31, 4:22 AM #10
When the first cog question pertaining to sleep was asked.

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

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-12-31, 6:59 AM #11
If your doing cutscenes, sure, Sleep() sowkrs fine. In fact, any cog that can only be triggered once, or very infreqently, can use Sleep() just fine, and its good for that. In those cases, hell, Id use Sleep().

But once you start getting into complex timed situations; doors, elevators, switches, things that can be triggered very quicky, one after the other, then Sleep() sucks noodles. If you dont understand why, go back and re-read the tutorials......... [http://forums.massassi.net/html/wink.gif]

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2003-12-31, 3:28 PM #12
I haven't heard of a single tut that says don't use sleep for multi-called cogs. so what tuts where?

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

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-12-31, 3:47 PM #13
I personally love using the Sleep() thing. But it is true, if it is a cog that gets called frequently, you have to be careful to make sure your cog won't do stupid stuff if it gets called while its sleeping. A well place inuse var solves most of the problems I've had from it.
One day, after everybody else quits, I'll be the best.
Sith Mercenaries
^My site.
2003-12-31, 6:24 PM #14
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SM_Sith_Lord:
...A well place inuse var solves most of the problems I've had from it.</font>


Sure, up to a certain level of complexity.


Listen, Ive written alot of cogs. Alot. Too many, actully. Ive seen alot of wierd stuff happen ingame, stuff thats easily attributed to functions overlapping via Sleep(). Simple cogs can use Sleep() wihtout any problem. But complex cog; weapon cogs, environment control cogs, etc, may behave oddly in certain circumstances if timing isnt handled properly. Trying to cover up bad timing with a bunch of 'inuse variables' doesnt help the situation, either, it just adds to the complexity. And believe it or not, too much complexity is a bad thing. The simpler your cogs are, easier and faster they will run, and the easier it will be to troubleshoot when something goes wrong.

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2004-01-01, 6:57 PM #15
Listen to GBK, he knows his shizzle.

SetTimerEx is better for one simple reason: It doesn't pause the whole cog for the duration of the timer.

That's what sleep screws up with, it pauses the whole cog for its duration. SetTimerEx just sets a timer for the timer: message to be called.

------------------
Duel Zero : Released the beta. Probably the end of it. Not to worry though, I'm working on Randsaber, which is a lot better.
2004-01-01, 10:16 PM #16
Yeah, i really kind grasp how cogs get run. They way I see it, when a cog is called a new instance of the cog is executed, but the vars from the other instances remain. I think this because, if i'm not mistaken, if a cog gets called even while it is Sleep()ing, it still executes.

------------------
One day, after everybody else quits, I'll be the best.
Sith Mercenaries
^My site.
One day, after everybody else quits, I'll be the best.
Sith Mercenaries
^My site.
2004-01-03, 6:47 AM #17
"SetTimerEx()" verb is far better, not only because "It doesn't pause the whole cog for the duration of the timer", but also because you can get a handle (via parameter check) as to the exact ID of the timer. Ultimately this means (for complex time-based-issue cogs) that you can run more than one "timer" event message at the same time; get a handle of it and deal with that particular ID message, giving different statement blocks of code for different timed message events. Inevitably, this ease of use lets us all go home early and put the kettle on for a nice cup of tea before re-checking the Massassi forums to see if anyone has responded to our post(s)... [http://forums.massassi.net/html/smile.gif]

Well I'm off for a cup of tea - be back in 5 [http://forums.massassi.net/html/rolleyes.gif] [http://forums.massassi.net/html/wink.gif]

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

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX

"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)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2004-01-03, 7:04 AM #18
I didnt use SetTimerEX() because I only used ONE TIMER, and there was no need to kill that timer. For simplicity's sake, ya see?

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2004-01-03, 1:20 PM #19
Sorry about not clearing that reason up GBK - I was taking that as a "given" (one timer message for "SetTimer()"; multiple timers for "SetTimerEx()"), explaining only why a "timer" message function was used rather than "Sleep()", instead... sorry about the ensuing confusion... [http://forums.massassi.net/html/rolleyes.gif] [http://forums.massassi.net/html/wink.gif]

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX

"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)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||

↑ Up to the top!