PDA

View Full Version : 1.Gravity Switch 2. forcefield off when u enter game.



YourOwners
11-28-2003, 07:48 PM
1. i need a gravity switch, thats not the one from massassi. that one only works for the host. i need a surface (preferably) or thing to be activated and can set the gravity on low, medium, and high. low gravity is slow motion like, medium is default and thats how it should start out when u start the game, and high makes you jump really fast because theres a lot of force pushing u down. if you made 3 individual switches, that would be even better. just make sure that it works for host and others.


2. when i made my forcefield, i used two cogs. i dont know if you need both, or which one you want, so ill give you both of them. i need the forcefield to be turned off when u enter the game if thats possible. in jed, you make the surface hard and stuff, so i dont know if its possible. heres the cogs:



# Jedi Knight Cog Script
#
# M2_FFieldSwitch.cog
#
# This script operates a forcefield surface that damages
# the player.
# It also sets this surface to be nomove and translucent.
#
# [SC]
#
# 8/8/97 - YB - Fixed sleep() problem by using timers.
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ================================================== ======================================

symbols

message startup
message damaged
message activated
message touched
message timer

sound poweroff=activate04.wav local
sound poweron=activate01.wav local
sound hitsurf=ForceFieldHit01.wav local

surface switch linkid=1
surface switch1 linkid=1
surface damsurf linkid=3 mask=0x448
surface damsurf2 linkid=3 mask=0x448

flex maxdamage=10.0
flex mindamage=5.0
flex damage=0.0 local
flex interval=0.25 local

int damaging=1 local
int garbage=0 local
int garbage2=0 local

thing victim local

template sparks=+heavysmoke local

end

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

code

startup:
SetWallCel(switch,0); //on
ClearAdjoinFlags(damsurf,2); //no move
ClearAdjoinFlags(damsurf2,2);
SetFaceGeoMode(damsurf,0); //translucent
SetFaceGeoMode(damsurf2,0);
SetSurfaceFlags(damsurf,16384); //magsealed
SetSurfaceFlags(damsurf2,16384);
SurfaceLightAnim(damsurf, 0.4, 1.0, 0.5); // animate surface
SurfaceLightAnim(damsurf2, 0.4, 1.0, 0.5);
return;

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

activated:
if ((GetWallCel(switch) == 0) && (GetSenderId() == 1))
{
PlaySoundPos(poweroff, SurfaceCenter(switch), 1.0, -1, -1, 0 );
PlaySoundPos(poweroff, SurfaceCenter(switch1), 1.0, -1, -1, 0);
SetWallCel(switch,1);
SetWallCel(switch1,1); //off
SetAdjoinFlags(damsurf,2); //move
SetAdjoinFlags(damsurf2,2);
}
else if ((GetWallCel(switch) == 1) && (GetSenderId() == 1))
{
PlaySoundPos(poweron, SurfaceCenter(switch), 1.0, -1, -1, 0 );
PlaySoundPos(poweron, SurfaceCenter(switch1), 1.0, -1, -1, 0);
SetWallCel(switch,0);
SetWallCel(switch1,0); //on
ClearAdjoinFlags(damsurf,2); //no move
ClearAdjoinFlags(damsurf2,2);
}
return;

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

touched:
if ((GetSenderID() == 3) && (damaging == 1))
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0 );
victim = GetSourceRef();
damage = (Rand()*(maxdamage - mindamage))+mindamage;
DamageThing(victim,damage,0x2,victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
damaging=0;
SetTimerEx(interval, 1, 0, 0);
}
else return;

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

damaged:
victim = GetThingParent(GetSourceRef());

if((GetParam(1) == 1) && (GetThingType(victim) == 10))
{
damage = (Rand()*(maxdamage - mindamage))+mindamage;
DamageThing(victim, damage, 0x1, victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0 );
SetFaceGeoMode(damsurf,3);
SetFaceGeoMode(damsurf2,3);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}
else
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0 );
SetFaceGeoMode(damsurf,3);
SetFaceGeoMode(damsurf2,3);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}

return;

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

timer:
if(GetSenderId() == 1)
{
damaging=1;
}

if(GetSenderId() == 2)
{
SetFaceGeoMode(damsurf,0);
SetFaceGeoMode(damsurf2,0);
}

return;

end


&




# ForceFieldSwitch
# Jedi Knight Cog Script
#
# 10_FFieldSwitch.cog
#
# this script activates a forcefield that damages a player on touch.
# also sets this surface to be nomove and translucent.
# Shooting or activating switch will turn it off.
# Adapted from Steve's level 18 script
#
# [DB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

message startup
message damaged
message activated
message touched
message timer

surface switch linkid=1 mask=0x448
surface damsurf mask=0x448
surface damsurf2 mask=0x448

flex maxdamage=10.0
flex mindamage=5.0
flex damage=0.0 local

sound powerup=ForceFieldOn01.wav local
sound powerdown=ForceFieldOff01.wav local
sound wav0=ForceFieldHum01.wav local
sound wav1=ForceFieldHit01.wav local

int garbage=0 local

thing victim local

end


code
startup:
SetWallCel(switch,0); //on
ClearAdjoinFlags(damsurf,10); //no move
ClearAdjoinFlags(damsurf2,10);
SetFaceGeoMode(damsurf,0); //translucent
SetFaceGeoMode(damsurf2,0);
SetSurfaceFlags(damsurf,16384); //magsealed
SetSurfaceFlags(damsurf2,16384);
PlaySoundPos(wav0, GetSurfaceCenter(damsurf), 1.0, 1, 10, 0x1);
return;

activated:
if (GetSenderID() != 1) return;

if (GetWallCel(switch) == 0)
{
SetWallCel(switch,1); //off
PlaySoundLocal(powerdown, 1, 0, 0);
SetAdjoinFlags(damsurf,10); //move
SetAdjoinFlags(damsurf2,10);
}
else if (GetWallCel(switch) == 1)
{
SetWallCel(switch,0); //on
PlaySoundLocal(powerup, 1, 0, 0);
ClearAdjoinFlags(damsurf,10); //no move
ClearAdjoinFlags(damsurf2,10);
}
return;

touched:
if ((GetSenderRef() == damsurf) || (GetSenderRef() == damsurf2))
{
victim = GetSourceRef();
damage = (Rand()*(maxdamage - mindamage))+mindamage;
garbage = DamageThing(victim, damage, 0x4, victim);
PlaySoundPos(wav1, GetSurfaceCenter(damsurf), 0.5, 1, 10, 0);
call fieldflash;
}
Return;

damaged:
if (GetSenderID() == 1)
{
call activated;
}
else
{
call fieldflash;
}
return;

timer:
SetFaceGeoMode(damsurf,0);
SetFaceGeoMode(damsurf2,0);
Return;

fieldflash:
SetFaceGeoMode(damsurf,4);
SetFaceGeoMode(damsurf2,4);
KillTimerEx(1);
SetTimerEx(0.5, 1, 0, 0);
return;

end




if you can tell me if i need one or the other, or both, it would be nice, cause using 2 cogs seems unordinary.
THX!


------------------
Your Owners Clan Leaader,
_yo_wasup_

Edward
11-29-2003, 10:16 AM
I'll tell you what you need for your gravity.
To start off, normal gravity is 4. So you can guess what would be slow motion... 1. For a quick jump, lets have like... 16. To crush someone on jump, try a billion!

To set a gravity, try SetGravity(flex_gravity);
To make it work for all and not just the host, try removing the flags=0x240 at the top of your COG.
Have none? Then try a trigger. I'm no expert at triggers so you'll have to ask around. Have you got it? No? I'll see if I can cook up a COG here:


# Changing Gravity between 1, 4 and 16.
#
# By Edward
symbols

message startup
message activated

surface low
surface medium
surface high

end
#
code
startup:
SetGravity(4);
SetWallCel(low,0);
SetWallCel(medium,1);
SetWallCel(high,0);
// Mkae sure we are at medium
return;
activated:
If(GetSenderRef()==low)
{
SetGravity(1);
SetWallCel(low,1);
SetWallCel(medium,0);
SetWallCel(high,0);
jkStringClear();
jkStringConcatAsciiString("Gravity has been turned to low (1/4)");
jkStringOutput(-3, -1);
jkStringClear();
}
else If(GetSenderRef()==medium)
{
SetGravity(4);
SetWallCel(low,0);
SetWallCel(medium,1);
SetWallCel(high,0);
jkStringClear();
jkStringConcatAsciiString("Gravity has been turned to medium (4/4)");
jkStringOutput(-3, -1);
jkStringClear();
}
else If(GetSenderRef()==high)
{
SetGravity(16);
SetWallCel(low,0);
SetWallCel(medium,0);
SetWallCel(high,1);
jkStringClear();
jkStringConcatAsciiString("Gravity has been turned to high (8/4)");
jkStringOutput(-3, -1);
jkStringClear();
}
return;
end

Now, this is an Untested COG. Any problems, I'll see where it is. If I can't find, anyone please, help out! Feel free to change the gravity numbers in any way!
About your forcefield... I'm sorry, but I can't help...

YourOwners
11-29-2003, 07:31 PM
your gravity switch is aweomse, except it only works for host. try to find out why and post the edited cog again please.

thx.

------------------
Your Owners Clan Leaader,
_yo_wasup_

darthslaw
11-29-2003, 08:24 PM
Try this cog for your forcefield. It hasn't been tested (as i don't have a level made already to implement it in), but it should work, provided I set everything right. Also, you shouldn't need to use both cogs for your ff, just one.



# Slaw_ff_switch.cog
#
# This script operates a forcefield surface that damages
# the player.
# It also sets this surface to be nomove and transparent.
#
# Modified to initialize to an off state by Darth Slaw
#
#================================================= =============#
symbols

message startup
message damaged
message activated
message touched
message timer

sound poweroff=activate04.wav local
sound poweron=activate01.wav local
sound hitsurf=ForceFieldHit01.wav local

surface switch linkid=1
surface switch1 linkid=1
surface damsurf linkid=3 mask=0x448
surface damsurf2 linkid=3 mask=0x448

flex maxdamage=10.0
flex mindamage=5.0
flex damage=0.0 local
flex interval=0.25 local

int damaging=0 local

thing victim local

template sparks=+heavysmoke local

end
#================================================= =============#
code
#------------------------------------------------------
startup:
SetWallCel(switch, 1); //off
SetWallCel(switch1, 1);
SetAdjoinFlags(damsurf, 2); //move
SetAdjoinFlags(damsurf2, 2);
SetFaceGeoMode(damsurf, 0); //translucent
SetFaceGeoMode(damsurf2, 0);
SetSurfaceFlags(damsurf, 16384); //magsealed
SetSurfaceFlags(damsurf2, 16384);
SurfaceLightAnim(damsurf, 0.4, 1.0, 0.5); // animate surface
SurfaceLightAnim(damsurf2, 0.4, 1.0, 0.5);

Return;
#------------------------------------------------------
activated:
if((GetWallCel(switch) == 0) && (GetSenderID() == 1))
{
PlaySoundPos(poweroff, SurfaceCenter(switch), 1.0, -1, -1, 0);
PlaySoundPos(poweroff, SurfaceCenter(switch1), 1.0, -1, -1, 0);
SetWallCel(switch, 1);
SetWallCel(switch1, 1); //off
SetAdjoinFlags(damsurf, 2); //move
SetAdjoinFlags(damsurf2, 2);
}
else if((GetWallCel(switch) == 1) && (GetSenderID() == 1))
{
PlaySoundPos(poweron, SurfaceCenter(switch), 1.0, -1, -1, 0);
PlaySoundPos(poweron, SurfaceCenter(switch1), 1.0, -1, -1, 0);
SetWallCel(switch, 0);
SetWallCel(switch1, 0); //on
ClearAdjoinFlags(damsurf, 2); //no move
ClearAdjoinFlags(damsurf2, 2);
}

Return;
#------------------------------------------------------
touched:
if((GetSenderID() == 3) && (damaging == 1))
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
victim = GetSourceRef();
damage = (Rand() * (maxdamage - mindamage)) + mindamage;
DamageThing(victim, damage, 0x2, victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
damaging = 0;
SetTimerEx(interval, 1, 0, 0);
}

Return;
#------------------------------------------------------
damaged:
victim = GetThingParent(GetSourceRef());
if((GetParam(1) == 1) && (GetThingType(victim) == 10))
{
damage = (Rand() * (maxdamage - mindamage)) + mindamage;
DamageThing(victim, damage, 0x1, victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
SetFaceGeoMode(damsurf, 3);
SetFaceGeoMode(damsurf2, 3);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}
else
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
SetFaceGeoMode(damsurf, 3);
SetFaceGeoMode(damsurf2, 3);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}

Return;
#------------------------------------------------------
timer:
if(GetSenderID() == 1)
{
damaging = 1;
}
if(GetSenderID() == 2)
{
SetFaceGeoMode(damsurf, 0);
SetFaceGeoMode(damsurf2, 0);
}

Return;
#------------------------------------------------------
end


Hope this works. 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 November 29, 2003).]

lucky_jackpot
11-30-2003, 04:25 PM
Hi there http://forums.massassi.net/html/smile.gif

One tested (working, complete, buggy-free etc etc... http://forums.massassi.net/html/wink.gif) force-field cog script, that I wrote a while back:

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

Wow - it was a while back now, come to think about it... *much ferreting through Massassi archives* http://forums.massassi.net/html/wink.gif

And Darth Slaw is right - only one cog is needed for the force-field; what you had in your first post were two marginally different force-field scripts that cater for differing styles/effects.

Strange about the gravity one though... sorry I can't think of a solution off the top of my head, but I can hear my pillow calling... *Zzzz*

Hope the force-field cog helps - I'll try and have a look at the gravity ASAP http://forums.massassi.net/html/smile.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)

Edward
12-01-2003, 06:54 AM
OK, I've changed some stuff, but still untested.


# Changing Gravity between 1, 4 and 16.
#
# By Edward
flags=0x240
symbols

message startup
message activated
message trigger

surface low
surface medium
surface high

end
#
code
startup:
SetGravity(4);
SetWallCel(low,0);
SetWallCel(medium,1);
SetWallCel(high,0);
// Mkae sure we are at medium
return;
activated:
If(GetSenderRef()==low)
{
SendTrigger(-1, 4001, 0, 0, 0, 0);
}
else If(GetSenderRef()==medium)
{
SendTrigger(-1, 4002, 0, 0, 0, 0);
}
else If(GetSenderRef()==high)
{
SendTrigger(-1, 4003, 0, 0, 0, 0);
}
return;
trigger:
if(GetSourceRef()==4001)
{
SetGravity(1); //LowGrav
SetWallCel(low,1);
SetWallCel(medium,0);
SetWallCel(high,0);
jkStringClear();
jkStringConcatAsciiString("Gravity has been turned to low (1/4)");
jkStringOutput(-3, -1);
jkStringClear();
}
else if(GetSourceRef()==4002)
{
SetGravity(4); //MediumGrav
SetWallCel(low,0);
SetWallCel(medium,1);
SetWallCel(high,0);
jkStringClear();
jkStringConcatAsciiString("Gravity has been turned to medium (4/4)");
jkStringOutput(-3, -1);
jkStringClear();
}
else if(GetSourceRef()==4003)
{
SetGravity(16); //HighGrav
SetWallCel(low,0);
SetWallCel(medium,0);
SetWallCel(high,1);
jkStringClear();
jkStringConcatAsciiString("Gravity has been turned to high (8/4)");
jkStringOutput(-3, -1);
jkStringClear();
}
return;
end


/Edward

darthslaw
12-01-2003, 01:12 PM
I think I may have made an error in my ff cog. In the symbols list, damaging may need to be set back to 1 like it was (I think I misinterpreted it, so I'll look into that for you and fix it if needed) http://forums.massassi.net/html/biggrin.gif
-----------------------------------------
[edit]
Ok, I fixed the ff (it did need to be 1) and even tweaked it up so it's more advanced. Here it is (and it's been tested!)


# Jedi Knight Cog Script
#
# Slaw_ff_switch.cog
#
# This script operates a forcefield surface that damages
# the player.
# It also sets this surface to be nomove and transparent.
# Modifications made by Darth Slaw:
# - Initializes to an off state
# - Can choose (de)activation sounds in Jed now
# - (De)Activation sounds are played at the switches and forcefield surfaces,
# and can be changed in Jed's COG Window
# - Forcefield now hums
#
#================================================= =============#
symbols

message startup
message damaged
message activated
message touched
message timer

surface switch linkid=1
surface switch1 linkid=1
surface damsurf linkid=3 mask=0x448
surface damsurf2 linkid=3 mask=0x448

flex maxdamage=10.0
flex mindamage=5.0

sound poweron=forcefieldon01.wav
sound poweroff=forcefieldoff01.wav
sound switchon=activate01.wav
sound switchoff=activate02.wav
sound hitsurf=ForceFieldHit01.wav local
sound ffhum=forcefieldhum01.wav local

flex damage=0.0 local
flex interval=0.25 local

int damaging=1 local
int humloop local

thing victim local

template sparks=+heavysmoke local

end
#================================================= =============#
code
#------------------------------------------------------
startup:
SetWallCel(switch, 1); //off
SetWallCel(switch1, 1);
SetAdjoinFlags(damsurf, 2); //move
SetAdjoinFlags(damsurf2, 2);
SetFaceGeoMode(damsurf, 0); //transparent
SetFaceGeoMode(damsurf2, 0);
SetSurfaceFlags(damsurf, 16384); //magsealed
SetSurfaceFlags(damsurf2, 16384);
SurfaceLightAnim(damsurf, 0.4, 1.0, 0.5); //animate surface
SurfaceLightAnim(damsurf2, 0.4, 1.0, 0.5);

Return;
#------------------------------------------------------
activated:
if((GetWallCel(switch) == 0) && (GetSenderID() == 1))
{
PlaySoundPos(switchoff, SurfaceCenter(switch), 1.0, -1, -1, 0);
PlaySoundPos(switchoff, SurfaceCenter(switch1), 1.0, -1, -1, 0);
PlaySoundPos(poweroff, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
StopSound(humloop, 1.0);
SetWallCel(switch, 1);
SetWallCel(switch1, 1); //off
SetAdjoinFlags(damsurf, 2); //move
SetAdjoinFlags(damsurf2, 2);
SetFaceGeoMode(damsurf, 0); //transparent
SetFaceGeoMode(damsurf2, 0);
}
else if((GetWallCel(switch) == 1) && (GetSenderID() == 1))
{
PlaySoundPos(switchon, SurfaceCenter(switch), 1.0, -1, -1, 0);
PlaySoundPos(switchon, SurfaceCenter(switch1), 1.0, -1, -1, 0);
PlaySoundPos(poweron, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
SetWallCel(switch, 0);
SetWallCel(switch1, 0); //on
ClearAdjoinFlags(damsurf, 2); //no move
ClearAdjoinFlags(damsurf2, 2);
SetFaceGeoMode(damsurf, 3); //translucent
SetFaceGeoMode(damsurf2, 3);
humloop = PlaySoundPos(ffhum, SurfaceCenter(damsurf), 1.0, -1, -1, 0x1);
}

Return;
#------------------------------------------------------
touched:
if((GetSenderID() == 3) && (damaging == 1))
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
victim = GetSourceRef();
damage = (Rand() * (maxdamage - mindamage)) + mindamage;
DamageThing(victim, damage, 0x2, victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
damaging = 0;
SetTimerEx(interval, 1, 0, 0);
}

Return;
#------------------------------------------------------
damaged:
victim = GetThingParent(GetSourceRef());
if((GetParam(1) == 1) && (GetThingType(victim) == 10))
{
damage = (Rand() * (maxdamage - mindamage)) + mindamage;
DamageThing(victim, damage, 0x1, victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}
else
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}

Return;
#------------------------------------------------------
timer:
if(GetSenderID() == 1)
{
damaging = 1;
}
if(GetSenderID() == 2)
{
SetFaceGeoMode(damsurf, 0);
SetFaceGeoMode(damsurf2, 0);
}

Return;
#------------------------------------------------------
end

If you need special modifications to it, I'd be more than happy to help http://forums.massassi.net/html/biggrin.gif
Also, I should mention that this cog assumes that your ff surfaces are textured with solid color mats (i.e. '00red.mat', '00yellow.mat'). If you must use a mat that is not a solid color, you need to edit the cog so that all the
"SetFaceGeoMode(damsurf, 3);"
and
"SetFaceGeoMode(damsurf2, 3);"
lines say
"SetFaceGeoMode(damsurf, 4);"
and
"SetFaceGeoMode(damsurf2, 4);"
respectively.

------------------
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 01, 2003).]

YourOwners
12-02-2003, 02:44 PM
If it is a custom solid texture do i still have to do that?

------------------
Your Owners Clan Leaader,
_yo_wasup_

darthslaw
12-02-2003, 02:58 PM
No, not as long as it's a solid tex. If it doesn't work, well, Tell me what happened and I'll try to figure it out.

------------------
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 02, 2003).]