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 → finished shield
finished shield
2002-01-18, 9:16 PM #1
i useta b I_Chop_Ur_PP and some of u mite remember me posting a shield cog and heres it.

# Jedi Knight Cog Script
#
# shield.COG
#
# Description
#
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

thing player


message startup
message pulse
message killed
message activated


end

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

code

startup:

player = GetLocalPlayerThing();
switch = 1;

return;


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

killed:

Print("Shield Offline");
SetPulse(0.0);
ClearThingFlags(player, 0x4);
switch = 1;

return;

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

pulse:

bullet = FirstThingInView(player, 179, 15, 0x48);

while(bullet != -1)
{
bulletshooter = GetThingParent(bullet);

if(bulletshooter != player && GetThingParent(bullet) != player && VectorDist(GetThingPos(bullet), GetThingPos(player)) > 0.2) StopThing(bullet);

bullet = NextThingInView();
}

return;

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

activated:

if(switch == 1)
{
SetThingFlags(player, 0x4);
Print("Shield Online");
SetPulse(0.00000000000000001);
switch = 0;
}
else
{
ClearThingFlags(player, 0x4);
Print("Shield Offline");
SetPulse(0.0);
switch = 1;
}
return;

end

i just wanna know wut u all think how good i am doing and c if it has any flaws that i didnt notice.
2002-01-19, 6:16 AM #2
Several things:

1) You should define all of your variables in the symbols section. Note that you don't have to, but since LEC did, there's probably a reason.

^A mistake in Pele's cog tut says that all undefined vars have random values.

2) In your pulse, there's no need to find all the bullets within 15 JKUs. Just search for all bullets within 1 JKU.[edit]Read below.[/edit]

3)
Code:
bulletshooter != player && GetThingParent(bullet) != player


bulletshooter and GetThingParent(bullet) are one and the same thing - no need to check it twice.

4)
Code:
SetPulse(0.00000000000000001);

Do you really think a pulse is going to run that quickly? Even if you have the fastest computer out there, you're probably not going to get a pulse faster than 0.001.

Overall, not a bad cog for someone who's new to cogging.

On another note, don't act so immaturely. Your first name was bad enough, and no one on this forum wants to hear your perversion of English.

------------------
More matter with less art.

[This message has been edited by SaberMaster (edited January 19, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-19, 6:33 AM #3
Quote:
<font face="Verdana, Arial" size="2">
2) In your pulse, there's no need to find all the bullets within 15 JKUs. Just search for all bullets within 1 JKU. You could just check for bullets within 0.2 and get rid of the VectorDist() checking, but I don't know if the pulse would be fast enough.
</font>


I'm sure you are correct here and it's something I am doing wrong, but I have always had to use VectorDist() checking also.

Are the 'units' the same in both verbs? I guess I'm asking, does VectorDist return the answer in JKU's ?

Everytime I have tried to do something like:

bullet = FirstThingInView(player, 179, 0.2, 0x48);

It still manages to return thing value's that are much father away than 0.2 JKU's.

If your experiences are different or you see what I'm doing wrong, please tell me.

(I only have experience with JK, maybe it works correct in MOTS but not in JK ? )


[This message has been edited by The_New_Guy (edited January 19, 2002).]
- Wisdom is 99% experience, 1% knowledge. -
2002-01-19, 11:09 AM #4
Hmmm... I just tested that, New Guy, and you're right. Most of the time(~70%), FTIV() returned things within 1 JKU when I gave it distance of 1 JKU. But sometimes, FTIV() found things several JKUs away. So yes, you do need to use VectorDist() checking.

VectorDist() uses JKUs, but now I'm not sure about FTIV().

[This message has been edited by SaberMaster (edited January 19, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!