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 → ForceField Sounds
ForceField Sounds
2003-12-02, 5:17 PM #1
i have a problem with my cog, everything is good on it, except the host is the only one that hears the sounds when you activate the surface.please help to find out what is wrong, and reply with the edited cog.

Code:
##
# MOTS Cog Script
#
# 00_simpleForceField.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 switch (surface).
# Force-field starts being ON (default: status=1).
# Change status=0 if you want the force-field to be OFF at start.
#
# 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 4
#
# 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
#
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##


symbols

message startup
message activated
message touched
message damaged
message timer

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

surface switch      linkid=1
thing    console     linkid=1

template    sparks=+heavysmoke                  local

#thing   player      local
thing   playerReference     local
thing   victim      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     damaging=1   local

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

int     tempSound1  local
int     tempSound2  local
int     tempSound3  local
int     tempSound4  local

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

end

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


code

startup:

    if (verbose)
        Sleep (2.5);    // Allow dust to settle for a bit...
        Print ("Force Field Status COG EXECUTING !!!");

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

    return;

#------------------------------------------------------

activated:

    playerReference = GetLocalPlayerThing();

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

    if (GetSenderID() == -1)
        return;

    if (GetSenderID() == 1) {
            if (status == 0) {
                if (verbose)
                Print ("FF IS OFF");
                SetWallCel (switch, 0);
                call forceField_OFF;
            }
            else
            if (status == 1) {
                if (verbose)
                Print ("FF IS ON");
                SetWallCel (switch, 1);
                call forceField_ON;
            }
    }

    return;

#------------------------------------------------------
touched:

    if (GetSenderID() != 2)
        return;

    playerReference = GetLocalPlayerThing();
    victim = GetSourceRef();

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

        if (status == 1) {
            if (verbose)
                // Strange - you would have thought status would
                // have to be 1 to be ON and damage player, but nevermind
                // - the script works... ;p
                Print ("SAFE TO PASS - OK");
                Print ("FF is off so dont 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 (playerReference, 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, victim);
            damaging = 0;
            SetTimer (damageInterval);
        }
    }

    return;

#------------------------------------------------------

damaged:

    if (GetParam (1) == 1) {
        //player = GetThingParent (GetSourceRef() );
        player = GetSourceRef();

        if (GetThingType (player) != 10)
            return;

        damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
        DamageThing (player, damage, 0x01, player);
    }

    return;

#------------------------------------------------------

timer:

    damaging = 1;
    return;

#------------------------------------------------------

forceField_ON:

        // Floor; Used in COG; Impassable; Magsealed
    SetSurfaceFlags (ff_front, 0x14007);
    SetSurfaceFlags (ff_back, 0x14007);
        // Not passable
    ClearAdjoinFlags (ff_front, 0x2);
    ClearAdjoinFlags (ff_back, 0x2);  // ALT: SetAdjoinFlags (ff_back, 0x5);
        // Geo-mode
    SetFaceGeoMode (ff_front, 4);   // Surface face
    SetFaceGeoMode (ff_back, 4);   // is drawn...
        // Surface Face Type Info
    SetFaceType (ff_front, 0x2);  // Translucent
    SetFaceType (ff_back, 0x2);
        // Sounds stuff
    PlaySoundLocal (ff_on, 1, 0, 0x0); // Play On sound
    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 (switch, 1);
        // Reset status to 0 - OFF
        // (think that status should be 1 ?? Try it and see what happens...    [http://forums.massassi.net/html/wink.gif]
    status = 0;

    return;

#------------------------------------------------------

forceField_OFF:

        // Surface flags
    ClearSurfaceFlags (ff_front, 0x14007);
    ClearSurfaceFlags (ff_back, 0x14007);
        // Adjoins info
    SetAdjoinFlags (ff_front, 0x2);
    SetAdjoinFlags (ff_back, 0x2);    // ALT: SetAdjoinFlags (ff_back, 0x7);
        // 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);     //SetFaceType (ff_back, 0x0);
        // Sounds stuff
    StopSound (tempSound1, 0.5);  // Stop hum sound
    StopSound (tempSound2, 0.5);
    StopSound (tempSound3, 0.2);
    StopSound (tempSound4, 0.2);
    PlaySoundLocal (ff_off, 1, 0, 0x0); // Play Off sound
        // Set wall cell mat info
    SetWallCel (switch, 0);
        // Reset status to 1 - ACTIVE
        // (think that status should be 0 ?? Try it and see what happens...    [http://forums.massassi.net/html/wink.gif]
    status = 1;

    return;

#------------------------------------------------------

end


------------------
Your Owners Clan Leaader,
_yo_wasup_
-=__/¯¯l¤¥Ø¤l¯¯\__\/\/ª≤uÞ_=-
http://www.TeamYo.org
2003-12-03, 2:03 AM #2
Wow - old code... [http://forums.massassi.net/html/wink.gif]

Personally, I don't see any reason why it doesn't work (although I do see a few bits of redundant code in there, at a second glance).

The main activation sounds are played locally ("PlaySoundLocal()" verb) so I don't see why it should play solely for the host and not the clients. Maybe if you make it so that it reads "PlaySoundGlobal()" (with the various flagged parameters, naturally), that may fix it - unfortunately I don't have access to the DataMaster at work, but if you have a read through under the "Sounds" verbs in the "Cogs" section (fairly self explanatory that... [http://forums.massassi.net/html/wink.gif]) then there should be an appropriate verb for you to choose from.

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

-Jackpot

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

Initiator of the "Bring Back Jan Ors" Campaign!

"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-03, 2:06 AM #3
LJ, do you know any cog at all?

in a multipalyer game playsound localy allways palys the sound for the host adn not the clients, jsut as getlocalpalyer thing allways reurns the host.. (note that jkgetlocalplayer returns the local palyer of the cog) but you are right in sayig he shoudl use playsoundglobal insted.... thats your saveing grase [http://forums.massassi.net/html/biggrin.gif]

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

rule three, "asprines good, but it hasent got the kick of morphine. and its not gonna stop the hurting in my arm, the ones thats on the otherside of the room i mean" -the alternatior
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-03, 3:28 AM #4
Quote:
<font face="Verdana, Arial" size="2">
Orginally posted by: [SF]pjb
LJ, do you know any cog at all?
</font>

Excuse me, but I find your phrasing in that sentence to be exceptionally rude PJB! That comment was totally uncalled for and unnecessary. Geez, I do my best to help the community and if it's not one thing, I get slated by another! Please show your fellow editors, coggers and Massassians a little courtesy and refrain from negative commentary in future, as I (for one) have no desire to cross-swords with anyone here at Massassi...

For your information, when I wrote the original version of the script, it was for a single-player level, so the "sound-issue" never arose! But as you didn't know this I won't hold it against you [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/tongue.gif]

Likewise from my perspective, when I wrote the cog script with "single-player" in mind, I expect it to be used in single-player [http://forums.massassi.net/html/smile.gif]. How was I to know that the editor was going to use the script for multi-player? Admittedly, the base script doesn't change too much, but it's just little things like sound setting that need changing - nothing drastic. I think you'll find everything else works correctly with that cog script, so to answer your question:

"Yes", pjb, "I DO know some cog!!!" [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

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

Initiator of the "Bring Back Jan Ors" Campaign!

"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-03, 3:47 AM #5
although i dident mean wha i said in a rude way.

Quote:
<font face="Verdana, Arial" size="2">
The main activation sounds are played locally ("PlaySoundLocal()" verb) so I don't see why it should play solely for the host and not the clients.
</font>


that is you talking.. and it makes no sence... you need to brush up on the basics if you cant rember that playsoundlocal palys on teh host in MP.. of corse yove proebly been working in JO icarus or something for a while and forgot it.. but either way.. you could give some one a bad idea with misinformation..

bu if you took my comment rudely i do apologise..

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

rule three, "asprines good, but it hasent got the kick of morphine. and its not gonna stop the hurting in my arm, the ones thats on the otherside of the room i mean" -the alternatior
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-03, 4:04 AM #6
Yes... I can see what you mean [http://forums.massassi.net/html/wink.gif]

It was just the manner you mentioned it - I'd hoped you meant it as a more joking "off-the-cuff" comment than a flat-out insult [http://forums.massassi.net/html/wink.gif]. As I mentioned, the script's purpose was marginally different than that for which it was originally intended...

As daft as it sounds, the part of my earlier post you quoted was a clear mistake on my part - it was early in the day and I hadn't got my brain in-gear with regard to how I phrased it... which is rightfully why you noticed it and pulled it apart [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/smile.gif]

And apology accepted [http://forums.massassi.net/html/smile.gif]. Admittedly the fault of expression in the original phrase lies squarely with me. Still - no hard feelings pjb? [http://forums.massassi.net/html/biggrin.gif]. I was (and still am) just trying to help out the community, just like you [http://forums.massassi.net/html/smile.gif] - we're all doing our best to valiantly cling to an age-old game... [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

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

Initiator of the "Bring Back Jan Ors" Campaign!

"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-03, 9:56 AM #7
Code:
PlaySoundLocal (ff_on, 1, 0, 0x0); 


I dont like this. SoundLocal basicly dont work for MP (it gets local as host's place, so ONLY host hear this). Try to replace this with playsound attacked to surface (so other players will also hear it, ALSO when there will be more players in area). Should work fine.

------------------
The miners of Kiith Somtaaw sacificed much, and risked all. For their efforts they were brought into the inner most circle of Hiigaren power. Naabal, S'jet, and Sobanii bowed before them. And from that day to this, Somtaaw's children have been known to one and all as Beastslayers..
2003-12-03, 10:13 AM #8
Why don't you use the PlaySoundPos(SurfaceCenter(surf), etc etc) instead of the PlaySoundLocal()? Or something similar. You said that only the on/off sounds at the switches don't work, and you said nothing about FF surface issues. Besides that, you'd only hear the sounds if you were close to the switch or the FF.
(Yeah, What AceCSF said! [http://forums.massassi.net/html/biggrin.gif] )

SIDENOTE ALERT!
Oh, and are you using my FF cog at all (just curious [http://forums.massassi.net/html/smile.gif] )?

------------------
We are Slaw of Borg.
You will be assimilated.
Resistance is futile.
-Darth Slaw, Dark Lord of the Borg

[This message has been edited by Darth Slaw (edited December 03, 2003).]
May the mass times acceleration be with you.
2003-12-03, 10:59 AM #9
darth, as it says in the cog, jackpot made it. he also mentioned it in the replies.but like 500 different people said to put different things, like attack, global, local, soundpos, man, can i have the correct one?

if you know the correct cog, copy the cog and paste the new one with the problem fixed. and if you know how to make a new sound when you shoot the forcefield, that would be also appreciated.

------------------
Your Owners Clan Leaader,
_yo_wasup_
-=__/¯¯l¤¥Ø¤l¯¯\__\/\/ª≤uÞ_=-
http://www.TeamYo.org
2003-12-03, 11:52 AM #10
Ok - nice and simple reply, so no-one misinterprets this [http://forums.massassi.net/html/wink.gif] :

Replace "PlaySoundLocal" with "PlaySoundGlobal" (minus the quotation marks). A simple "find and replace" will do the trick - mostly all text-editors have this feature so it can't possibly get any easier and simpler [http://forums.massassi.net/html/wink.gif]

Quote:
<font face="Verdana, Arial" size="2">
Orginally posted by EH_AceCSF:
I dont like this. SoundLocal basicly dont work for MP (it gets local as host's place, so ONLY host hear this)
</font>


Sorry, but you're a bit late Ace - pjb and I have already gone through this discussion and arrived at the mutual decision that "PlaySoundGlobal" is the best verb to use in this situation; please refer to one of my earlier posts, where I said "when I wrote the cog script with "single-player" in mind, I expect it to be used in single-player [http://forums.massassi.net/html/smile.gif]" - I clearly state that this script's original intention was for single-player, but replacing PlaySoundLocal with PlaySoundGlobal will make it compatible with multi-player [http://forums.massassi.net/html/wink.gif]

Darth Slaw - with regard to hearing the sounds if you were close to the switch or the FF - that's the point of using PlaySoundPos() with the ff surface "centers" - after all you don't want to waste processing power on generating sound throughout the whole level and PlaySoundPos will make it seem more realistic as you will only hear the ff "hum" if it is switched on and the player is near the ff. Essentially, if sound is played at a position in-game (using PlaySoundPos verb) it will use a minimum and a maximum radius, and will therefore play constantly anyway, host or client side. The DataMaster has quite a detailed "Notes" section, if you check "Cog Menu -> Cog Verbs -> Sounds" [http://forums.massassi.net/html/biggrin.gif]

Hope this helps - the upshot YourOwners: every time you see the word PlaySoundLocal crop up, replace it with PlaySoundGlobal [http://forums.massassi.net/html/biggrin.gif]

Et voila - 1 complete working mp ff script [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

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

Initiator of the "Bring Back Jan Ors" Campaign!

"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-03, 12:03 PM #11
I wasn't referring to Jackpot's cog. I just wanted to know if mine was being implemented, too.
I would say to replace the playsoundlocal lines with these two:
Code:
PlaySoundPos (ff_on, GetSurfaceCenter (switch), 0.5, 1, 10, 0);
PlaySoundPos (ff_on, console, 0.5, 1, 10, 0);

I say this because the click sound would only be heard at the switch/ff, not 5 miles from it! This is what I did in my cog (except I played clicking sounds at the switches and ff (de)activation sounds at the ff)
Though, I'm not sure if PlaySoundPos() will play on all the clients' PC's. If it doesn't, definitely listen to Jackpot.

[edit]
On second thought, I think I'll leave this one open to Jackpot, being his cog and all. Listen to him--he obviously knows what he's talking about. (my cog already should have these things fixed if PlaySoundPos works on all pc's)

------------------
We are Slaw of Borg.
You will be assimilated.
Resistance is futile.
-Darth Slaw, Dark Lord of the Borg

[This message has been edited by Darth Slaw (edited December 03, 2003).]
May the mass times acceleration be with you.
2003-12-03, 10:23 PM #12
I was thinking last night (geez - hazy crazy day yesterday) that you may well have a point there Darth Slaw... [http://forums.massassi.net/html/eek.gif]. I've spent far too much of this week editing instead of cogging [http://forums.massassi.net/html/redface.gif]

PlaySoundPos should work on both server and client-sides. And you are quite right about the observation of playing it from a fixed position, as opposed to hearing it play globally throughout the whole level! I'm having an absolute nightmare of a cogging week (Grrr - too much Java-coding-for-fun" [http://forums.massassi.net/html/redface.gif]) - roll on next week...

So ok, ok - I've been avoiding it for as long as possible, but I'll repost the ammended cog when I get home from work... *shrugs accompanied by sigh* [http://forums.massassi.net/html/rolleyes.gif]

Until then (when something inevitably crops up)... That's the thing about coding/scripting - there'll always be a "next time" due to the "WHY didn't it work the first time" question [http://forums.massassi.net/html/rolleyes.gif]. Hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

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

Initiator of the "Bring Back Jan Ors" Campaign!

"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-04, 1:33 AM #13
PlaySoundLocal and PlaySoundGlobal are basicly bad for MP. Its couse if you play Local only host will hear it, if global, all will hear (also those who never seened the forcefield so this will be REALLY strange). Those werbs works OK for SP becouse there is only 1 player that can hear them

------------------
The miners of Kiith Somtaaw sacificed much, and risked all. For their efforts they were brought into the inner most circle of Hiigaren power. Naabal, S'jet, and Sobanii bowed before them. And from that day to this, Somtaaw's children have been known to one and all as Beastslayers..
2003-12-04, 3:56 AM #14
Whenever you're in doubt of something, crack open an LEC cog, like m2_ffieldswitch.cog, which clearly uses PlaySoundPos() [http://forums.massassi.net/html/smile.gif]

------------------
-Blessed Be-
I know it's the last day on earth,
We'll be together while the planet dies.

DBZ: The Destruction is Real
-Hell Raiser
2003-12-04, 8:52 AM #15
Ok, ok - version 3 of this blinkered script... [http://forums.massassi.net/html/rolleyes.gif]. Oh well - here it is in all its glory (and if you don't like it, then you can use someone else's because I'm tired of seeing the same arguments put forward about the "sound" issue. Geez - I made one initial miscalculation (thinking it was single-player, not multi-player it was being used for) and everyone jumps on the "Let's linch Jackpot" train... [http://forums.massassi.net/html/rolleyes.gif] [http://forums.massassi.net/html/wink.gif]). PlaySoundPos() now works with both the "activatable" console and/or switch. I've tested it as best I can, everything working for myself (taking into consideration I don't have multiple machines to test multi-player gameplay issues...)

* /ends a "half-rant" [http://forums.massassi.net/html/wink.gif] *

So let us go forth, be happy and play around with force-fields in multiplayer [http://forums.massassi.net/html/wink.gif]

Code:
##
# MOTS Cog Script
#
# 00_multiplayerForceField.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 switch0ed off by either a console (thing) or switch0 (surface).
# Force-field starts being ON (default: status=1).
# Change status=0 if you want the force-field to be OFF at start.
#
# 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 4
#
# 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!
#
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##


symbols

message startup
message activated
message touched
message damaged
message timer

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

surface switch0     linkid=1
thing    console     linkid=1

template    sparks=+heavysmoke                  local

thing   playerReference     local
thing   victim      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     damaging=1   local

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

int     tempSound1  local
int     tempSound2  local
int     tempSound3  local
int     tempSound4  local


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);
        call forceField_OFF;
    }
    else
    if (status == 1) {
        if (verbose)
            Print ("startup: ON");
        SetWallCel (switch0, 1);
        call forceField_ON;
    }

    return;

#------------------------------------------------------

activated:

    playerReference = GetLocalPlayerThing();

        // 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) {
        if (status == 0) {
            if (verbose)
            Print ("FF IS 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
            SetWallCel (switch0, 0);
            call forceField_OFF;
        }
        else
        if (status == 1) {
            if (verbose)
            Print ("FF IS 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
            SetWallCel (switch0, 1);
            call forceField_ON;
        }
    }

    return;

#------------------------------------------------------
touched:

    if (GetSenderID() != 2)
        return;

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

        if (status == 1) {
            if (verbose)
                // Strange - you would have thought status would
                // have to be 1 to be ON and damage player, but nevermind
                // - the script works... ;p
                Print ("SAFE TO PASS - OK");
                Print ("FF is off so dont 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());
            damaging = 0;
            SetTimer (damageInterval);
        }
    }

    return;

#------------------------------------------------------

damaged:

    if (GetParam (1) == 1) {

        if (GetThingType (GetSourceRef() ) != 10)
            return;

        damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
        DamageThing (GetSourceRef(), damage, 0x01, GetSenderRef() );
    }

    return;

#------------------------------------------------------

timer:

    damaging = 1;
    return;

#------------------------------------------------------

forceField_ON:

        // Floor; Used in COG; Impassable; Magsealed
    SetSurfaceFlags (ff_front, 0x14007);
    SetSurfaceFlags (ff_back, 0x14007);
        // Not passable
    ClearAdjoinFlags (ff_front, 0x2);
    ClearAdjoinFlags (ff_back, 0x2);  // ALT: SetAdjoinFlags (ff_back, 0x5);
        // Geo-mode
    SetFaceGeoMode (ff_front, 4);   // Surface face
    SetFaceGeoMode (ff_back, 4);   // is drawn...
        // Surface Face Type Info
    SetFaceType (ff_front, 0x2);  // Translucent
    SetFaceType (ff_back, 0x2);
        // 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);
        // Reset status to 0 - OFF
        // (think that status should be 1 ?? Try it and see what happens...
    status = 0;

    return;

#------------------------------------------------------

forceField_OFF:

        // Surface flags
    ClearSurfaceFlags (ff_front, 0x14007);
    ClearSurfaceFlags (ff_back, 0x14007);
        // Adjoins info
    SetAdjoinFlags (ff_front, 0x2);
    SetAdjoinFlags (ff_back, 0x2);    // ALT: SetAdjoinFlags (ff_back, 0x7);
        // 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);     //SetFaceType (ff_back, 0x0);
        // 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);
        // Reset status to 1 - ACTIVE
        // (think that status should be 0 ?? Try it and see what happens...
    status = 1;

    return;

#------------------------------------------------------

end


There it is, so you eager beavers can analyse, suggest and pull it apart [http://forums.massassi.net/html/wink.gif]. I think I've ironed out all the major issues, plus tidied it up some (in places). Otherwise, do let me know.

Secretly, I want to go for version 4... [http://forums.massassi.net/html/wink.gif]

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

-Jackpot

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

Initiator of the "Bring Back Jan Ors" Campaign!

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