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 → lucky_jackpot - about that force mana draining lightning...
lucky_jackpot - about that force mana draining lightning...
2003-11-21, 7:49 AM #1
Thanx 4 yer reply in the other forum -- I shoulda known it'd be controlled by COG; I get a bit confused when it comes to projectiles.

_K_
2003-11-22, 3:59 AM #2
Okies - first off, sorry to be a slow-a$$ pain - that annoying thing called a "personal life" got in the way (issues with family [http://forums.massassi.net/html/redface.gif]), so ... not wanting you to worry too much ( [http://forums.massassi.net/html/wink.gif]), I've drummed up this script.

NOTE however that this is far from perfect - but it's the best I could do in the short time, as I'm working the rest of the weekend now, and won't have time to sit down and code [http://forums.massassi.net/html/frown.gif] - so I give you *cue drum roll*:
The Imperfect "Force Drain" class cog script v1.0.

Code:
## Jedi Knight Cog Script
#
# FORCE_DRAIN.COG
#
# FORCEPOWER Script - DRAIN - replaces "Blinding"
#  Light (should be Dark) Side Power
#  Bin 27
#
# [Originally by YB]
#
# Modifed version of force blinding, so that the victim's health and mana
# become the attacker's (the force user's).
#
# This cog script is FAR from perfect - it's just a *(VERY) QUICK* altered version of
# LEC's "Force Blinding" that I drummed up - there are a couple of inconsistencies,
# and none of the script is *really* dependent upon "force assignment stars".
# (eg: "rank" based effects/duration)
#   The script also contains many "hard-coded" variables, that do not allow for
#   any real "dynamic updating"... :S
#
# If you wish to have it as an additional force power, then you'll need to edit
# "items.dat" file (make sure you have an "icon"), else it will crash JK !!!
#
#
# This COG script is NOT supported by LucasArts or LEC.
#
# Permission is granted to use this script by the author, as long as credit
# is provided in the readme file for any add-on levels that use this script.
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
##


symbols

thing       player                           local
thing       victim                           local
thing       potential                        local

flex        mana                             local
flex        cost=100.0                       local
int         rank                             local
int         count                            local
int         retval=0                         local
int         dummy                            local

flex        dot                              local
flex        maxDot                           local

sound       blindingSound=ForceBlind01.WAV   local
template    cone_tpl=+force_blind            local

int         active=0                         local

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

flex    playerHealth        local
flex    victimHealth        local
flex    damageAmount    local
flex    manaReductionRate=10   local
flex    minAmountNeeded=25     local

end

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

code

startup:
   player = GetlocalPlayerThing();

   Return;

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

activated:
   if(active) Return;

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

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

   Return;

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

pulse:

    if (GetInv (player, 14) <= minAmountNeeded)
        Return;

   // 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(6, 6, 6);
      jkSetTarget(victim);

        ChangeInv (player, 14, -10);

      PlaySoundThing(blindingSound, player, 1.0, -1, -1, 0x80);


        // Sort out "health" redistribution and dispersement...
        // This is tested and works...

      victimHealth = GetThingHealth (victim);
      damageAmount = 10;
      DamageThing (victim, damageAmount, 0x1, player);
      PrintInt (victimHealth);
      HealThing (player, 5);

        // Now deal with the force side of things...
        // NB: Could not test this next section of code
        // (for MP *OR* SP), so this is based on theory... :/

      if (IsInvAvailable (player, 14) > 0) {   // If the player's Force bin is available...
        if (IsInvAvailable (victim, 14) > 0 ) {     //...and the victim's Force bin is available
            ChangeInv (victim, 14, -manaReductionRate);  // reduce victim's mana...
            ChangeInv (player, 14, manaReductionRate); // increase player's mana...
        }
        else {
            Print ("NO FORCE to DRAIN....");
        }
      }

   }
   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);

      if(HasLOS(player, victim) && (victim != player))
      {
         PlayMode(player, 24);
//         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');
//         SetThingLook(dummy, VectorSub(GetThingPos(victim), GetThingPos(player)));

         // Blind victim for 5 seconds per rank
         if ( (GetThingType(victim) == 10) || (GetThingType (victim) == 2) )      // OTHER PLAYER
         {
            if(!(GetThingFlags(victim) & 0x200))
               retval = SkillTarget(victim, player, 27, rank);
         }
         else                                // ENEMY
         {
            // If bit is already set we kill the existing timer and start a new one
            if(GetActorFlags(victim) & 0x800) KillTimerEx(victim);
            SetActorFlags(victim, 0x800);

            // Pass signature (i.e. unique ID) as a check in param 0
            SetTimerEx(rank * 5, victim, GetThingSignature(victim), 0.0);
         }
      }
   }

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

   Return;

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

timer:
   // This checks that the thing ref is still assigned to the same thing
   // (remember the guy could have died and its ref reassigned to a generated thing)
   if(GetThingSignature(GetSenderId()) == GetParam(0))
   {
      ClearActorFlags(GetSenderId(), 0x800);
   }

   Return;

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

selected:
   jkPrintUNIString(player, 27);
   Return;

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

deselected:
   call stop_power;

   Return;

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

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

    Return;

newplayer:
   call stop_power;

   Return;

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

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

   Return;

end


Essentially, this is more a "base" for future work, rather than a defintive force power script - I'm just throwing ideas into the arena...

When I get more time, I can sit down and code it for you properly, if you want? The difficulty comes in testing it (especially if you're intending to use it for MP), because I don't have multiple machines to test it on... [http://forums.massassi.net/html/frown.gif]

Hope this has (somewhat) helped [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

NB for more experienced coggers: Before you ask - "Yes" this was a very (!!!) quickly drummed up script, ok? So go nicely and no bashing lol. I know it's a little glitchy [http://forums.massassi.net/html/wink.gif]

------------------
Are you feeling lucky, cuz if you are, get your hands off me... ;p

Initiator of the "Bring Back Jan Ors" Campaign!

"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2003-11-22, 10:09 AM #3
l_jp; you ROCK...!!! Thanx for this "base" script...!

QUOTE: "...Okies - first off, sorry to be a slow-a$$ pain..."

Yo, never a rush on my part -- no backside pain here [http://forums.massassi.net/html/wink.gif]

QUOTE: "...NOTE however that this is far from perfect - but it's the best I could do in the short time, as I'm working the rest of the weekend now..."

I work my full time job on the weekends -- I unnerstan'... I also run a bizness the rest o' th' time...

QUOTE: "...When I get more time, I can sit down and code it for you properly, if you want?..."

Sure...! But no rush wahtsoever...!

Thanx a million for this... no, I mean THANX...!

_K_

↑ Up to the top!