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 → Another Problem has arisen...
Another Problem has arisen...
2005-02-18, 1:21 PM #1
Hi!
New problem. I am attempting an Air Strike, though I don't think it is working properly... In the code, I did so that when you had a lock on someone and released the trigger, conc bullets would come raining down, if there was a high enough ceiling. 2 problems though:

1. After I've hit my target, the game quits. Not to desktop, but to the main menu.
2. It seems like only one vertex is registered because I only see one bullet come raining down, though I am sure of that there are more vertices in the level. I'm testing this in the big open level 06.

Code:
# Jedi Knight Cog Script
#
# WEAP_CONCRIFLE.COG
#
# WEAPON 9 Script - Concussion Rifle
#
# The trusty weapon of the Bossk race. It fires a concussive blast with a maximum
# range of 30 meters, from there it creates an explosion that has a spread of about
# 4 meters in diameter.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================

symbols

model       povModel=conv.3do                   local
model       weaponMesh=cong.3do                 local

keyframe    mountAnim=ConVmnt.key               local
keyframe    dismountAnim=ConVdis.key            local
keyframe    povfireAnim=ConVpst1.key            local
keyframe    povfireAnim2=detvpre1.key            local
keyframe    holsterAnim=kyhlstr.key             local

sound       mountSound=df_rif_ready.wav         local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=concuss5.wav              local
sound       outSound=concuss1.wav               local
sound		callSound=i00o305z.wav		local
sound		incoming=Nouveau.wav		local

flex        fireWait=1.2                        local
flex        powerBoost                          local
flex        autoAimFOV=30                       local
flex        autoAimMaxDist=5                    local
flex        holsterWait                         local

int         dummy                               local

template    projectile=+concbullet              local
template    projectile3=+concbullet2             local
template	in=+lightninghit		local

thing       player                              local
thing		p				local
int		vercount=0			local
int         trackID=-1                          local
int         mode                                local
int         holsterTrack                        local
flex		rank=4				local
int		victim=-1			local
int		potential=-1			local
flex		maxdot				local
flex		dot				local

int         selectMode=1                  local
vector		lv			local
vector		lvr			local
int		i			local
sector		sector			local
thing		returnpos		local
template	ghost=+repeaterball	local
int		isaflag			local

message     activated
message     deactivated
message     selected
message     deselected
#message     newplayer
message     autoselect
message     fire
message     timer

end

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

code

fire:
   // Check that the player is still alive.
   if(GetThingHealth(player) <= 0)
   {
      Return;
   }

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

   if(mode == 0)
   {
      dummy = FireProjectile(player, projectile, fireSound, 18, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
      ChangeInv(player, 12, -8.0);
     ChangeFireRate(player, fireWait/powerBoost);
   SetPOVShake('0.0 -.03 0.0', '4.0 0.0 0.0', .05, 80.0);
   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   // Provide a kick backwards
   ApplyForce(player, VectorScale(GetThingLVec(player), -80));

   }
   else
   {

	ChangeFireRate(player, 0.01);
   // Check all things for our victim.
   victim = -1;
   maxDot = 0;

   // Search for all players, actors and items.
   potential = FirstThingInView(player, 20 + 15 * rank, 5.5, 0x424);
   while(potential != -1)
   {
      if(
         HasLOS(player, potential) && 
         (potential != player) && 
         (VectorDist(GetThingPos(player), GetThingPos(potential)) <= 10) && 
         !(GetThingFlags(potential) & 0x200) && 
         !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)) && 
         !(GetPhysicsFlags(potential) & 0x400000) &&
	 !(GetThingType(potential)==5)
	)
      {
         // Hack to avoid targetting a CTF flag...
         IsAFlag = 0;

         if(!IsAFlag)
         {
            dot = ThingViewDot(player, potential);
            if(dot > maxDot)
            {
               victim = potential;
               maxDot = dot;

            }
         }

      }
      potential = NextThingInView();
   }

   // If we have a victim...
   if(victim != -1)
   {
      jkSetTargetColors(rand()*255,rand()*255,rand()*255);
      jkSetTarget(victim);
   }
   else
   {
      jkEndTarget();
   }

   }


   powerBoost = GetInv(player, 63);

   Return;

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

activated:
   player = GetSourceRef();
   mode = GetSenderRef();

   jkSetWaggle(player, '0.0 0.0 0.0', 0);

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

   Return;

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

deactivated:
   player = GetSourceRef();
   mode = GetSenderRef();

	if(mode==1)
	{
		jkEndTarget();
		vercount=0;
		if(victim == -1) return;
		sector=GetThingSector(player);
		SetPOVShake('0.0 -.03 0.0', '4.0 0.0 0.0', .05, 80.0);
		returnpos=FireProjectile(player,ghost,-1,-1,'0 0 0.1','0 0 0',0,0,0,0);
		for(sector=0; sector<=GetSectorCount(); sector=sector+1) {
		for(i=0; i<=GetNumSectorVertices(sector); i=i+1)
		{
			if(VectorZ(GetSectorVertexPos(sector, i))>VectorZ(GetThingPos(player))+1)
			{
				lv=VectorSub(GetSectorVertexPos(sector, i),GetSectorVertexPos(sector, i+1));
				lvr=VectorSet(-VectorX(lv),-VectorY(lv),-VectorZ(lv));
				lv=VectorSub(GetSectorVertexPos(sector, i),GetThingPos(victim));
				lvr=VectorSet(-VectorX(lv),-VectorY(lv),-VectorZ(lv));
				dummy=CreateThingAtPos(ghost,sector,GetSectorVertexPos(sector, i),lvr);
				CaptureThing(dummy);
				SetThingLook(dummy,lvr);
				TeleportThing(player,dummy);
				if(HasLos(player,victim)) {
				p=FireProjectile(player,projectile3,-1,-1,'0 0 0','0 0 0',0,0x00,0,0);
				SetThingVel(p,VectorScale(lvr,powerBoost));
//				p=FireProjectile(player,projectile3,-1,-1,'.1 0 0','0 0 0',0,0x00,0,0);
//				SetThingVel(p,VectorScale(lvr,powerBoost));
//				p=FireProjectile(player,projectile3,-1,-1,'0 0 .1','0 0 0',0,0x00,0,0);
//				SetThingVel(p,VectorScale(lvr,powerBoost));
//				p=FireProjectile(player,projectile3,-1,-1,'.1 0 .1','0 0 0',0,0x00,0,0);
//				SetThingVel(p,VectorScale(lvr,powerBoost));
//				p=FireProjectile(player,projectile3,-1,-1,'-.1 0 0','0 0 0',0,0x00,0,0);
//				SetThingVel(p,VectorScale(lvr,powerBoost));
//				p=FireProjectile(player,projectile3,-1,-1,'0 0 -.1','0 0 0',0,0x00,0,0);
//				SetThingVel(p,VectorScale(lvr,2*powerBoost));
//				p=FireProjectile(player,projectile3,-1,-1,'-.1 0 -.1','0 0 0',0,0x00,0,0);
//				SetThingVel(p,VectorScale(lvr,powerBoost));
}				DestroyThing(dummy);
				vercount=vercount+1;
			}
		} }
		TeleportThing(player,returnpos);
		DestroyThing(returnpos);
		if(vercount>0) {
		jkPlayPOVKey(player, povfireAnim2, 1, 0x38);
		PlaySoundThing(callSound,player,1,-1,-1,0x0);
		PlaySoundGlobal(incoming,1,0,0x0); }

	}
   jkSetWaggle(player, '10.0 7.0 1.0', 350);
   DeactivateWeapon( player, mode );

   Return;

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

selected:
   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, 9);

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

   Return;

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

deselected:
   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);
   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;

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

//newplayer:
// player = GetSourceRef();
//
// // Make sure that if the player is respawning, the old mount isn't playing anymore.
// if (trackID != -1)
//    jkStopPOVKey(player, trackID, 0);
//
// Return;

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

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

   // If the player has the weapon
   if(GetInv(player, 9) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) > 7.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;

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

timer:
   StopKey(player, holsterTrack, 0.0);
   Return;

end


Now, you're probebly wondering about the 6 commented out FireProjectiles... Well, I can't decide how many bullets I want from each vertex, so... And also, about searching for all vertices in all sectors, that is because when I fire from the ground in 06, I'm not in the same sector as the sky. Not until I'm up on the bridges and so on do I get in the same sector as the sky. I am using HasLos to make sure I don't blow something else up by misstake, but I guess that ain't good enough... What do I need so that the bombing comes from the sky.

/Edward
Edward's Cognative Hazards
2005-02-21, 8:39 AM #2
Hello? Was this a bit too tricky for you guys?
Edward's Cognative Hazards

↑ Up to the top!