PDA

View Full Version : A big problem...



Edward
06-10-2004, 07:02 AM
Hi!
I've modified Force Seeing so that all surfaces will become Green Code from the matrix. Now, if a surface has a COG associated to it, it would become Gold Code, and I found it a little... little... If you are the one in the Matrix, I thought, you should be able to see any object with a COG attached to it, so... I edited some, and did so that sectors with a COG attached would get something created in the middle, and objects with a COG would flicker between Render Texture and Render Solid Colors. But, when ever I deactivate the Force, the game crashes... Could someone help me out!



# Jedi Knight Cog Script
#
# FORCE_SEEING.COG
#
# FORCEPOWER Script - Seeing
# Light Side Power
# Bin 23
#
# [YB]
# [SF]pjb did Code Seeing.
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing player local

flex cost=30.0 local
flex mana local

sound seeingSound=ForceSee01.WAV local
sound seeingSound2=vibes2.wav local
int channel=-1 local

int rank=0 local
int flags=0 local
int old_flags=0 local

template t=+lightninghit local

int effectHandle=-1 local
material greencode=code.mat local
material yellowcode=code2.mat local

int i local

surface x local
int zz=0 local
thing z local
int zzz=0 local
sector y local
int yy local
int zzzz=0; local

message startup
message shutdown
message activated
message timer
message pulse
message newplayer
message killed
message selected

end

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

code

startup:
player = GetLocalPlayerThing();
old_flags = GetMapModeFlags();
sleep(0.1);
HeapNew(0, getsurfacecount()+1);
for(i=0; i<=GetSurfaceCount(); i=i+1)
{
heapset(i,getsurfacemat(i));
if(GetSurfaceFlags(i) & 0x2) { SetSurfaceMat(i, yellowcode); }
else { SetSurfaceMat(i, greencode); }
}

sleep(0.1);
call stop_power;

Return;

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

shutdown:
call stop_power;

Return;

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

activated:
if(!IsInvActivated(player, 23))
{
mana = GetInv(player, 14);
if(mana >= cost)
{
if(GetInv(player, 65) != 1) ChangeInv(player, 14, -cost);

rank = GetInv(player, 23);
if(rank == 1) flags = 0xc; // players & actors
else if(rank == 2) flags = 0xc; // players & actors
else if(rank == 3) flags = 0x1c; // players & actors & items
else if(rank == 4) flags = 0x4c; // players & actors & items & projectiles

PlayMode(player, 24);

// Play activation sound
channel = PlaySoundThing(seeingSound, player, 1.0, -1, -1, 0x80);
if(GetDebugModeFlags() & 0x400)
ChangeSoundPitch(channel,0.5,0.01);

// Play loop sound at 0.0 volume and fade it in to 1.0 volume in 0.75 secs
channel = PlaySoundThing(seeingSound2, player, 0.0, -1, -1, 0x81);
ChangeSoundVol(channel, 1.0, 0.75);

effectHandle = newColorEffect(1, 1, 1, 0, 0, 0, 0, 0, 0, 1.0);
for(i=0; i<=GetSurfaceCount(); i=i+1)
{
heapset(i,getsurfacemat(i));
if(GetSurfaceFlags(i) & 0x2){ SetSurfaceMat(i, yellowcode); }
else { SetSurfaceMat(i, greencode); }
}
EnableIRMode(1, 1);
old_flags = GetMapModeFlags();
SetMapModeFlags(flags);
SetInvActivated(player, 23, 1);
zz=0;
zzz=0;
zzzz=0;
SetPulse(0.01);
}
}
else { call stop_power; }

Return;

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

timer:
call stop_power;

Return;


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

pulse:
// check that the player didn't die
if(GetThingHealth(player) < 1)
{
call stop_power;
}
if(GetActorFlags(player) & 0x200000)
{
call stop_power;
}
zzz=zzz+1;
if(zzz==10)
{
for(z=0; z<=GetThingCount(); z=z+1)
{
if(GetThingFlags(z) & 0x400) { SetThingUserData(z, 4000000000); }
if(GetThingUserData(z) == 4000000000)
{
if(GetThingCurGeoMode(z) == 3)
{
SetThingCurGeoMode(z, 4);
}
else if(GetThingCurGeoMode(z) == 4)
{
SetThingCurGeoMode(z, 3);
}
}
}
zzz=0;
}
zzzz=zzzz+1;
if(zzzz==100)
{
for(y=0; y<=GetSectorCount(); y=y+1)
{
if((GetSectorFlags(y) & 0x4) && (VectorDist(GetThingPos(player),GetSectorCenter(y) ) <= 10))
{
tt=CreateThingAtPos(t,y,GetSectorCenter(y),'0 0 0');
}
}
zzzz=0;
}
zz=zz+1;
if(zz==25)
{
for(x=0; x<=GetSurfaceCount(); x=x+1) {
if(GetSurfaceMat(x)==greencode)
SetSurfaceCel(x, rand()*4); }
SetMaterialCel(yellowcode, rand()*4);
zz=0;
}
Return;

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

selected:
jkPrintUNIString(player, 23);
Return;

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

killed:
if(GetSenderRef() != player) Return;

newplayer:
call stop_power;

Return;

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

stop_power:
SetPulse(0);
KillTimerEx(1);
if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}

if(effectHandle!=-1)
{
freeColorEffect(effectHandle);
effectHandle = -1;
}

// Don't disable IR mode if IR Goggles are on...
if(!IsInvActivated(player, 41))
DisableIRMode();
for(i=0; i<=GetSurfaceCount(); i=i+1)
{
SetSurfaceMat(i, heapget(i));
}
for(z=0; z<=GetThingCount(); z=z+1)
{
if(GetThingUserData(z) == 4000000000)
{
if(GetThingCurGeoMode(z) == 3)
{
SetThingCurGeoMode(z, 4);
}
}
}

// Clear the map mode flags
ClearMapModeFlags(0xffff);

// and reset them to what they were.
SetMapModeFlags(old_flags);

SetInvActivated(player, 23, 0);

Return;

end

Not only that, but in MP, at startup the textures aren't stored in the heap. All surfaces get one texture.

/Edward

Lord_Grismath
06-10-2004, 09:49 AM
Does heap even work in MP?

------------------
Rites (http://www.massassi.net/levels/files/2300.shtml) of (http://www.massassi.net/levels/files/2302.shtml) Xanthus (http://www.massassi.net/levels/files/2311.shtml)

The TC that exacted a terrible toll on my time and eyesight.

Tazz
06-10-2004, 11:21 PM
stop_power:
SetPulse(0);
KillTimerEx(1);
if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}
if(effectHandle!=-1)
{
freeColorEffect(effectHandle);
effectHandle = -1;
}
// Don't disable IR mode if IR Goggles are on...
if(!IsInvActivated(player, 41))


The last line should actually be:



if(!IsInvActivated(player, 23))


It was checking to see if the IR Goggles are on, but earlier in activated you checked bin 23. They need to match up.

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz

[This message has been edited by Tazz (edited June 10, 2004).]

Edward
06-11-2004, 04:02 AM
Actually I see nothing wrong there... If I do what you ask me to do, then if I have Force seeing on AND the IR Goggles on, then when I turn off Force Seeing, the IR Goggles will also turn off but my batteries will disappear. And I think that would most definetly do something wierd to the code... I swear, I haven't touched that from the original Force Seeing COG. Check that line between my COG and the Original and you'll see that all is well...

/Edward

Edward
06-14-2004, 10:33 AM
OK, update... On SOME levels does the COG crash the game. And those levels where it doesn't crash, it does... It just seems to sneak up on me and BANG! And also, as you can see in the pulse, I test to see if the player is totally imobile, and stops the power. At some point, while watching a cut-scene, the part about giving the objects back their texture if taken away didn't seem to work... Did I miss something?

/Edward

darthslaw
06-14-2004, 11:16 AM
No, Tazz, that's not correct -- bin 41 is the IRGogs, and bin 23 is FSeeing. In the Activated message, it was checking if FSeeing was on, not the Goggles.

DM doesn't say Heap won't work in MP... hmm...

[nevermind this removed part]

[edit]Parsec sez:
"Prolly not a good idea to use 'code.mat'" -- dunno why, but try changing that texture to maybe 'code1.mat' or something
"remove the semicolon succeeding initial value for symbol 'zzzz' on line 44"
"symbol yy was not used in code sction"
"add symbol 'thing tt local' to symbols section"

Fix these and it works fine -- I tested. Except it doesn't do the mats right in MP http://forums.massassi.net/html/confused.gif -- they all get set to a green solid mat on startup; they change to the right mats when the power is activated, but I dunno why it isn't starting up right...

------------------
nytfyre m0d (http://www.nightfire.uni.cc/site/page.php) || f33l t3h p0w3r (http://www.geocities.com/qrphome/pwp3/) || t3h l0st c0gz (http://www.tbns.net/GBK/ol/index.htm) || OMF > * (http://www.bkkbazaar.com/omf/)

[This message has been edited by Darth Slaw (edited June 14, 2004).]

LKOH_SniperWolf
06-14-2004, 11:57 AM
Perhaps try adding the local/unsynced flags to the beginning. (I don't see why you'd want it to do this for everyone anyways...)

That'd be
flags=0x240
just before symbols section.

------------------
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come

Edward
06-14-2004, 02:07 PM
Thanks! That made a difference. Now, could someone tell me, how do I test for ghost objects? I was thinking of revealing the ghost objects with a COG attached to them the same way I'd reveal a sector with a COG attached to it.

/Edward

darthslaw
06-14-2004, 03:48 PM
<font face="Verdana, Arial" size="2">Originally posted by Edward:
Thanks! That made a difference. Now, could someone tell me, how do I test for ghost objects? I was thinking of revealing the ghost objects with a COG attached to them the same way I'd reveal a sector with a COG attached to it.

/Edward</font>



symbols
.
.
.
template ghosttemp=ghost local
.
.
.
pulse:
.
.
.

if(zzz==10)
{
for(z=0; z&lt;=GetThingCount(); z=z+1)
{
if(GetThingFlags(z) & 0x400)
{
if(GetThingTemplate(z) == ghosttemp) //ghost with a cog
{
SetThingUserData(z, 5000000000);
}
else // has a cog but not a ghost
{
SetThingUserData(z, 4000000000);
}
}
if(GetThingUserData(z) == 4000000000) //not a ghost
{
if(GetThingCurGeoMode(z) == 3)
{
SetThingCurGeoMode(z, 4);
}
else if(GetThingCurGeoMode(z) == 4)
{
SetThingCurGeoMode(z, 3);
}
}
else if(GetThingUserData(z) == 5000000000) //is a ghost
{
Do_Your_Stuff_Here_Edward();
}
}
zzz=0;
}
.
.
.
}

------------------
nytfyre m0d (http://www.nightfire.uni.cc/site/page.php) &#0124;&#0124; f33l t3h p0w3r (http://www.geocities.com/qrphome/pwp3/) &#0124;&#0124; t3h l0st c0gz (http://www.tbns.net/GBK/ol/index.htm) &#0124;&#0124; OMF &gt; * (http://www.bkkbazaar.com/omf/)