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 → MP Forcefield cog
MP Forcefield cog
2004-05-07, 2:51 AM #1
Hi guys.

I am making a horizontal forcefield that damages the player when activated and when he's walking on it.

I tried the JK MP cog (m2_ffieldswitch.cog), but I need it to do two more things. The transparency needs to be red, instead of blue, and also, the surface that is set to 'no move' needs to be set to floor too, so you can walk on the activated forcefield, because it's horizontal. (ofcourse you take damage when you do). It needs to work for clients comps too, ofcourse.

There may already be a modified version of this cog that does this, I don't know. Can anyone tell me where to get a cog that does this, or tell me how to modify?

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-07, 4:40 AM #2
I believe this is the link to the thread about a link to the original thread that was addressing a MP force-field cogscript [http://forums.massassi.net/html/rolleyes.gif] [http://forums.massassi.net/html/wink.gif]

http://forums.massassi.net/html/Forum4/HTML/004071.html

In short the version you're after (which was originally by myself and marginally modified/"upgraded" by Slaw ends shameless plug* [http://forums.massassi.net/html/wink.gif] ), is directly on the linked page provided - 2nd/3rd to last post, if I recall correctly....

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

-Jackpot

PS: Maybe I really ought to get round to submitting that script to Massassi - the number of requests for force-field scripts is unbelievable [http://forums.massassi.net/html/eek.gif] [http://forums.massassi.net/html/biggrin.gif]

------------------
"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-05-07, 6:58 AM #3
Thanks! I checked it out, but it was really confusing, lol. I found 3 versions of the cog. Which version do I exactly need? Maybe you could be so nice to post it on here? [http://forums.massassi.net/html/wink.gif] lol. Also (forgive me being a cog newb), it says that it's a MotS cog. Is there a difference between MotS cogs and JK Cogs?

Oh, and just to be sure... I really need the surface to be walkable, and red transparent. Is that possible with this cog? I couldn't make much out by looking at the code.

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-07, 12:09 PM #4
Here ya go. It was the last version posted (the one in my post that was, according to jackpot, "upgraded" [http://forums.massassi.net/html/wink.gif] ). The only difference in this one is that I Scribed it (using Scribe by SM, of course [http://forums.massassi.net/html/biggrin.gif] ), and thus some of the areas of the code were easier to follow. And if it makes you happy, the header says JK script now. [http://forums.massassi.net/html/smile.gif]
Oh, also, I think I found a small typo in the startup message, too; there was an "if(verbose)" statement (if you want to print debug messages), and was followed by a sleep() command, and then the print("...") command (no braces around either). That has been fixed below. Probably wasn't a big deal, but, yeah... [http://forums.massassi.net/html/rolleyes.gif]

Code:
See below for updated code


If you want your ff surface to be red, use a red texture on it. And the cog (according to documantation) does automatically apply the floor flag to the ff surfaces, so you can walk on them. And the ff surfaces will be translucent (if they were transparent you couldn't see the ff [http://forums.massassi.net/html/wink.gif] ).
Aside from some verbs and flags, there's not any difference between MotS cogs and JK cogs (I dont think, anyway -- I can't think of any other differences)

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.

[This message has been edited by Darth Slaw (edited May 07, 2004).]

[This message has been edited by Darth Slaw (edited June 01, 2004).]
May the mass times acceleration be with you.
2004-05-08, 3:27 AM #5
Actually Slaw, there were no "{...}" around that "if" statement because the following line is only executed explicitly if the comparison result returns true [http://forums.massassi.net/html/smile.gif]. Try it if you don't believe me - however you can do this method if you have only one statement after the test ("if")condition. If you have any more than one statement that you want to execute (with regard to program flow), then you have to use braces.

In short (if you check the original version [http://forums.massassi.net/html/wink.gif]), the startup message executes the sleep message only if verbose is true and therefore (because of the lack of braces) the print message is printed regardless of the outcome of the test condition... which on second viewing, is not what I really wanted, but hey... [http://forums.massassi.net/html/rolleyes.gif] - it serves as an adequate example of my description though [http://forums.massassi.net/html/wink.gif] (yes, you can go ahead and delete that sleep statement [http://forums.massassi.net/html/smile.gif]).

Apologies about this waffle - this was more just a "clarifier" message [http://forums.massassi.net/html/biggrin.gif] - just trying to make more people aware of programming conventions and program flow [http://forums.massassi.net/html/smile.gif].

And "ouch" - how many spaces does Scribe indentaion do - one thing's for certain, it isn't the conventional "4 spaces" rule...

Anyways - hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

PS: No, there's no different cog verbs explicit to either MotS or JK with this script - I just happened to be cogging for MotS when I submitted the script the first time....

------------------
"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-05-08, 12:51 PM #6
Ah, ok. (I like waffles [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif])

Also, Scribe doesn't indent the code in spaces; it indents in tabs (it does indentations in the symbols section with spaces, but the code section is indented with tabs; Can it indent in spaces instead? I don't know... doesn't look like it though)

If you really want it in spaces, you can copy/paste a TAB into the Find/Replace dialog and "replace all" with a 4-space string instead.

Not that this really makes any difference, but with TABs, Jackpot's cog is 500 bytes smaller in size than with spaces.

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.

[This message has been edited by Darth Slaw (edited May 08, 2004).]
May the mass times acceleration be with you.
2004-05-08, 2:06 PM #7
Lol, I didn't get any of that technical stuff, but thanks a lot anyway. I'll try it out and see if it works. Thanks a lot guys, I really appreciate the help. All will be credited if it works. [http://forums.massassi.net/html/smile.gif]

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-14, 3:29 PM #8
Hey guys, sorry for replying so late. I was too busy to work on my level. Anyway, I tested the cog, but... as soon as I activate the switch (touch the activation surface), JK crashes. =\ Maybe I did something wrong in the setup. I was wondering about two things:

Verbose [int]

and

SurfaceGeoMode [int]

What do these mean? I have no idea what it does or what value to use for it.

I didn't fill in anything for the verbose. I tried settings SurfaceGeoMode to 5, because I somehow suspected this might make the forcefield walkable. Crashed, so I put it back to 4 (default)...same thing.

so...what do I do with these, and could they be the cause of the problem? I remember reading somewhere that you have to do soething specific when you are using a solid colormat for transparent surfaces, but I can't remember what it was. I used the 00red.mat for the forcefield surfaces. Maybe that is the problem?

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-15, 6:38 AM #9
Didn't you read the documentation (aka comments) in the cog? [http://forums.massassi.net/html/rolleyes.gif]

For SurfaceGeoMode, use 3 if your ff surface uses solid-color mats, and 4 if it uses non-solid-color mats (I don't know what I should really call them).

Verbose should be set to 1 if you want the cog to print debugging messages (like "ff activated", "ff off", "you touched the ff", etc.) Otherwise, set it to 0.

You don't need to do any setup stuff to make the cog apply the floor flag to your ff surfaces; it does it all the time, whether you want it or not.

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

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-05-15, 9:46 AM #10
Yeah, sorry. I read it after posting. I set it to 3 and it worked ... but there's only one problem. I can walk on it, but it does no damage. Only when I hit it from below, it damages me. I switched the two surfaces in the setup of the cog, but it still only did damage on the 'downside', and lol.... you guessed it...I need it exactly the other way round. Can this be fixed?

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-15, 5:25 PM #11
Hmm... interesting. Some experimenting will have to be done here.

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-05-16, 2:47 AM #12
Yeah. Strange, isn't it? For example, 180 8 is my top surface and 152 3 is the downside. It does only damage on the downside. So I set top surface to 152 3 and downside to 180 8, it still only does damage on the downside. :S Absolutely crazy, lol. Other than that, it works fine. Sounds work, transparency works, switch works.

------------------
*There is no death, there is the Force*

[This message has been edited by ORJ_JoS (edited May 16, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-05-16, 4:56 AM #13
All this time I knew the problem (thanks to GBK's continuous bashing me about it long ago [http://forums.massassi.net/html/wink.gif] )! The ff surface you're walking on is flagged as floor, and the touched message is not called when a thing attaches to the surface if it is a floor; thus, we need to use the "entered" message.
Here's a version that supports floor ff's, but I'm still working out how to make it damage you continuously after walking on it instead of just when you first walk on it.
Code:
See below for updated code


------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good (:");
PrintInt(i); //print the integer value of infinity

[This message has been edited by Darth Slaw (edited June 01, 2004).]
May the mass times acceleration be with you.
2004-05-16, 8:41 AM #14
Ah, I see. Sounds like a tough problem to solve. But yeah, it needs to keep damaging all the time it is touched. Well, thanks a lot, I'll try this one out. We're getting closer! [http://forums.massassi.net/html/smile.gif]

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-16, 11:08 PM #15
Sorry I've been away so long - I know I'm supposed to be revising, so this will have to be a quick post (that and the fact that I'm using a friend's uni internet access so...)

For the continual damage aspect, why not invoke a timer/damaged combo, when the entered message is called?

Sorry if it's a (very!) brief suggestion but I've got major exams this week [http://forums.massassi.net/html/frown.gif]. For anyone who cares, I'll probably be back next week - by that time I'll rig up a fool-proof force-field script. Period. If for no other reason than my own peace of mind... [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

So until then, my fellow coggers... [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-05-17, 11:15 AM #16
Alright, good luck with your exams dude [http://forums.massassi.net/html/biggrin.gif]

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-18, 5:44 PM #17
Okay, I got about 99% of this code working correctly; the other troublesome 1% is that the player will not stop from being damaged by the timer -- I don't understand why. Maybe another set of eyes will see something I missed.

It seems to be something wrong in the exited message; if the "killtimerex()" line worked, then the player would have his timer damaging thinger stopped and no more damage would be dealt; instead, it continues to run the timer message.
Code:
See below for updated code


------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity

[This message has been edited by Darth Slaw (edited May 18, 2004).]

[This message has been edited by Darth Slaw (edited June 01, 2004).]
May the mass times acceleration be with you.
2004-05-19, 2:09 AM #18
Awesome! You guys are really miracle workers. [http://forums.massassi.net/html/biggrin.gif] Sounds like it only needs a tiny little fix now. I think once it's done, it should be submitted to the Massassi Cogs section. It's really a cog that could come in handy for a LOT of people.

Thanks again guys, you'll all be on the credits list. I'm making a pretty big level with some special features. It will definitely get released, so you're not doing it for nada. [http://forums.massassi.net/html/wink.gif]

In a couple of weeks time I'll have a request for a very special cog that I don't think has been made before. Methinks it won't even be that hard to do, but... I don't know anything about cog, so we'll see about that, lol.

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-19, 1:10 PM #19
Erm =\

Coming to think of it... there's something I forgot, ehehehe.

Would it be possible for the forcefield to do direct damage to the health? (so no shield damage) Only if it's not too much hassle / code. Mesa would be pleased, lol.

And also...it'd be nice if it displayed a line of text everytime it does damage.

Could those two things be done? Sorry for asking so late. If it's too much trouble, just forget it. I'll be happy enough if it works.

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-22, 5:39 AM #20
So, no one sees ANYTHING wrong with the cog I posted? [http://forums.massassi.net/html/confused.gif]

Quote:
<font face="Verdana, Arial" size="2">Originally posted by ORJ_JoS:
Erm =\

Coming to think of it... there's something I forgot, ehehehe.

Would it be possible for the forcefield to do direct damage to the health? (so no shield damage) Only if it's not too much hassle / code. Mesa would be pleased, lol.

And also...it'd be nice if it displayed a line of text everytime it does damage.

Could those two things be done? Sorry for asking so late. If it's too much trouble, just forget it. I'll be happy enough if it works.

</font>


Nah, no trouble. Just a little copy/pasting (sorta).

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity
May the mass times acceleration be with you.
2004-05-22, 3:20 PM #21
Alright. Well I can't see anything about the code of the cog, because I don't know anything about it. But LuckyJackpot said he'd be back this week, so... [http://forums.massassi.net/html/smile.gif]

I'm glad it's no big deal to add those things. Since it's apparently not in its final version yet, I have just one last request. (I promise, this is the last, really, lol):

The FF should be off at startup, I know that shouldn't be a big deal to do. (Although I couldn't do it myself)

K, so just to be safe: FF off at startup, displaying text when damaging, and damage to health, not to shield.

Thanks again! I'm sure someone knows how to fix that problem with the damage.

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-22, 6:18 PM #22
Well, actually, the ability to tell it whether to start on or off is already implemented. Set the symbol "status" to 1 to turn it on at startup, and 0 to leave it off. [http://forums.massassi.net/html/smile.gif]

That problem with the damage will get fixed sooner or later; worst case scenario, we have to start over with the previous version and reimplement the floor damaging code.

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity
May the mass times acceleration be with you.
2004-05-22, 11:36 PM #23
Nah, you just have to change the damage flags in the DamageThing() verb to 0x8 or something.
If you tell me what text to display, I'll update the above posted cog with these changes...

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-05-23, 10:34 PM #24
Ta-daa - I'm back again after a hectic week - normal cogging services are now resumed [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif] (exam free time w00t-age [http://forums.massassi.net/html/biggrin.gif])

Anyways, when I get back from work today, I'll have a gander at the FF script (I was meant to last night, but I was too tired travelling back [http://forums.massassi.net/html/frown.gif] ).

Where you wish the damage to cut straight through the shields and do direct health damage, I believe the alteration should be in the DamageThing (params) line, where the damage type flag should be set to 0x1 (for physical damage - at least I think it's that flag, although the DataMaster knows for sure [http://forums.massassi.net/html/wink.gif]) [http://forums.massassi.net/html/smile.gif]. That said, don't worry if you don't understand ORJ [http://forums.massassi.net/html/wink.gif] - I'll fix it up so that it works (as well as add in a few extras that I've been meaning to, but haven't had the time to implement...) [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-05-24, 10:58 AM #25
Okies - here we go again - take 5 of this blinkered script - heck, I know I'm one for a challenge, but even I didn't see this script being re-written this many times... [http://forums.massassi.net/html/wink.gif]

NB: Please read the header instructions for this cog - chances are, if you have a question regarding this cog and it's set-up, the header's already got your answer included... [http://forums.massassi.net/html/wink.gif]

Code:
##
# MOTS Cog Script
#
# 00_MPForceFieldv5.COG
#
# Force-field effect on two adjoined surfaces (ff_front and ff_back)
#
# Will damage player if touched while force-field status is ON.
# May be switched off by either a "console" (thing) or "switch0"/"switch1" (surfaces).
#
# Force-field starts being ON (default: status=1).
# Change status=0 if you want the force-field to be OFF at start.
#
# Version 5 addition:
#   Set isShootableSwitch=1, to be able to toggle the force-field ON/OFF
#   just by shooting either switches or console.
#   To disable this feature, set isShootableSwitch=0.
#
# In JED (or something similiar in JK Edit, if you're so inclined...) :
# NB-01: Set +ADJOIN FLAGS to 5
# NB-02: Set +SURFACE FLAGS to 14007
# NB-03: Set +FACE FLAGS to 2
# NB-04: Set +GEO to value of 'surfaceGeoMode' symbol
#
# Set verbose=1, if you want to see print out messages.
# (More for test purposes than anything else...)
#
# This COG script is NOT supported by LucasArts or LEC.
#
# Permission is granted to use this script by the author, as long as credit
# is provided in the readme file for any add-on levels that use this script.
#
# version 1 : 12-August-2003
# version 2 : 14-August-2003
# version 3 : 04-December-2003 --> Optimised for multi-player!
# version 4 : 18-May-2004      --> Added support for floor force fields
#                                    (this code inspired by lucky_jackpot and
#                                    Zagibu and implemented by Darth Slaw)
#
# version 5 : 24-May-2004    --> Once and for all - this is it !!! (both SP & MP)
#                                      -Jackpot, with thanks to Darth Slaw and Zagibu
#                                       for refinements along the way  [http://forums.massassi.net/html/wink.gif]   [http://forums.massassi.net/html/biggrin.gif]
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##

symbols

message   startup
message   activated
message   entered
message   exited
message   touched
message   damaged
message   timer

surface   ff_front                     linkid=2 mask=0x400
surface   ff_back                      linkid=2 mask=0x400

surface   switch0                     linkid=1 mask=0x408   # Player, actor, weapon
surface   switch1                     linkid=1 mask=0x408
thing     console                      linkid=1 mask=0x408

template  sparks=+heavysmoke       local
flex      damage                            local
flex      damageInterval=0.25          local
flex      minDamage=2.0
flex      maxDamage=10.0

int     status=1                                 # 1 is ON ; 0 is OFF
int     isShootableSwitch=0                 # 1 is ON ; 0 is OFF

int       tempSound1                   local
int       tempSound2                   local
int       tempSound3                   local
int       tempSound4                   local
int       surfaceGeoMode=4                        # use 3 for solid mats; 4 for non-solid mats

sound     ff_on=forcefieldon01.wav
sound     ff_off=forcefieldoff01.wav
sound     ff_hum=forcefieldhum01.wav
sound     ff_hit=forcefieldhit01.wav


int       verbose=0                               # Used as a test variable.  Set to 0 to not print messages...

end

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

code

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


startup:
    if (verbose) {
        Sleep (1.0);    // Allow dust to settle for a bit...
        Print ("Force Field Status COG EXECUTING !!!");
    }

    if (status == 0) {
        if (verbose)
            Print ("Startup: OFF");
        SetWallCel (switch0, 0);
        SetWallCel (switch1, 0);
        call forceField_OFF;
    }
    else if (status == 1) {
        if (verbose)
            Print ("Startup: ON");
        SetWallCel (switch0, 1);
        SetWallCel (switch1, 1);
        call forceField_ON;
    }

    Return;

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


activated:

      // Eliminate any possibility that something other than
      // the on-off switch0 OR console could send the
      // "activated" message...
    if (GetSenderID() != 1)
        Return;

    if (GetSenderID() == 1) {    // Just a double-check to make sure we've got a handle on the right thing...
        if (status == 0) {
            if (verbose)
                Print ("FF IS OFF");
            call forceField_OFF;
        }
        else
        if (status == 1) {
            if (verbose)
                Print("FF IS ON");
            call forceField_ON;
        }
    }

    Return;

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


entered:
    if (GetSenderID() != 2)
        Return;

    if (GetSenderID() == 2) {
        if (verbose) {
            Print ("SURFACE TOUCHED !!!!");
            PrintInt (GetSourceRef() );
        }

        if (status == 1) {
            if (verbose)
                Print ("FF DEACTIVATED ---> Safe to Pass !!!");
        }
        else
        if (status == 0) {
            damage = (Rand() * (maxDamage - minDamage) ) + minDamage;

              // Allow for self-inflicted damage (0x2)
              // Change to 0x1 flag to cut straight through shields and do DIRECT health damage....
            DamageThing (GetSourceRef(), damage, 0x2, GetSenderRef() );

              // Sounds stuff
            tempSound3 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);
            tempSound4 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_back), 0.5, 1, 10, 0);

            if (!IsMulti() )
                CreateThing (sparks, GetSourceRef() );  // Do only on evaluative "true" condition
            KillTimerEx (GetSourceRef() );
            SetTimerEx (damageInterval, GetSourceRef(), 0, 0);
        }
    }

    Return;

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


exited:

    if (GetSenderID() != 2)
        Return;

    if (verbose) {
        Print ("Detatched");
        PrintInt (GetSourceRef() );
    }

    KillTimerEx (GetSourceRef() );

    Return;

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


touched:

    if (GetSenderID() != 2)
        Return;

    if (GetSenderID() == 2) {
        if (verbose)
        Print ("SURFACE TOUCHED !!!!");
        if (status == 1) {
            if (verbose)
                Print ("SAFE TO PASS - OK");
            Print ("FF is off so don't damage...");
        }
        else
        if (status == 0) {
            if (verbose)
                Print("OUCH !!!");
            damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
              // Allow for self-inflicted damage (0x2)
              // Change to 0x1 flag to cut straight through shields and do DIRECT health damage....
            DamageThing (GetSourceRef(), damage, 0x2, GetSenderRef() );
              // Sounds stuff
            tempSound3 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);
            tempSound4 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_back), 0.5, 1, 10, 0);

            if (!IsMulti() )
                CreateThing (sparks, GetSourceRef() );
        }
    }

    Return;

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

damaged:

      // This clause allows the switch to be shot and alter the force-field state.
    if (isShootableSwitch) {
        if (GetSenderID() ==1) {
            if (verbose)
                Print ("If WALLS could talk, we'd say: OUCH - that's a chunk of my brickwork !!!!");
            if (status == 1)
                call forceField_ON;
            else
                call forceField_OFF;
        }
    }

      // If we reach this evaluation, then we know that this is a player...
    if (GetParam (1) == 1) {
        if (GetThingType (GetSourceRef() ) != 10)   // Don't hurt anything that isn't a player!
            Return;
        damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
        DamageThing (GetSourceRef(), damage, 0x1, GetSenderRef() ); // Do physical damage
    }

    Return;

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

timer:

    SetTimerEx (damageInterval, GetSenderID(), 20, 0);
    if (verbose)
        PrintInt (GetSenderID() );
    damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
    DamageThing (GetSenderID(), damage, 0x2, GetSenderRef() );
    tempSound3 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);
    tempSound4 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_back), 0.5, 1, 10, 0);

    if (!IsMulti() )
        CreateThing (sparks, GetSenderID() );

    Return;

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

forceField_ON:

    PlaySoundPos (ff_on, GetSurfaceCenter (switch0), 0.5, 1, 10, 0);  // Play On sound - switch0
    PlaySoundPos (ff_on, GetThingPos (console), 0.5, 1, 10, 0);   // Play On sound - console

      // Floor; Used in COG; Impassable; Magsealed
    SetSurfaceFlags (ff_front, 0x14007);
    SetSurfaceFlags (ff_back, 0x14007);
      // Not passable
    ClearAdjoinFlags (ff_front, 0x2);
    ClearAdjoinFlags (ff_back, 0x2);
      // Geo-mode
    SetFaceGeoMode (ff_front, surfaceGeoMode);   // Surface face
    SetFaceGeoMode (ff_back, surfaceGeoMode);   // is drawn...
    SetFaceType (ff_front, 0x2);      // Surface Face Type Info
    SetFaceType (ff_back, 0x2);      // Set face type to "translucent"
      // Sounds stuff
    tempSound1 = PlaySoundPos (ff_hum, GetSurfaceCenter (ff_front), 1.5, 2.0, 10.0, 0x1);
    tempSound2 = PlaySoundPos (ff_hum, GetSurfaceCenter (ff_back), 1.5, 2.0, 10.0, 0x1);
      // Set wall cell mat info
    SetWallCel (switch0, 1);
    SetWallCel (switch1, 1);

      // Reset status to 0 - OFF
    status = 0;

    Return;

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

forceField_OFF:

    PlaySoundPos (ff_off, GetSurfaceCenter (switch0), 0.5, 1, 10, 0); // Play Off sound - switch0
    PlaySoundPos (ff_off, GetThingPos (console), 0.5, 1, 10, 0);  // Play Off sound - console

      // Surface flags
    ClearSurfaceFlags (ff_front, 0x14007);
    ClearSurfaceFlags (ff_back, 0x14007);
      // Adjoins info
    SetAdjoinFlags (ff_front, 0x2);
    SetAdjoinFlags (ff_back, 0x2);
      // Geo-mode
    SetFaceGeoMode (ff_front, 0);    // Don't draw surface
    SetFaceGeoMode (ff_back, 0);
      // Surface Face Type Info
    ClearFaceType (ff_front, 0x2);
      // Clears translucency
    ClearFaceType (ff_back, 0x2);
      // Sounds stuff
    StopSound (tempSound1, 0.5); // Stop hum sound
    StopSound (tempSound2, 0.5);
    StopSound (tempSound3, 0.2);
    StopSound (tempSound4, 0.2);
      // Set wall cell mat info
    SetWallCel (switch0, 0);
    SetWallCel (switch1, 0);

      // Reset status to 1 - ACTIVE
    status = 1;

    Return;

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

end


As for the damage thing - I could code up a way of doing it, but it would mean a lot of MP overhead "if" statement checking [http://forums.massassi.net/html/frown.gif]. To get around this, look for the "DamageThing(params) lines and change all the 0x<<insert number here>> so that they read 0x1 (this does "physical" damage to the player). Although this is mentioned in the script, I just thought I'd reiterate it again!! [http://forums.massassi.net/html/biggrin.gif]

The only real new addition that this script has are "shootable trigger switches" whereby, the force-field can (as well as acting normally) also be switched on/off by shooting the switches/console that control whether the force-field is on/off. However, if you don't want this mode, then simply set the variable "isShootableSwitch" to 0 in the level editor.


Phew - okies - I think that this is now the defintive force-field script around (although I bet someone finds something wrong with it...) [http://forums.massassi.net/html/wink.gif]

-Jackpot

PS: ... and "YES", before anyone asks, this truly does work for both SP and MP; JK andMOTS... Here's hoping it's the last time I see this script... [http://forums.massassi.net/html/wink.gif]

PPS: Yes, I said it last time I thought I'd finally got it right, but "secretly I want to go for version 6" tempts fate...

------------------
"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-05-24, 2:50 PM #26
Lol!! Version 6, eh? who knows, lol. Alright, this is awesome guys, I'll go test it right away. [http://forums.massassi.net/html/biggrin.gif]

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-24, 4:31 PM #27
Well, I tested it, and here's the results:

-Shootable switch works, no problem.
-Walking on Forcefield is possible, I take damage when I do, no problem.

3 Problems:
-It keeps damaging me continuously, even when I'm not standing on it, and even after dying and respawning.
-It still does damage to the shield (instead of directly to the health)
-It does damage REALLY fast! Even in very small amounts you die in just seconds.

Seems like your wish is granted, LuckyJackpot [http://forums.massassi.net/html/wink.gif] Still needs some work.

Oh btw, I'd like it to display a line of text when it does damage. DarthSlaw said that wouldn't be much work. Here's the text:

"The floor is burning hot! You are taking damage!"

------------------
*There is no death, there is the Force*

[This message has been edited by ORJ_JoS (edited May 24, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-05-24, 10:31 PM #28
Hi-ho, hi-ho, it's back to that darn script I go [http://forums.massassi.net/html/rolleyes.gif] [http://forums.massassi.net/html/wink.gif]

I left Slaw's original "damage speed", so to speak, because I thought it seemed realistic and gave the player long enough to get off that particular surface. I'm guessing you want a longer pause in-between damage bursts?

As for the shields thing, I'll change it for you and repost it tonight, although I've tinkered around with this sort of script before and literally, it'll cut through your health in a split-second (obviously you can lower the minDamage and maxDamage variables) but unless it's some sort of crushing device, I generally avoid going for direct health damage, but if that's what you want.... [http://forums.massassi.net/html/smile.gif]

Also with the print statements, sure they're easy enough to add in, but I believe they'll only print out on the server machine (because the cog isn't running locally, with the "flags=0x240" setting). Although I don't have multiple machines to test this theory, I'm pretty sure that I've heard that print statements will only execute on the server, for a cog like this, but I'll alter it when I get home from work and repost and you can test and let me know [http://forums.massassi.net/html/biggrin.gif]

Hope this helps (if you can survive the wait) [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

PS: Personally, I think this script is finished as it stands, so I think maybe 5.1 for a "patched" version [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

------------------
"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-05-25, 4:09 AM #29
Ok, let's forget the directly-to-health damage then.

And yeah, it should damage a bit 'slower'.

Once you have it done, I'll check out the text thing, see if it works on client - I got 2 comps [http://forums.massassi.net/html/wink.gif]

My main concern is the damage that continues after you leave the surface. That's definitely a big bug that has to be fixed. Once the damage starts, it won't stop. :S

DarthSlaw said:

"Okay, I got about 99% of this code working correctly; the other troublesome 1% is that the player will not stop from being damaged by the timer -- I don't understand why. Maybe another set of eyes will see something I missed.
It seems to be something wrong in the exited message; if the "killtimerex()" line worked, then the player would have his timer damaging thinger stopped and no more damage would be dealt; instead, it continues to run the timer message."

------------------
*There is no death, there is the Force*

[This message has been edited by ORJ_JoS (edited May 25, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-05-25, 5:06 AM #30
(manages to sneak a quick post in while at work) Hmm... you say you continue to take damage even after you leave the surface? Do you mean the player takes continual damage after leaving the surface or they just lose a little bit of health/shields and then the damage effect ends? [http://forums.massassi.net/html/redface.gif] [http://forums.massassi.net/html/confused.gif]

When I tested this script, I jumped onto the force-fielded floor and got hurt, proceeded to jump off the floor and then the damage effect ended. If this isn't what you mean, then please do describe what happens in more detail (maybe a *small* screenshot?), as I'm curious about this effect and can't seem to replicate the problem... [http://forums.massassi.net/html/confused.gif]

Anyways, as I said earlier, when I get home, I'll have a fresh look over this script and try and iron out this timer-based issue bug [http://forums.massassi.net/html/smile.gif], but any further description of the problem you're encountering would be a huge asset [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-05-25, 11:23 AM #31
Hopefully jackpot sees this post before he gets down to work on the cog. Yes, I found the problem.

Apparently, (I didn't know this before) but cogs don't seem to like to terminate timers with the SenderID of 0. My player number (and probably ORJ's as well) was 0, and chances are, jackpot, that yours wasn't, considering you didn't get this bug.

Anyway, I took Jackpot's most recently posted cog, and the floor damage code has been updated, and now it works correctly, all the time. (yay!!! [http://forums.massassi.net/html/biggrin.gif])

And ff damages slower now. 0.25 seconds... what was I thinking? Of course, it was jackpot's variable to begin with, so... [http://forums.massassi.net/html/tongue.gif]

Code:
See below for updated code


------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity

[This message has been edited by Darth Slaw (edited May 25, 2004).]

[This message has been edited by Darth Slaw (edited June 01, 2004).]
May the mass times acceleration be with you.
2004-05-25, 12:47 PM #32
"Too late!" came the cry... [http://forums.massassi.net/html/rolleyes.gif]

Well I started to get to work on it and after trying my best to simulate something, I coudn't any which way I tried, so it looks like your assumption holds true Slaw, about timers not liking a sender ID of 0 - interesting this is... [http://forums.massassi.net/html/biggrin.gif]

(and just to confirm your theory, my player was thing1 - I'd devised a test level the first time around, when I'd been editing with MOTS, and the original walkplayer model (thing0) uses different mats, so when I tested it in JK, it bombed me back to my desktop, so I made thing0 a ghost and thing1 my new test walkplayer...)

NB: I know your alteration works, but it's a bit cheeky coding (maybe "lazy"? [http://forums.massassi.net/html/wink.gif]) to just shove a "+1" for the number comparison [http://forums.massassi.net/html/biggrin.gif]. But that said, if it works then I'll run with it [http://forums.massassi.net/html/smile.gif]

I suppose logistically speaking, it stands to reason that timers can't run with a value of 0 - afterall - if you create a thread with a "0" time run-length, then how is it supposed to execute? Does it loop infinitely or just not start (in JK's case, we've found it to be the latter - the question is: does this qualify us for Daft_Vader's "Editing Hall of Heroes" thread? [http://forums.massassi.net/html/wink.gif])

As for the force-field damage and speed of damage (I was going to mention the latter was my choice of variables Slaw - sorry about that... [http://forums.massassi.net/html/wink.gif]), then you have several options:

1.) Increase the damageInterval variable (you may want to amend your post Slaw, so as that variable isn't local and give the editor some say in the duration - I made it local, just because for myself, I knew I wasn't going to alter that value again...)

or alternatively

2.) You can reduce the minDamage and/or maxDamage variables to inflict less damage upon the player.

Well - here's hoping this really is done and dusted. As for your damage quote ORJ, simply type:
Code:
Print ("The floor is burning hot! You are taking damage!");


... in the "entered" message block, (see where it is sandwiched below - hopefully in italics):
Code:
else
if (status == 0) {
    Print ("The floor is burning hot! You are taking damage!");
    damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
    // rest of code block here // 
}


You never know - maybe Slaw will be kind enough to modify it for you (seeing as it takes ages to copy/paste and edit a cog that's posted here with IE, stupid browser glitch...)

Anyways - I hope that we've all managed to help you and impart some of our infinitely invaluable wisdom unto you, ORJ - hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

[EDIT: I hate UBB code tags *hand meets forehead...*]

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

[This message has been edited by lucky_jackpot (edited May 25, 2004).]
"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-05-25, 1:22 PM #33
I made the amends. Cog is now fitting for ORJ's level [http://forums.massassi.net/html/smile.gif].

It doesn't take me more than a couple seconds to edit code and stuff, btw. And I use IE. Maybe my cable modem makes the difference [http://forums.massassi.net/html/biggrin.gif].

As always, glad to help. [http://forums.massassi.net/html/smile.gif]
Now I just feel bad that I couldn't figure anything out for Edward's two problems [http://forums.massassi.net/html/redface.gif] [http://forums.massassi.net/html/confused.gif] . *shrug*

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity
May the mass times acceleration be with you.
2004-05-26, 5:44 AM #34
I'm speachless... thanks a ton, guys [http://forums.massassi.net/html/biggrin.gif] Thanks a lot for fixing that problem. Sorry for late reaction, I was away yesterday (and look what I missed, lol!)

And just for the record, Jackpot, what I meant was, that once the forcefield was activated, and I stepped onto the surface, I started taking damage, but it wouldn't stop no matter what. I left the forcefield surface and the damage would go on, not for a short period, but continuously. I would die, respawn in a totally different place, and I'd take damage again, die, etc. Infinity loop of taking damage.

But obviously you guys figured out the problem! I hope I can add that text line, what I do is just opening the cog with notepad and insert it in the right place, is that a safe way of doing it?

When I copy the cog from this page, I just paste it in Word, then save as .txt, then change the extension to .cog. It always works for me, but tell me if there's a better way.

I still have to test it, but I'm sure it works now. I'll get back to you.

It never ceases to amaze me what you can do with a cog. With your help, I can do things with my level that I haven't seen before. I can't wait to release it. It's still a couple of months work though. I think I already mentioned it, but if I can interest you for it;

I had an idea for a cog, that I don't think has been made before. I'm not even sure if it's possible, but if it isn't, no biggie...just curious. But that can wait for now. Like I said, I'll test this forcefield cog and be back. (I babble too much, lol)

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-26, 1:09 PM #35
Hey no worries - that's why we're a community [http://forums.massassi.net/html/smile.gif] (and a dang good one at that [http://forums.massassi.net/html/biggrin.gif]) - chances are there's always someone that has an answer and is willing to help you out, as well as teach you a thing or two along the way [http://forums.massassi.net/html/smile.gif]

And yes, the way you suggested will work - basically, as long as the text here ends up in a file with the extension ".cog" then you're all sorted [http://forums.massassi.net/html/smile.gif]

Generally, cog is a pretty flexible language to learn and is rather "forgiving" in many areas, meaning its great for beginners to pick up and start tinkering around with, so just have a play-around and see what else you can do to "spark up" your level. Just earlier this evening, I wrote a hotkeyable "bullet-time" effect (well slow-mo really, but it's the best you're going to get with JK [http://forums.massassi.net/html/wink.gif]) that works a little like Max Payne's concept. I know GBK wrote the original controller for it after SaberMaster's discovery of the flags, but it plays well in a level set I'm creating. Sure, you have more than a few trade-offs with COG scripting, but for your average editor, it's more than capable of extending a basic level's needs...

Just a couple of (semi-precious) thoughts shared with you there, after a while of editing cog [http://forums.massassi.net/html/wink.gif] - I hope they help and inspire you [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)

And he's finally off the starting grid --> Zooooom -@%
"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-05-26, 4:06 PM #36
Alright, it's working!!!! [http://forums.massassi.net/html/biggrin.gif] Again, my thanks, and yes, I do pick up a little here and there.

One tiny little problem; I'll have to take out the line of text. It doesn't work on clients comp. Lol, if the client player is on the surface, the host will see the text. So, I'll have to take that out. Hm, lemme see, what part exactly do I have to delete?

I can't make anything of the statements in the cog, lol.

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-05-26, 10:16 PM #37
I'm glad it's (essentially [http://forums.massassi.net/html/wink.gif]) working for you [http://forums.massassi.net/html/biggrin.gif]

Where the line of text is in the "entered" message block (see my post, 5 posts back, about where you insert the Print("your text here"); line, you can do one of two things:
1) Get the cog to ignore processing of the line (it won't execute this way), by placing a "//" in front of the line
OR
2) Delete the line [http://forums.massassi.net/html/biggrin.gif] (yes, it really is that simple [http://forums.massassi.net/html/wink.gif])

Basically, "find the line of text that's printing the phrase you wanted and delete it" - that's what I was trying to say, in a simple manner [http://forums.massassi.net/html/rolleyes.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)

And he's finally off the starting grid --> Zooooom -@%
"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-05-27, 2:55 AM #38
Lol, ok. I suspected as much, but I was just wondering if any other lines were also 'part of the trigger' for the text bit. Apparently not, hehe, thanks [http://forums.massassi.net/html/smile.gif]

------------------
*There is no death, there is the Force*
ORJ / My Level: ORJ Temple Tournament I
2004-06-01, 1:07 PM #39
Sorry I'm a little late on this, but I just found another bug.
Apparently, if the ff was deactivated, nad you were standing on the ff surface, you would still keep taking damage and you also wouldn't be detached from the surface until you moved. The below code now fixes that little issue. [http://forums.massassi.net/html/smile.gif]
Code:
##
# MOTS Cog Script
#
# 00_MPForceFieldv5.COG
#
# Force-field effect on two adjoined surfaces (ff_front and ff_back)
#
# Will damage player if touched while force-field status is ON.
# May be switched off by either a "console" (thing) or "switch0"/"switch1" (surfaces).
#
# Force-field starts being ON (default: status=1).
# Change status=0 if you want the force-field to be OFF at start.
#
# Version 5 addition:
#   Set isShootableSwitch=1, to be able to toggle the force-field ON/OFF
#   just by shooting either switches or console.
#   To disable this feature, set isShootableSwitch=0.
#
# In JED (or something similiar in JK Edit, if you're so inclined...) :
# NB-01: Set +ADJOIN FLAGS to 5
# NB-02: Set +SURFACE FLAGS to 14007
# NB-03: Set +FACE FLAGS to 2
# NB-04: Set +GEO to value of 'surfaceGeoMode' symbol
#
# Set verbose=1, if you want to see print out messages.
# (More for test purposes than anything else...)
#
# This COG script is NOT supported by LucasArts or LEC.
#
# Permission is granted to use this script by the author, as long as credit
# is provided in the readme file for any add-on levels that use this script.
#
# version 1 : 12-August-2003
# version 2 : 14-August-2003
# version 3 : 04-December-2003 --> Optimised for multi-player!
# version 4 : 18-May-2004      --> Added support for floor force fields
#                                    (this code inspired by lucky_jackpot and
#                                    Zagibu and implemented by Darth Slaw)
#
# version 5 : 24-May-2004      --> Once and for all - this is it !!! (both SP & MP)
#                                      -Jackpot, with thanks to Darth Slaw and Zagibu
#                                       for refinements along the way     [http://forums.massassi.net/html/wink.gif]     [http://forums.massassi.net/html/biggrin.gif]
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##

symbols

message   startup
message   activated
message   entered
message   exited
message   touched
message   damaged
message   timer

surface   ff_front                     linkid=2 mask=0x400
surface   ff_back                      linkid=2 mask=0x400

surface   switch0                      linkid=1 mask=0x408   # Player, actor, weapon
surface   switch1                      linkid=1 mask=0x408
thing     console                      linkid=1 mask=0x408

template  sparks=+heavysmoke           local
flex      damage                       local
flex      damageInterval=0.4           #local
flex      minDamage=2.0
flex      maxDamage=10.0

int       status=1                                           # 1 is ON ; 0 is OFF
int       isShootableSwitch=0                                # 1 is ON ; 0 is OFF

int       tempSound1                   local
int       tempSound2                   local
int       tempSound3                   local
int       tempSound4                   local
int       surfaceGeoMode=4                                   # use 3 for solid mats; 4 for non-solid mats

sound     ff_on=forcefieldon01.wav
sound     ff_off=forcefieldoff01.wav
sound     ff_hum=forcefieldhum01.wav
sound     ff_hit=forcefieldhit01.wav


int       verbose=0                                          # Used as a test variable.  Set to 0 to not print messages...

end

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

code

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


startup:
    if (verbose) {
        Sleep (1.0);    // Allow dust to settle for a bit...
        Print ("Force Field Status COG EXECUTING !!!");
    }

    if (status == 0) {
        if (verbose)
            Print ("Startup: OFF");
        SetWallCel (switch0, 0);
        SetWallCel (switch1, 0);
        call forceField_OFF;
    }
    else if (status == 1) {
        if (verbose)
            Print ("Startup: ON");
        SetWallCel (switch0, 1);
        SetWallCel (switch1, 1);
        call forceField_ON;
    }

    Return;

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


activated:

      // Eliminate any possibility that something other than
      // the on-off switch0 OR console could send the
      // "activated" message...
    if (GetSenderID() != 1)
        Return;

    if (GetSenderID() == 1) {    // Just a double-check to make sure we've got a handle on the right thing...
        if (status == 0) {
            if (verbose)
                Print ("FF IS OFF");
            call forceField_OFF;
        }
        else
        if (status == 1) {
            if (verbose)
                Print("FF IS ON");
            call forceField_ON;
        }
    }

    Return;

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


entered:
    if (GetSenderID() != 2)
        Return;

    if (GetSenderID() == 2) {
        Print ("The floor is burning hot! You are taking damage!");
        if (verbose) {
            Print ("SURFACE TOUCHED !!!!");
            PrintInt (GetSourceRef() );
        }

        if (status == 1) {
            if (verbose)
                Print ("FF DEACTIVATED ---> Safe to Pass !!!");
        }
        else
        if (status == 0) {
            damage = (Rand() * (maxDamage - minDamage) ) + minDamage;

              // Allow for self-inflicted damage (0x2)
              // Change to 0x1 flag to cut straight through shields and do DIRECT health damage....
            DamageThing (GetSourceRef(), damage, 0x2, GetSenderRef() );

              // Sounds stuff
            tempSound3 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);
            tempSound4 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_back), 0.5, 1, 10, 0);

            if (!IsMulti() )
                CreateThing (sparks, GetSourceRef() );  // Do only on evaluative "true" condition
            KillTimerEx (GetSourceRef() + 1);
            SetTimerEx (damageInterval, GetSourceRef() + 1, 0, 0);
        }
    }

    Return;

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


exited:

      //wasn't one of our ff surfaces
    if (GetSenderID() != 2)
        Return;

    if (verbose) {
        Print ("Detatched");
        PrintInt (GetSourceRef() );
    }

    KillTimerEx (GetSourceRef() + 1);

    Return;

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


touched:

    if (GetSenderID() != 2)
        Return;

    if (GetSenderID() == 2) {
        if (verbose)
            Print ("SURFACE TOUCHED !!!!");
        if (status == 1) {
            if (verbose) {
                Print ("SAFE TO PASS - OK");
                Print ("FF is off so don't damage...");
            }
        }
        else
        if (status == 0) {
            if (verbose)
                Print("OUCH !!!");
            damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
              // Allow for self-inflicted damage (0x2)
              // Change to 0x1 flag to cut straight through shields and do DIRECT health damage....
            DamageThing (GetSourceRef(), damage, 0x2, GetSenderRef() );
              // Sounds stuff
            tempSound3 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);
            tempSound4 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_back), 0.5, 1, 10, 0);

            if (!IsMulti() )
                CreateThing (sparks, GetSourceRef() );
        }
    }

    Return;

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

damaged:

      // This clause allows the switch to be shot and alter the force-field state.
    if (isShootableSwitch) {
        if (GetSenderID() ==1) {
            if (verbose)
                Print ("If WALLS could talk, we'd say: OUCH - that's a chunk of my brickwork !!!!");
            if (status == 1)
                call forceField_ON;
            else
                call forceField_OFF;
        }
    }

      // If we reach this evaluation, then we know that this is a player...
    if (GetParam (1) == 1) {
        if (GetThingType (GetSourceRef() ) != 10)   // Don't hurt anything that isn't a player!
            Return;
        damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
        DamageThing (GetSourceRef(), damage, 0x1, GetSenderRef() ); // Do physical damage
    }

    Return;

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

timer:

    if(status == 0)
        SetTimerEx(damageInterval, GetSenderID(), 20, 0);
    else {
        DetachThing(GetSenderID() - 1);
        //ApplyForce(GetSenderID() - 1, VectorScale(GetThingLVec(GetSenderID() - 1), 0.1));
        Return;
    }
    if(verbose)
        PrintInt (GetSenderID() - 1);
    damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
    DamageThing (GetSenderID() - 1, damage, 0x2, GetSenderID() - 1);
    tempSound3 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);
    tempSound4 = PlaySoundPos (ff_hit, GetSurfaceCenter (ff_back), 0.5, 1, 10, 0);

    if (!IsMulti() )
        CreateThing (sparks, GetSenderID() - 1);

    Return;

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

forceField_ON:

    PlaySoundPos (ff_on, GetSurfaceCenter (switch0), 0.5, 1, 10, 0);  // Play On sound - switch0
    PlaySoundPos (ff_on, GetThingPos (console), 0.5, 1, 10, 0);   // Play On sound - console

      // Floor; Used in COG; Impassable; Magsealed
    SetSurfaceFlags (ff_front, 0x14007);
    SetSurfaceFlags (ff_back, 0x14007);
      // Not passable
    ClearAdjoinFlags (ff_front, 0x2);
    ClearAdjoinFlags (ff_back, 0x2);
      // Geo-mode
    SetFaceGeoMode (ff_front, surfaceGeoMode);   // Surface face
    SetFaceGeoMode (ff_back, surfaceGeoMode);   // is drawn...
    SetFaceType (ff_front, 0x2);      // Surface Face Type Info
    SetFaceType (ff_back, 0x2);      // Set face type to "translucent"
      // Sounds stuff
    tempSound1 = PlaySoundPos (ff_hum, GetSurfaceCenter (ff_front), 1.5, 2.0, 10.0, 0x1);
    tempSound2 = PlaySoundPos (ff_hum, GetSurfaceCenter (ff_back), 1.5, 2.0, 10.0, 0x1);
      // Set wall cell mat info
    SetWallCel (switch0, 1);
    SetWallCel (switch1, 1);

      // Reset status to 0 - OFF
    status = 0;

    Return;

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

forceField_OFF:

    PlaySoundPos (ff_off, GetSurfaceCenter (switch0), 0.5, 1, 10, 0); // Play Off sound - switch0
    PlaySoundPos (ff_off, GetThingPos (console), 0.5, 1, 10, 0);  // Play Off sound - console

      // Surface flags
    ClearSurfaceFlags (ff_front, 0x14007);
    ClearSurfaceFlags (ff_back, 0x14007);
      // Adjoins info
    SetAdjoinFlags (ff_front, 0x2);
    SetAdjoinFlags (ff_back, 0x2);
      // Geo-mode
    SetFaceGeoMode (ff_front, 0);    // Don't draw surface
    SetFaceGeoMode (ff_back, 0);
      // Surface Face Type Info
    ClearFaceType (ff_front, 0x2);
      // Clears translucency
    ClearFaceType (ff_back, 0x2);
      // Sounds stuff
    StopSound (tempSound1, 0.5); // Stop hum sound
    StopSound (tempSound2, 0.5);
    StopSound (tempSound3, 0.2);
    StopSound (tempSound4, 0.2);
      // Set wall cell mat info
    SetWallCel (switch0, 0);
    SetWallCel (switch1, 0);

      // Reset status to 1 - ACTIVE
    status = 1;

    Return;

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

end

Just replace your current ff cog with this one and you've successfully updated your cog -- I only added a few if statements and a few commands into the timer message -- no new symbols. No need to go to Jed and reassign your parameters. [http://forums.massassi.net/html/smile.gif]

Now let's hope this is the last fix we need to make. [http://forums.massassi.net/html/smile.gif] [http://forums.massassi.net/html/biggrin.gif]

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity

[This message has been edited by Darth Slaw (edited June 01, 2004).]
May the mass times acceleration be with you.
2004-06-01, 1:38 PM #40
Wow, Slaw, that's really cool. You checked it even more and removed the last bug! In my level I didn't detect that bug, because I tested it on a surface that is passable when the FF is off...so...thanks a lot.

Lol, my level is going to be really big, and will feature some new ideas (I think). The credit list for the cogs is going to have a lot of names on it! [http://forums.massassi.net/html/biggrin.gif]

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

"There is no death, there is the Force."

Long live JK! =Best Game Ever=

[This message has been edited by ORJ_JoS (edited June 01, 2004).]
ORJ / My Level: ORJ Temple Tournament I

↑ Up to the top!