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 → Line 'em up, Knock 'em down
Line 'em up, Knock 'em down
2002-07-19, 3:02 PM #1
could someone tell me what code to put in a force push cog so it plays a key where the guy gets knocked down, and while the key is playing he can't do anything?
Those who live by the sword get shot by those who don't.
OSC
2002-07-19, 3:36 PM #2
JK/MOTS? JK MOTS?!?!?!?!

CaptureThing(target);
...
ReturnEx(0);

Something like that.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-19, 3:59 PM #3
No, no, no Grismath! That won't work!

Add this line in the force_push.cog.
Code:
SendMessage(GetThingClassCog(victim), user1);
Add this to kyle.cog.
Code:
User1:
   SetActorFlags(player, 0x240000);
   PlayKey(player, falldown, 1, 0x0);
   SetTimerEx([a flex delay], GetKeyLen(falldown), 0, 0);
   Return;
Timer:
   If(GetSenderID() == [the ID number])
   {
      ClearActorFlags(player, 0x240000);
   }
There, you don't have to add any symbols except for the keyframe, just replace the [] with a number. As it stands, this shuold only work in MP.

------------------
The Sniper Missions. Current project, The Sniper Missions

[This message has been edited by Descent_pilot (edited July 21, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-19, 4:10 PM #4
Thanks, and by the way, its jk. sorry for not mentioning.
Those who live by the sword get shot by those who don't.
OSC
2002-07-19, 4:17 PM #5
ahhh, doesn't really matter here.

------------------
The Sniper Missions. Current project, The Sniper Missions
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-20, 10:18 AM #6
Just one more question. where does the code go in the cog? (i.e. top, bottom, middle...)
Those who live by the sword get shot by those who don't.
OSC
2002-07-20, 12:03 PM #7
User1 can go anywhere, because it hasn't been defined (add message user0 in the symbols). Timer, you have to splice that into the normal timer, on the top. Post the entire cog with done for final debugging.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited July 21, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-20, 2:41 PM #8
Shouldn't it be
Code:
SendMessage(GetThingClassCog(victim), user0);
?
And meanwhile the bus with legs has destroyed half of disneyland . . . and nobody cares!
2002-07-21, 5:01 AM #9
Sorry for the bad typing, changed all user0s to user1s. User1, because there's already a user0 in kyle.cog. If you want to make this for SP, you have to change all of the class cogs for all of the enimies.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited July 21, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-21, 5:05 AM #10
What you should do is use SkillTarget() just like the original force powers. Also, I don't think you need to use 0x40000 as well as 0x200000 for immobilization.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited July 21, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-21, 8:30 AM #11
hmmmm. Never thought of that.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-22, 4:59 AM #12
Here are the cogs. (by the way, the push isn't mine, i modified MrGrim's.

kyle.cog
Code:
symbols

thing       player                           local

int         nextBlock=0                      local
int         bin                              local
int         rank                             local

int         force_blinding=0                 local
int         blindingEffectHandle=-1          local
int         PulledWeapon                     local

int         playersector                     local
vector      playerpos                        local
int         bub                              local

template    tpl=+FPBryarPistol               local
template    tpl1=+FPBryarPistol              local
template    tpl2=+FPBryarPistol              local
template    tpl3=+FPSTrifle                  local
template    tpl4=+FPDetonator                local
template    tpl5=+FPCrossbow                 local
template    tpl6=+FPRepeaterGun              local
template    tpl7=+FPRailGun                  local
template    tpl8=+FPSeqCharge                local
template    tpl9=+FPConcRifle                local

template    smoke_tpl=+heavysmoke            local
int         smoke                            local

template    teleport_particles=+telesparks   local
sound       teleportsnd=ForceThrow01.WAV     local

template    bubble_tpl=bubble                local
template    bubble_tpl2=bubble2              local
template    bubble_tpl3=bubble3              local

template    splash_tpl=+watersplash          local
template    splash_tpl2=+watersplash2        local
int         a_splash                         local
int         sender                           local
int         source                           local

keyframe    povBlockAnim0=SabVblk0.key       local
keyframe    povBlockAnim1=SabVblk1.key       local
keyframe    povBlockAnim2=SabVblk2.key       local

keyframe    blockAnim0=KYblock0.key          local
keyframe    blockAnim1=KYblock1.key          local
keyframe    blockAnim2=KYblock2.key          local

keyframe    knockdown=kyknockdown.key        local

int         dummy=0                          local
int         blockPOVTrack=-1                 local
int         blockTrack=-1                    local

int         griptrackID=-1                   local

message     startup
message     killed
message     newplayer
message     timer
message     blocked
message     skill
message     damaged
message     splash
message     user0

end

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

code

startup:
   player = GetLocalPlayerThing();

   if(!IsMulti()) call init_kyle;

   // Bubbles
   if(IsMulti())
      SetTimerEx(4 + 5 * rand(), 2, 0, 0);
   else
      SetTimerEx(2 + 5 * rand(), 2, 0, 0);

   Return;

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

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

   if(IsMulti())
   {
      CreateBackpack(player);
      ClearActorFlags(player, 0x2000);
   }

   // clean up force powers stuff
   if(blindingEffectHandle!=-1)
   {
      freeColorEffect(blindingEffectHandle);
      blindingEffectHandle = -1;
   }
   ClearActorFlags(player, 0x800);
   KillTimerEx(27);
   force_blinding = 0;

   ClearActorFlags(player, 0x40000);

   if(griptrackID != -1)
   {
      StopKey(player, griptrackID, 0.1);
      griptrackID = -1;
   }

   Return;

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

damaged:
   if(GetParam(1) == 32) call make_bubbles;

   ReturnEx(GetParam(0));
   Return;

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

make_bubbles:
   playersector = GetThingSector(player);
   playerpos    = VectorAdd(GetThingPos(player), '0 0 0.075');

   for(bub = 1; bub < 1 + 3 * rand(); bub = bub + 1)
   {
      CreateThingAtPosNR(bubble_tpl[3 * rand()], playersector, VectorAdd(playerpos,
      VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 
      0 0');
      Sleep(0.05);

      // Don't create too many bubbles over the network...
      if(!IsMulti())
      {
         CreateThingAtPos(bubble_tpl3, playersector, VectorAdd(playerpos,
      VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0
      0 0');
         Sleep(0.05);
      }
   }

   Return;

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

newplayer:

   call init_kyle;

   // If it's multiplayer
   if(IsMulti()) call init_multi_kyle;

   // Start Bubbles
   SetTimerEx(2 + 5 * rand(), 2, 0, 0);

   Return;

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

timer:
   if(GetSenderId() == 1)                    // Invulnerable for a while
   {
      // jkSetInvulnerable(GetParam(0), 0);
      ClearActorFlags(GetParam(0), 8);
      Return;
   }
   else
   if(GetSenderId() == 2)                    // Bubbles check
   {
      if(GetThingHealth(player) < 1) Return;

      if((GetThingFlags(player) & 0x2000000) && !(GetPhysicsFlags(player) & 0x100000))
         call make_bubbles;

      if(IsMulti())
         SetTimerEx(4 + 5 * rand(), 2, 0, 0);
      else
         SetTimerEx(2 + 5 * rand(), 2, 0, 0);

      Return;
   }
   else
   if(GetSenderId() == 24)
   {
      // A pulled weapon must be made takeable again
      SetCollideType(GetParam(0), 1);
      Return;
   }
   else
   if(GetSenderId() == 27)
   {
      ClearActorFlags(player, 0x240000);
   }
   else
   if(GetSenderId() == 31)
   {
      if(griptrackID != -1)
      {
         StopKey(player, griptrackID, 0.1);
         griptrackID = -1;
      }
      ClearActorFlags(player, 0x40000);
      Return;
   }
   
   Return;

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

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

   if (blockPOVTrack != -1)
   {
      jkStopPOVKey( player, blockPOVTrack, 0.1 );
      blockPOVTrack = -1;
   }
   if (blockTrack != -1)
   {
      StopKey( player, blockTrack, 0.1 );
      blockTrack = -1;
   }

   // PlaySoundThing(hitSound14, player, 1.0, -1, -1, 0);
   blockPOVTrack = jkPlayPOVKey(player, povBlockAnim0[nextBlock], 2, 0x1a);
   blockTrack = PlayKey(player, blockAnim0[nextBlock], 2, 0x1a);

   nextBlock = nextBlock + 1;
   if(nextBlock > 2)
      nextBlock = 0;

   Return;

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

// This message is sent from the weap_saber.cog
user0:
   if (blockPOVTrack != -1)
   {
      jkStopPOVKey( player, blockPOVTrack, 0.1 );
      blockPOVTrack = -1;
   }
   if (blockTrack != -1)
   {
      StopKey( player, blockTrack, 0.1 );
      blockTrack = -1;
   }
   Return;

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

skill:

   // player might be dead when skill: arrives over the net...
   if(GetThingHealth(player) <= 0) Return;

   // Handle multiplayer force power effects
   bin = GetParam(0);
   rank = GetParam(1);

   if(bin == 24)                             // Force Pull
   {
      ReturnEx(0);
      if(!IsInvActivated(player, 28))        // Absorb makes player immune to Pull
      {
         if((GetCurWeapon(player) != 1) && (GetCurWeapon(player) != 10))
         {
            // Create a powerup corresponding to the current weapon
            PulledWeapon = CreateThingAtPos(tpl[GetCurWeapon(player)], GetThingSector(player), GetThingPos(player), '0 0 0');

            // Make the powerup collide later
            SetTimerEx(0.2, 24, PulledWeapon, 0);

            // Duplicate for internet games
            SetTimerEx(0.25, 24, PulledWeapon, 0);

            // Throw the powerup at the player
            ApplyForce(PulledWeapon, VectorScale(VectorNorm(VectorSub(GetThingPos
            (GetSourceRef()), GetThingPos(player))), 30));

            // Remove the weapon from the player
            ChangeInv(player, GetCurWeapon(player), -1);

            // Switch to fists
            SelectWeapon(player, 1);

            ReturnEx(1);
         }
      }

      Return;
   }
   else
   if (bin == 27)                            // Force Blinding
   {
      if((!force_blinding) && (!IsInvActivated(player, 23)))   // Seeing makes player immune to Blinding
      {
         User1:   SetActorFlags(player, 0x240000);   
         PlayKey(player, knockdown, 1, 0x0);   
         SetTimerEx([a flex delay], GetKeyLen(knockdown), 0, 0);   
         Return;
      }
      else
      {
         ReturnEx(0);
      }

      Return;
   }
   else
   if (bin == 31)                            // Force Grip
   {
      if(!IsInvActivated(player, 29))        // Protection makes player immune to Grip
      {
         griptrackID = PlayMode(player, 25);
         SetActorFlags(player, 0x40000);

         // Print("You are taking Grip damage");
         jkPrintUNIString(player, 300);
         DamageThing(player, 2 * rank, 0x8, GetSourceRef());
         SetTimerEx(0.5, 31, player, 0);
         ReturnEx(1);
      }
      else
      {
         ReturnEx(0);
      }

      Return;
   }
   else
   if (bin == 34)                            // Deadly Sight
   {
      // Print("You are taking Deadly Sight damage");
      jkPrintUNIString(player, 301);
      DamageThing(player, 4 * rank, 0x8, GetSourceRef());
      smoke = CreateThingAtPosNR(smoke_tpl, GetThingSector(player), GetThingPos(player), '0 0 0');
      // Raise the tint above the normal damage tint
      if(GetCurrentCamera() == 0)
         AddDynamicTint(player, 0.15, 0.0, 0.07);
      ReturnEx(1);
      Return;
   }

   ReturnEx(-1);
   Return;

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

splash:
   // splash: messages are only sent to the local player's cogs
   // (class cog and capture cog) for performance reasons...

   sender = GetSenderRef();
   source = GetSourceRef();

   // actor or player ?
   if((GetThingType(sender) == 2) || (GetThingType(sender) == 10))
   {
      // whatever source (i.e. enter or leave, don't care)
      a_splash = CreateThingAtPosNR(splash_tpl2, GetThingSector(sender), GetThingPos(sender), '0 0 0');
   }
   // these are mostly the projectiles...
   else
   {
      // on entering only
      if(source == 1)
         // not if player is submerged, but still do it if he's on the surface
         if(!(GetThingFlags(player) & 0x2000000) || (GetPhysicsFlags(player) & 0x100000))
            a_splash = CreateThingNR(splash_tpl, sender);
   }

   Return;

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

init_kyle:
   SetActorFlags(player, 8);
   SetTimerEx(1.50, 1, player, 0);

   // Set Health to full
   SetThingHealth(player, 100);

   // Set Mana to full
   SetInv(player, 14, GetInv(player, 20) * 50);

   // Set Shields to 100 minimum
   if(GetInv(player, 60) < 100) SetInv(player, 60, 100);

   // Set Battery to 100 minimum
   if(GetInv(player, 13) < 100) SetInv(player, 13, 100);

   // Set the power boost to 1.0
   SetInv(player, 63, 1.0);

   // When player starts, give him fists, and a bryar.
   SetInv(player, 1, 1.0);
   SetInv(player, 2, 1.0);

   // Give 50 energy minimum
   if(GetInv(player, 11) < 50) SetInv(player, 11, 50.0);

   // Bacta
   if(GetInv(player, 40) == 0)
      SetInvAvailable(player, 40, 0);
   else
      SetInvAvailable(player, 40, 1);

   // IR Goggles
   if(GetInv(player, 41))
      SetInvAvailable(player, 41, 1);
   else
      SetInvAvailable(player, 41, 0);
   SetInvActivated(player, 41, 0);

   // Field Light
   SetInv(player, 42, 1);
   SetInvAvailable(player, 42, 1);
   SetInvActivated(player, 42, 0);
   ClearActorFlags(player, 4);

   jkEndTarget();

   Return;

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

init_multi_kyle:

   // Set Weapons
   SetInv(player, 1, 1.0);
   SetInv(player, 2, 1.0);
   SetInv(player, 3, 0.0);
   SetInv(player, 4, 0.0);
   SetInv(player, 5, 0.0);
   SetInv(player, 6, 0.0);
   SetInv(player, 7, 0.0);
   SetInv(player, 8, 0.0);
   SetInv(player, 9, 0.0);
   SetInv(player, 10, 1.0);

   // Set Ammo
   SetInv(player, 11, 50.0);
   SetInv(player, 12, 0.0);
   SetInv(player, 15, 0.0);

   // Remove bacta tank and IR goggles
   SetInv(player, 40, 0);
   SetInv(player, 41, 0);
   SetInvAvailable(player, 40, 0);
   SetInvAvailable(player, 41, 0);

   // Set shields to 100
   SetInv(player, 60, 100);

   // Do respawn effects
   dummy = CreateThingAtPos(teleport_particles, GetThingSector(player),
   GetThingPos(player), '0 0 0');
   dummy = PlaySoundThing(teleportsnd, player, 1.0, -1, -1, 0x180);

   SetFireWait(player, -1);
   SetMountWait(player, 0);
   SetCurInvWeapon(player, 0);
   SelectWeapon(player, AutoSelectWeapon(player, 1));

   Return;

end


force_blinding.cog (push replaces blinding)

Code:
symbols

thing       player                           local
thing       victim                           local
thing       potential                        local

flex        mana                             local
flex        cost=0.0                         local
flex        delay=10.0                       local
int         rank                             local
int         count                            local
int         retval=0                         local
int         dummy                            local

flex        dot                              local
flex        maxDot                           local

sound       blindingSound=orceblind   local
template    cone_tpl=+orce_blind            local

int         active=0                         local

message     startup
message     activated
message     deactivated
message     pulse
message     timer
message     newplayer
message     killed
message     deselected
message     selected

# ......................................................................................
# External animations

keyframe push=kyrepel0.key        local

end

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

code

startup:
   player = GetlocalPlayerThing();

   Return;

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

activated:
   if(active) Return;

   mana = GetInv(player, 14);
   rank = GetInv(player, 24);

   if(mana >= cost)
   {
      victim = -1;
      active = 1;
      SetInvActivated(player, 27, 1);
      SetPulse(0.33);
   }

   Return;

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

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

   // Search for all players and actors.
   potential = FirstThingInView(player, 30 + 15 * rank, 8, 0x404);
   while(potential != -1)
   {
      if(
         HasLOS(player, potential) &&
         (potential != player) &&
         (VectorDist(GetThingPos(player), GetThingPos(potential)) <= (1 + rank)) &&
         !(GetThingFlags(potential) & 0x200) &&
         !(GetActorFlags(potential) & 0x100) &&
         !((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(19, 20, 18);
      jkSetTarget(victim);
      SendMessage(GetThingClassCog(victim), user1);
   }
   else
   {
      jkEndTarget();
   }

   Return;

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

deactivated:
   if((victim == -1) || (GetThingHealth(player) <= 0))
   {

      call stop_power;
      Return;
   }

   SetPulse(0);
   jkEndTarget();

   mana = GetInv(player, 14);
   if(mana >= cost)
   {
      if(GetInv(player, 65) != 1) ChangeInv(player, 14, -cost);
      SetBinWait(player, 27, 0.2);
      rank = GetInv(player, 27);

      SetTimer(delay);
      if(HasLOS(player, victim) && (victim != player))
      {
         PlayMode(player, 24);
         PlayKey(player, push, 1, 0x38);
         PlaySoundThing(blindingSound, player, 1.0, -1, -1, 0x80);
         dummy = CreateThingAtPosNR(cone_tpl, GetThingSector(player), VectorAdd(GetThingPos(player), '0.0 0.0 0.04'), '0.0 0.0 0.0');
            DetachThing(victim);
            ApplyForce(victim, VectorScale(VectorNorm(VectorSub(GetThingPos(victim),GetThingPos(player))), 150 * rank));
         SetThingLook(dummy, VectorSub(GetThingPos(victim), GetThingPos(player)));
      }
   }

   active = 0;
   SetInvActivated(player, 27, 0);

   Return;

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

timer:
   // This checks that the thing ref is still assigned to the same thing
   // (remember he could have died and its refrence reassigned to a generated thing)

   Return;

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

selected:
   jkPrintUNIString(player, 27);
   Return;

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

deselected:
   call stop_power;

   Return;

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

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

newplayer:
   call stop_power;

   Return;

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

stop_power:
   SetPulse(0);
   SetInvActivated(player, 27, 0);
   active = 0;
   jkEndTarget();

   Return;

end


[This message has been edited by SaberMaster (edited July 22, 2002).]
Those who live by the sword get shot by those who don't.
OSC
2002-07-22, 7:08 AM #13
Okay, SaberMaster's way is better. Get rid of user1: but leave all the lines there after in the skill. You also must replace the [a felx dealy] with a flex in kyle.cog. In force_push.cog, you can get rid of the SendMessage line, we won't need that, and unless you're going to add something in the timer, remove that as well.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-22, 11:13 AM #14
Always use the UBB code tags when posting cogs, ForceDude. You should only be posting relevant parts of it anyway - not the whole thing.

Anyway, what force power does your power replace? If it was blinding, then you would replace the code for blinding in the skill message of kyle.cog. Be sure to remove any of the coding that the replaced force power used. For example, blinding has a timer to stop the blinding effect and several variables.

The DataMaster includes a thorough description of SkillTarget() and the skill message.

Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!