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 cog
Forcefield cog
2003-08-09, 6:01 PM #1
I need a simple forcefield cog that when the game starts up, the force field will be off, and can be turned on with a switch or console.

------------------
Dark-Vane
[This message has been edited by Vane (edited Tuesday, 1212).]
There's only one thing that im scared of, and it's Pixels... THERE EVERYWHERE!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH! *runs through a wall*
2003-08-10, 6:43 AM #2
OK, very simple...
First find a pair of adjoins (back to back, of course), and do so that they are impassable with a magneticly sealed flag (and if you want, the transulcent flag), and then make a COG.
Code:
# ForceField cog
#
# By Edward
symbols

message    startup
message    activated

surface    ff1
surface    ff2
# Forcefield surface, link them with the back and front of the wall you made

surface    switch
# If you need 2, then set switch1 and switch2
thing      console
# that if you want a console to turn the ForceField on/off

int        on=0    local

end
#
code
startup:
        SetFaceGeoMode(ff1,0);
        SetFaceGeoMode(ff2,0);
        // Turn the visibility off
        SetAdjoinFlags(ff1,0x2);
        SetAdjoinFlags(ff2,0x2);
        // Making it passable
return;
activated:
        If(GetSenderRef()==switch) //Or what ever
        {
            If(on==0) //is it on?
            {
                SetFaceGeoMode(ff1,4);
                SetFaceGeoMode(ff2,4);
                // Make it visable
                ClearAdjoinFlags(ff1,0x2);
                ClearAdjoinFlags(ff2,0x2);
                //Non passable
            }
            else
            {
                //Do the same as in the startup
            }
        }
return;
end

And of course you can either add a seperate cog called Damagewall, or ask someone to implement it into this COG. Why can't I? I've gotta go... Busy busy!

/Edward
Edward's Cognative Hazards
2003-08-11, 4:10 PM #3
Hi there [http://forums.massassi.net/html/smile.gif]

I saw your dilemma and thought I could help out [http://forums.massassi.net/html/smile.gif] Not to mention I needed a custom force-field cog script for my single-player level series, so I hope this meets both our needs... [http://forums.massassi.net/html/wink.gif]

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.
#
# 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.
#
# 12-August-2003
#
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##


symbols

message startup
message activated
message touched
message damaged
message timer

surface ff_front    linkid=0
surface ff_back    linkid=0

surface switch      linkid=1
thing    console     linkid=1

template    sparks=+heavysmoke                  local

thing   player      local
thing   victim      local

flex    damageInterval=0.25

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     verbose=0                   # Used as a test variable.  Set to 0 to not print messages...

end

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


code

startup:

    if (verbose)
        Print ("Force Field Status: ON");

    if (status == 0) {
            // Surface flags
        ClearSurfaceFlags (ff_front, 4007);
        ClearSurfaceFlags (ff_back, 4007);
            // Adjoins info
        SetAdjoinFlags (ff_front, 2);
        SetAdjoinFlags (ff_back, 2);    // 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, 2);    // Clears translucency
        ClearFaceType (ff_back, 2);
            // Sounds stuff - don't play on startup
        //StopSound (ff_hum, 1);  // Stop hum sound
        //PlaySoundLocal (ff_off, 1, 0, 0x0); // Play Off sound
            // Set wall cell mat info
        SetWallCel (switch, 1);
            // Reset status to 0 - OFF
        status = 0;
    }
    else {
            // Surface flags
        SetSurfaceFlags (ff_front, 4007);
        SetSurfaceFlags (ff_back, 4007);
            // Adjoin flags - not passable
            // Alternatively, could use: SetAdjoinFlags (ff_front, 5);
        ClearAdjoinFlags (ff_front, 2);
        ClearAdjoinFlags (ff_back, 2);
            // Geo-mode
        SetFaceGeoMode (ff_front, 4);   // Surface face
        SetFaceGeoMode (ff_back, 4);   // is drawn...
            // Surface Face Type
        SetFaceType (ff_front, 2);  // Translucent
        SetFaceType (ff_back, 2);
            // Sounds stuff - play only on one side...
        PlaySoundPos (ff_hum, GetSurfaceCenter (ff_front), 1.5, 2.0, 10.0, 0x1);
            // Wall cell's information setting...
        SetWallCel (switch, 1);      // Assuming 1 is the "ON/ACTIVE" cell...
            // Reset status to 1 - ON
        status = 1;
    }

    return;

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

activated:

    if (verbose)
        Print ("FF Switch / Console ACTIVATED");

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

    if (status == 0) {
        if (verbose)
            Print ("FF IS ON");

            // Floor; Used in COG; Impassable; Magsealed
        SetSurfaceFlags (ff_front, 4007);
        SetSurfaceFlags (ff_back, 4007);
            // Not passable
        ClearAdjoinFlags (ff_front, 2);
        ClearAdjoinFlags (ff_back, 2);  // 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, 2);  // Translucent
        SetFaceType (ff_back, 2);
            // Sounds stuff - only play on one side, for performance issues
        PlaySoundPos (ff_hum, GetSurfaceCenter (ff_front), 1.5, 2.0, 10.0, 0x1);
            // Set wall cell mat info
        SetWallCel (switch, 0);
            // Reset status to 1 - ACTIVE
        status = 1;
    }
    else {
        if (verbose)
            Print ("FF IS OFF");

            // Surface flags
        ClearSurfaceFlags (ff_front, 4007);
        ClearSurfaceFlags (ff_back, 4007);
            // Adjoins info
        SetAdjoinFlags (ff_front, 2);
        SetAdjoinFlags (ff_back, 2);    // 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, 2);    // Clears translucency
        ClearFaceType (ff_back, 2);
            // Sounds stuff
        StopSound (ff_hum, 1);  // Stop hum sound
        PlaySoundLocal (ff_off, 1, 0, 0x0); // Play Off sound
            // Set wall cell mat info
        SetWallCel (switch, 1);
            // Reset status to 0 - OFF
        status = 0;
    }

    return;

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

    if (GetSenderID() != 0)
        return;

    if (damaging == 0)
        return;

    victim = GetSourceRef();

    damage = (Rand() * (maxDamage - minDamage) ) + minDamage;
    DamageThing (victim, damage, 0x2, victim);  // Allow for self-inflicted damage

        // Only play sound on one side for performance issues.
    PlaySoundPos (ff_hit, GetSurfaceCenter (ff_front), 0.5, 1, 10, 0);

    if (!IsMulti() )
        CreateThing (sparks, victim);
    damaging = 0;
    SetTimer (damageInterval);

    return;

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

damaged:

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

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

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

    return;

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

timer:

    damaging = 1;
    return;

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

end


Anyways possibly time for bed now [03:06am], so you'll have to forgive me if there are any errors. I haven't had time to test it out, but everything should work in theory... Famous last words, hey... [http://forums.massassi.net/html/wink.gif]

Let me know if you have any problems and I'll get to ironing them out for you [http://forums.massassi.net/html/smile.gif]

------------------
"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-08-11, 4:22 PM #4
the cog you gave me lucky_jackpot crashed my game when i tried to use the console to activate it

------------------
Dark-Vane
[This message has been edited by Vane (edited Tuesday, 1212).]
There's only one thing that im scared of, and it's Pixels... THERE EVERYWHERE!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH! *runs through a wall*
2003-08-12, 12:18 AM #5
Strange - must have overlooked something - I'll try and fix that "rather noticeable" bug... hmmm....

With a cursory glance, I can't see anything that's wrong, but I'll get back to you when I've tried and tested it...

-Jackpot

------------------
"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-08-12, 2:27 PM #6
Just looking over the cog, it's obvious that the max and min damage aren't defined and that the 'on' sound isn't used. But other than that, I don't see anything that will crash JK. Make sure that it's not something else in the level that's crashing.

BTW, lucky, Parsec would have told you the above - it's always a good thing to double-check a cog before posting it.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-08-12, 11:44 PM #7
Hi there all [http://forums.massassi.net/html/smile.gif]

Yes SaberMaster, I too realised that the "on" sound wasn't used when I looked at it yesterday (spent most of yesterday trying to fix up the COG to see what could have gone so wrong for Vane)...

Other than that I've modified some sections of it but no sooner than you fix one problem than another springs up. Now I'm having trouble with the magsealing the surface flag (sure I've got DataMaster for all the flags and cog verbs [http://forums.massassi.net/html/wink.gif], but it doesn't change the fact that in-game it doesn't seem to work quite right for me... hmmm...

Anyway - I'm still working on it, but I'll give Parsec a whirl and see what all the fuss is about [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"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-08-13, 5:21 PM #8
Is the problem fixed or is the cog still crashing? And if it's fixed, what was the problem?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-08-14, 1:35 AM #9
Well from the extensive testing that I've done (!! - it's starting to test my patience now...), I can't get it to crash. I'm guessing that the adjoins weren't actually adjoined with Vane's level, but even so, wouldn't that cause HOM more than anything else?

If I still haven't fixed it by this evening, (that's probably American afternoon time ?)then I'll post what I've re-done to the original. Well I'll try - I'm busying trying to find an industrial year placement as part of my uni course, and I'm waiting on various phonecalls etc, but I'll see what I can do - just don't hold anything to time [http://forums.massassi.net/html/wink.gif]

(and try as I might, I just can't get the surface to magseal itself. I've set the right flags and used the correct verbs, but it still eludes me. Anyways, I'll leave that until it's posted... [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"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-08-14, 5:39 AM #10
At last !!! Finally got things sorted out with this cog !!! lol

I've learnt some important lessons while doing this script and SaberMaster - if you don't mind me saying ... Parsec rules !!! [http://forums.massassi.net/html/biggrin.gif] (reminds me a little of a Java compiler, the way it displays the errors, complete with descriptions - and here was me trying to escape Java [http://forums.massassi.net/html/wink.gif] )

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


Basically, I've just tidied eveything up, and there should be no reason why this should crash because I've tested it thoroughly (and I'll email you my quick demo level if you want Vane ?) [http://forums.massassi.net/html/smile.gif]

------------------
"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 August 14, 2003).]
"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-08-14, 8:12 AM #11
I guess i could use the demo level
send it over
darkvane@sympatico.ca

------------------
Dark-Vane
[This message has been edited by Vane (edited Tuesday, 1212).]
There's only one thing that im scared of, and it's Pixels... THERE EVERYWHERE!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH! *runs through a wall*
2003-08-14, 9:58 AM #12
All the stuff has been zipped and sent on [http://forums.massassi.net/html/smile.gif]

Let me know if it's any use - once I've built up a few of these demo levels, I may even submit them to massassi to help other editors [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"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-08-15, 2:41 PM #13
Quote:
<font face="Verdana, Arial" size="2"> and SaberMaster - if you don't mind me saying ... Parsec rules !!!</font>


I don't mind - I appreciate the support. [http://forums.massassi.net/html/wink.gif]

I wish I had the time right now to start on a better version...

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!