SG-fan
04-17-2003, 07:17 AM
I remember that GBK was talking a while ago about finding how many adjoins were in view.
Well, I have figured out a way to do this.
Take your normal weapon cog (bryar, bowcaster...) and alter the code to check for this.
I know you are probably thinking "Dude this guy's stupid, there is no checking for a surface you havn't declared." Well I know that. Have this cog not check for surfaces, but rather what sector the weapon is in, when the number changes that means the weapon crossed an adjoin.
by having the weapon move slowly and having a fast pulse with the code
pulse:
sector1=GetThingSector(shot);
if(sector0==sector1) return;
else
{
count=count+1;
printint(count);
}
sector0=sector1;
sector0 is originally declared right after the shot is fired.
Theoretically this should work, but I han't tested it yet. If someone else uses this method I would like to be included in the credits for the idea http://forums.massassi.net/html/wink.gif
------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
You do realize, dont you, thats one of the first things I tried? http://forums.massassi.net/html/confused.gif
The problem with your approach is simple: all its doing is counting how many sectors the projectile has passed through. In any normal level, there are alot more adjoins inview than just those that you can lob a projectile through in a straight line.
------------------
Createthingatpos(GBK, 0, '0 0 0', '0 0 0');
DogSRoOL
04-17-2003, 07:49 PM
This gives me an idea. I'll experiment tomorrow and see if it works.
*hopes for success*
----------------------------------
<font face="Verdana, Arial" size="2">...there is no checking for a surface you havn't declared. </font>
Actually, you can. The only symbols absolutely essential to the cog are ones that send the message to it. I got started on this cog and it sets all sector adjoins to 0 without requiring a separate reference for each one. Getting specific ones to turn on, however, is a little more tricky, but I think I've almost got it.
..................
next day...
Unfortunately, (and as expected, I'm sure) I failed. The most I was able to do was see the sectors adjoined to the one I was in. I could probably expand on that, but it wouldn't be very useful or practical.
------------------
May the forks be with you.
There is a great disturbance in my shorts...
[This message has been edited by DogSRoOL (edited April 18, 2003).]
SG-fan
04-18-2003, 07:55 PM
I was kinda hopeing that you forgot to try that actually http://forums.massassi.net/html/wink.gif
Anyway, I am trying something to get around that problem, but it keeps crashing my game.
Here's the code
symbols
model povModel=bryv.3do local
model povModel_m=bryv_m.3do local
model weaponMesh=bryg.3do local
keyframe mountAnim=bryvmnt.key local
keyframe dismountAnim=bryvdis.key local
keyframe povfireAnim=bryvpst1.key local
keyframe holsterAnim=kyhlstr.key local
sound outSound=pistout1.wav local
sound mountSound=df_bry_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound fireSound=pistol-1.wav local
sound failSound=weapfail.wav local
template projectileB=+swsparks local
template projectile=+slow local
thing player local
thing victim local
thing potential local
flex dot local
flex maxDot local
flex fireWait=0.5 local
flex holsterWait local
flex fireDelay=0.6 local
flex powerBoost local
flex autoAimFOV=30 local
flex autoAimMaxDist=5 local
int weaponIndex local
int trackID=-1 local
int dummy=0 local
int mode local
int holsterTrack local
int sector[100] local
int count=0 local
int shot=-1 local
int i=0 local
int b=0 local
message pulse
message activated
message deactivated
message selected
message deselected
message autoselect
message fire
message timer
end
# ================================================== ======================================
code
fire:
player = GetSourceRef();
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 11) < 1.0)
{
PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
if(GetAutoSwitch() & 1)
SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
Return;
}
SendMessageEx(GetThingClassCog(GetLocalPlayerThing ()), user1, 3, 0, 0, 0);
SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
if (GetInv(player, 93) > 0.0)
{
dummy = FireProjectile(player, projectileB, failSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
}
else
{
if (mode == 0)
{
shot = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
sector[i]=GetThingSector(shot);
i=i+1;
SetPulse(0.001);
}
else if (mode==1)
{
count=0;
SetPulse(0);
Call secclear;
Print("Count reset");
}
}
ChangeInv(player, 11, -1.0);
jkPlayPOVKey(player, povfireAnim, 1, 0x38);
powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);
Return;
# .................................................. ......................................
activated:
player = GetSourceRef();
mode = GetSenderRef();
if (GetInv(player, 93) > 0.0)
SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
jkSetWaggle(player, '0.0 0.0 0.0', 0);
powerBoost = GetInv(player, 63);
ActivateWeapon( player, fireWait/powerBoost, mode );
Return;
# .................................................. ......................................
deactivated:
player = GetSourceRef();
mode = GetSenderRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon( player, mode );
Return;
# .................................................. ......................................
selected:
player = GetSourceRef();
// Setup the meshes and models.
if (GetInv(player, 67) == 0.0)
jkSetPOVModel(player, povModel); // Kyle hand
else
jkSetPOVModel(player, povModel_m); // Mara Hand
jkSetWeaponMesh(player, weaponMesh);
SetArmedMode(player, 1);
// Play mounting sound.
PlayMode(player, 41);
PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
// Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
// The animation is held at the last frame after it is played.
trackID = jkPlayPOVKey(player, mountAnim, 0, 0x14);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
// Clear saber flags, and allow activation of the weapon
jkClearFlags(player, 0x5);
SetCurWeapon(player, 2);
SetMountWait(player, GetKeyLen(mountAnim));
Return;
# .................................................. ......................................
deselected:
player = GetSourceRef();
weaponIndex = GetSenderRef();
PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
jkPlayPOVKey(player, dismountAnim, 0, 18);
holsterWait = GetKeyLen(holsterAnim);
SetMountWait(player, holsterWait);
holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
SetTimerEx(holsterWait, 2, 0.0, 0.0);
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);
Return;
# .................................................. ......................................
autoselect:
player = GetSourceRef();
// If the player has the weapon
if(GetInv(player, 2) != 0.0)
{
// If the player has ammo
if(GetInv(player, 11) != 0.0)
{
ReturnEx(500.0);
}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}
Return;
# .................................................. ......................................
timer:
StopKey(player, holsterTrack, 0.0);
Return;
# .................................................. ......................................
pulse:
if(i<=0)
{
return;
}
else
{
sector[i]=GetThingSector(shot);
if(sector[i] == -1)
{
return;
}
else
{
for(b=(i-1); b>=0; b=b-1)
{
if(sector[i]==sector[b])
{
return;
}
else
{
count=count+1;
printint(count);
i=i+1;
}
}
}
}
Return;
# .................................................. ......................................
secclear:
if(b>0)
{
for(b=i; b>=0; b=b-1)
{
sector[b]=-1;
}
}
else
{
sector[0]=-1;
}
i=0;
Return;
end
I am still trying to fix it, but it doesn't seem to want to be fixed. Don't try running it with parsec since it is for MOTS and is using some new methods I am testing (sector[100])
------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
[This message has been edited by SG-fan (edited April 18, 2003).]
DogSRoOL
04-18-2003, 09:14 PM
I crashed, too, 4 times before discovering that I simply used and int when it should have been a thing. And I actually tried a different method using "SetSectorAdjoins", but even though you can pass through the adjoins, jk will block any visual message from being sent (i.e. Sighted message, HasLOS, IsThingVisible (which I thought checked if a thing was visible in general, not just to the player)). That kinda threw my idea into the garbage.
Here's an idea using your technique, though (I don't feel like doing it http://forums.massassi.net/html/biggrin.gif(yet)). Have a pulse message fire several invisible projectiles at different angles from the player and have the cog render only the sectors they enter. This theoretically should work, especially since "FireProjectile" is based on the player's look vector.
------------------
May the forks be with you.
There is a great disturbance in my shorts...
[This message has been edited by DogSRoOL (edited April 20, 2003).]
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.