Wolfy
11-15-2003, 03:43 PM
One of the following COGs causes my level to slow down to the point of almost freezing.
################################################## ########################################
# Jedi Knight Cog Script #
# #
# electroswitch.cog #
# #
# #
# This cog will make a light thing flicker, to put it in your level, creat a thing #
# where you want the flickering light. #
# #
# [EL3CTRO - 15/04/2001] [ Modified by Wolfy - 15/11/2003] #
# #
################################################## ########################################
flags=0x240
symbols
message startup
message timer
message activated
thing light
template electric
template sparks
surface switch1
surface screen1
surface switch2
surface screen2
surface switch3
surface screen3
sound beep
sound elec_sound
int a=0 local
int sw1on=0 local
int sw2on=0 local
int sw3on=0 local
end
#================================================= ==========================-
code
startup:
SetTimer(rand());
return;
#================================================= ==========================-
activated:
if((GetSenderRef()==switch1) && (sw1on==0)) {
sw1on=1;
a=1;
SetWallCel(switch1, 1);
SetWallCel(screen1, 1);
PlaySoundLocal(beep, 1.0, 0.0, 0x0);
}
if((GetSenderRef()==switch2) && (sw2on==0)) {
sw2on=1;
SetWallCel(switch1, 2);
SetWallCel(screen1, 2);
PlaySoundLocal(beep, 1.0, 0.0, 0x0);
}
if((GetSenderRef()==switch3) && (sw3on==0)) {
sw3on=1;
SetWallCel(switch3, 1);
SetWallCel(screen3, 1);
PlaySoundLocal(beep, 1.0, 0.0, 0x0);
}
return;
#================================================= ==========================-
timer:
if(On)
{
if (a==0) {
SetThingLight(light, 1, 0);
CreateThing(electric, light);
CreateThing(sparks, light);
PlaySoundThing(elec_sound, light, 1.0, -1, -1, 0x0);
SetTimer(rand());
}
}
else
{
if (a==0) {
SetThingLight(light, 0, 0);
SetTimer(rand());
}
}
On = 1 - On;
return;
#================================================= ==========================-
end
This one generates lightning, sparks, and a flash of light at a specificed point (to simulate sparking wiring and electrical arcs). When you press switch1, it's supposed to set a=1, so that the timer stops.
# Jedi Knight Cog Script
#
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# 00_sectordamage.cog
#
# Apply constant amount of damage to a player in a sector.
# Sector can heal instead, if a negative number is used for the "damage" variable.
#
# 01/31/97 [CYW]
# 04/14/97 [YB] Disabled the pulse if the damageSector is not linked in
# Reduced the damageInterval and increased the damage
# 06/27/97 [DB] Changed damage type to 0x1
# ================================================== ======================================
symbols
message startup
message pulse
message activated
sector damageSector # the deadly sector.
surface switch1
flex damageInterval=1.0 # how often damage is applied in seconds.
flex damage=4.0 # how much damage is applied
thing victim local # actors and players affected.
int bugger=0 local
int type local
int sw****=0 local # Uh, oh! Naughty word!!!111shiftone
end
# ================================================== ======================================
code
# .................................................. ......................................
startup:
if(damageSector > -1) SetPulse(damageInterval);
return;
# .................................................. ......................................
activated:
if((GetSenderRef()==switch1) && (sw****==0)) {
sw****=1;
bugger=1;
}
# .................................................. ......................................
pulse:
if (bugger==0) {
victim = FirstThingInSector(damageSector);
while (victim != -1)
{
type = GetThingType(victim);
// If we have an actor (2) or a player (10)
if ((type==2) || (type==10))
{
// Do the damage or healing.
if (damage > 0)
{
DamageThing(victim, damage, 0x1, victim);
}
else
{
HealThing(victim, -damage);
}
victim = NextThingInSector(victim);
}
}
}
return;
# .................................................. ......................................
end
This COG is supposed to damage the player while bugger=0. Then, when switch1 is activated, bugger=1 and the player can not be damaged while he/she is in the specified sector.
Anyone have any ideas?
------------------
"LC Tusken: the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot"
Jack Chick preaches it (http://www.chick.com/bookimages/150/150_064.gif)
NMGOH (http://www.nmgoh.com)
################################################## ########################################
# Jedi Knight Cog Script #
# #
# electroswitch.cog #
# #
# #
# This cog will make a light thing flicker, to put it in your level, creat a thing #
# where you want the flickering light. #
# #
# [EL3CTRO - 15/04/2001] [ Modified by Wolfy - 15/11/2003] #
# #
################################################## ########################################
flags=0x240
symbols
message startup
message timer
message activated
thing light
template electric
template sparks
surface switch1
surface screen1
surface switch2
surface screen2
surface switch3
surface screen3
sound beep
sound elec_sound
int a=0 local
int sw1on=0 local
int sw2on=0 local
int sw3on=0 local
end
#================================================= ==========================-
code
startup:
SetTimer(rand());
return;
#================================================= ==========================-
activated:
if((GetSenderRef()==switch1) && (sw1on==0)) {
sw1on=1;
a=1;
SetWallCel(switch1, 1);
SetWallCel(screen1, 1);
PlaySoundLocal(beep, 1.0, 0.0, 0x0);
}
if((GetSenderRef()==switch2) && (sw2on==0)) {
sw2on=1;
SetWallCel(switch1, 2);
SetWallCel(screen1, 2);
PlaySoundLocal(beep, 1.0, 0.0, 0x0);
}
if((GetSenderRef()==switch3) && (sw3on==0)) {
sw3on=1;
SetWallCel(switch3, 1);
SetWallCel(screen3, 1);
PlaySoundLocal(beep, 1.0, 0.0, 0x0);
}
return;
#================================================= ==========================-
timer:
if(On)
{
if (a==0) {
SetThingLight(light, 1, 0);
CreateThing(electric, light);
CreateThing(sparks, light);
PlaySoundThing(elec_sound, light, 1.0, -1, -1, 0x0);
SetTimer(rand());
}
}
else
{
if (a==0) {
SetThingLight(light, 0, 0);
SetTimer(rand());
}
}
On = 1 - On;
return;
#================================================= ==========================-
end
This one generates lightning, sparks, and a flash of light at a specificed point (to simulate sparking wiring and electrical arcs). When you press switch1, it's supposed to set a=1, so that the timer stops.
# Jedi Knight Cog Script
#
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# 00_sectordamage.cog
#
# Apply constant amount of damage to a player in a sector.
# Sector can heal instead, if a negative number is used for the "damage" variable.
#
# 01/31/97 [CYW]
# 04/14/97 [YB] Disabled the pulse if the damageSector is not linked in
# Reduced the damageInterval and increased the damage
# 06/27/97 [DB] Changed damage type to 0x1
# ================================================== ======================================
symbols
message startup
message pulse
message activated
sector damageSector # the deadly sector.
surface switch1
flex damageInterval=1.0 # how often damage is applied in seconds.
flex damage=4.0 # how much damage is applied
thing victim local # actors and players affected.
int bugger=0 local
int type local
int sw****=0 local # Uh, oh! Naughty word!!!111shiftone
end
# ================================================== ======================================
code
# .................................................. ......................................
startup:
if(damageSector > -1) SetPulse(damageInterval);
return;
# .................................................. ......................................
activated:
if((GetSenderRef()==switch1) && (sw****==0)) {
sw****=1;
bugger=1;
}
# .................................................. ......................................
pulse:
if (bugger==0) {
victim = FirstThingInSector(damageSector);
while (victim != -1)
{
type = GetThingType(victim);
// If we have an actor (2) or a player (10)
if ((type==2) || (type==10))
{
// Do the damage or healing.
if (damage > 0)
{
DamageThing(victim, damage, 0x1, victim);
}
else
{
HealThing(victim, -damage);
}
victim = NextThingInSector(victim);
}
}
}
return;
# .................................................. ......................................
end
This COG is supposed to damage the player while bugger=0. Then, when switch1 is activated, bugger=1 and the player can not be damaged while he/she is in the specified sector.
Anyone have any ideas?
------------------
"LC Tusken: the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot"
Jack Chick preaches it (http://www.chick.com/bookimages/150/150_064.gif)
NMGOH (http://www.nmgoh.com)