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 → Client SIde/Server Side?
Client SIde/Server Side?
2000-11-16, 8:48 PM #1
This cog is for making Swarm missiles, and yes I do have permission to use it! The problem is, in multiplayer, the missiles do not show up, and no damage is done to the enemy. THe other player is, however, able to hear the sound of them. I need help. I've tried adding the 0X140 flag for multiplayer, but it still refuses to work.
Any suggestions? Here it is:

# The Emperor's Fury Cog Script
#
# WEAP_HMISSILE.COG
#
# Homing Missile
#
# Level used in - 00
#
# This gun fires homing swarm missiles. First you target the victim by pressing
# fire, and when you release it the missiles home in on the specified
# victim. It cannot be fired when there is no victim and does not
# differentiate between friendlies or enemies, so be careful!
# Before people complain there is a built in level of inacuracy in each missile,
# getting progressively worse.
# There is no form of secondary fire at all.
#
# - Not affected by Magsealed sectors/surfaces (It very rarely hits them [http://forums.massassi.net/html/smile.gif]
#
# [Yod]
#
# The Emperor's Fury is an addon by JKAT. Don't copy this file without authors' permission.

flags=0x140

symbols

model povModel=rldv.3do local
model weaponMesh=rldg.3do local

keyframe mountAnim=RldVmnt.key local
keyframe dismountAnim=RldVdis.key local
keyframe povfireAnim=RldVpst1.key local
keyframe holsterAnim=kyhlstr.key local

int trackID=-1 local
int mode local
int holsterTrack local

flex fireWait=1.2 local
flex powerBoost local
flex autoAimFOV=90 local
flex autoAimMaxDist=200 local
flex holsterWait local

thing player local
thing victim local
thing potential local

flex mana local
flex cost=1 local
int rank local
int count local
int retval=0 local

flex dot local
flex maxDot local

thing dummy local
thing dummy2 local
thing dummy3 local
thing dummy4 local

vector path local
vector path2 local
vector path3 local
vector path4 local

vector path0 local
vector path02 local
vector path03 local
vector path04 local

vector path00 local
vector path002 local
vector path003 local
vector path004 local

int timerID local
int random local
int random2 local
int random3 local
int random4 local

int wait local

template projectile=+swarm local
sound fireSound=concuss5.WAV local
sound mountSound=df_rif_ready.wav local
sound dismountSound=PutWeaponAway01.wav local

int active=0 local

message startup
message activated
message deactivated
message pulse
message timer
message newplayer
message killed
message deselected
message selected
message fire
message autoselect
message home

end

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

code

startup:
player = GetlocalPlayerThing();
mode = GetSenderRef();
Return;

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

activated:
if(active) Return;
if(mode == 0)
{
mana = GetInv(player, 15);

if(mana >= cost)
{
victim = -1;
active = 1;
SetPulse(0.33);
}
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);

powerBoost = GetInv(player, 63);
ActivateWeapon( player, fireWait/powerBoost, mode );

Return;

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

pulse:
// Check all things for our victim.
victim = -1;
maxDot = 0;

// Search for all players and actors.
potential = FirstThingInView(player, 200, 7, 0x404);
while(potential != -1)
{
if(
HasLOS(player, potential) &&
(potential != player) &&
(VectorDist(GetThingPos(player), GetThingPos(potential)) <= 200) &&
(VectorDist(GetThingPos(player), GetThingPos(potential)) >= 0.4) &&
!(GetThingFlags(potential) & 0x200) &&
!((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23))
)
{
dot = ThingViewDot(player, potential);
if(dot > maxDot)
{
victim = potential;
maxDot = dot;
}
}
potential = NextThingInView();
}

// If we have a victim...
if(victim != -1)
{
jkSetTargetColors(11,12,6);
jkSetTarget(victim);

}
else
{
jkEndTarget();
}

Return;

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

deactivated:
if((victim == -1) | | (GetThingHealth(player) <= 0))
{
call stop_power;
Return;
}

SetPulse(0);
jkEndTarget();

mana = GetInv(player, 15);
if(mana >= cost)
{
ChangeInv(player, 15, -cost);

// If we can see the victim...
if(HasLOS(player, victim) && (victim != player))
{
dummy = FireProjectile(player, projectile, fireSound, 18, '0.0207 0.15 0.00', '0 0 0', 1.0, 0x00, autoAimFOV, autoAimMaxDist);
dummy2 = FireProjectile(player, projectile, 0, 18, '-0.05 0.2 -0.05', '0.0 0 0', 1.0, 0x00, autoAimFOV, autoAimMaxDist);
dummy3 = FireProjectile(player, projectile, 0, 18, '0.0 0.5 0.00', '0.0 0 0', 1.0, 0x00, autoAimFOV, autoAimMaxDist);
dummy4 = FireProjectile(player, projectile, 0, 18, '0.05 0.3 0.07', '0.0 0 0', 1.0, 0x00, autoAimFOV, autoAimMaxDist);
wait = 0;
KillTimerEx(3);
call timer;
}

}

jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon(player, mode);
active = 0;
Return;

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


timer:

timerID = GetSenderId();

//Check which timer is being sent
if(timerID == 2)
{
StopKey(player, holsterTrack, 0.0);
Return;
}
else
if(HasLOS(dummy, victim) && (victim != dummy) && (GetThingHealth(victim) > 0))
{
//Create a new vector from the projectiles to the victim
path = VectorSub(GetThingPos(victim), GetThingPos(dummy));
path2 = VectorSub(GetThingPos(victim), GetThingPos(dummy2));
path3 = VectorSub(GetThingPos(victim), GetThingPos(dummy3));
path4 = VectorSub(GetThingPos(victim), GetThingPos(dummy4));

path0 = VectorNorm(path);
path02 = VectorNorm(path2);
path03 = VectorNorm(path3);
path04 = VectorNorm(path4);

path00 = VectorScale(path0, 1.5);
path002 = VectorScale(path02, 1.5);
path003 = VectorScale(path03, 1.5);
path004 = VectorScale(path04, 1.5);

//Stop the homing timer
KillTimerEx(3);
call home;
}
else
{
KillTimerEx(3);
}
Return;

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

selected:
print("Swarm Missile");
player = GetSourceRef();

// Play external mounting animation
PlayMode(player, 41);

// Setup the meshes and models.
jkSetPOVModel(player, povModel);
SetArmedMode(player, 1);
jkSetWeaponMesh(player, weaponMesh);
jkSetWaggle(player, '10.0 7.0 0.0', 350);

// Play mounting sound.
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, 20);
SetMountWait(player, GetKeyLen(mountAnim));

// Clear saber flags, and allow activation of the weapon
jkClearFlags(player, 0x5);
SetCurWeapon(player, 7);

// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 15) < 1.0)
{
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
if(GetAutoSwitch() & 1)
SelectWeapon(player, AutoSelectWeapon(player, 1));
}
Return;

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

deselected:
call stop_power;
player = GetSourceRef();

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);
KillTimerEx(3);
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;

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

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

newplayer:
call stop_power;

Return;

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

stop_power:
SetPulse(0);
active = 0;
jkEndTarget();
DeactivateWeapon(player, mode);
KillTimerEx(3);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
Return;

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

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

home:

random = Rand();
random2 = Rand();
random3 = Rand();
random4 = Rand();

// There is a small chance that the missiles will miss otherwise it's
// too powerful

if(wait == 0)
{
wait = 1;
SetTimerEx(0.2, 3, 0, 0);
Return;
}
else
if(wait == 1)
{
if(random <= 0.8)
{
// Set the projectiles velocity to head towards the victim
SetThingVel(dummy, path00);
#Print("Homing");
}

if(random2 <= 0.75)
{
SetThingVel(dummy2, path002);
}

if(random3 <= 0.6)
{
SetThingVel(dummy3, path003);
}

if(random2 <= 0.5)
{
SetThingVel(dummy4, path004);
}
}
// Set the timer for 0.7 seconds before the missiles re-check their direction
SetTimerEx(0.7, 3, 0, 0);

Return;

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

autoselect:
selectMode = GetSenderRef();
player = GetSourceRef();

// If the player has the weapon
if(GetInv(player, 7) != 0.0)
{
// If the player has ammo
if(GetInv(player, 15) > 1.0)
{

// query for ammo
if(selectMode == -1)
{
ReturnEx(1000.0);
Return;
}

if((selectMode == 0) && !(GetAutoPickup() & 2))
{
ReturnEx(1000.0);
Return;
}

if((selectMode == 1) && !(GetAutoSwitch() & 2))
{
ReturnEx(1000.0);
Return;
}

if((selectMode == 2) && !(GetAutoPickup() & 2))
{
ReturnEx(1000.0);
Return;
}

ReturnEx(-2.0);
Return;

}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}

Return;
end

2000-11-17, 4:51 AM #2
Templates from static.jkl will only be created on the person's computer that called FireProjectile().

You can, however, get around this by using triggers.

There's a tutorial at Millenium about it here.

↑ Up to the top!