Author Topic: Semi-Permanent Level Drain  (Read 2103 times)

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #15 on: May 31, 2016, 06:59:35 pm »


               

s/GetIsValid/GetIsObjectValid/  '<img'>



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #16 on: May 31, 2016, 07:21:04 pm »


               

Thanks meaglyn



               
               

               
            

Legacy_r8_

  • Newbie
  • *
  • Posts: 47
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #17 on: June 01, 2016, 09:25:43 pm »


               

Thanks for your help, I thought I'd post the scripts. I need to test them further, but I'm pretty sure they work well enough.


 


First I created an invisible object with the tag: q6e_ShaorisFellTemple ... Then, this is placed in OnPlayerRespawn module event:



//added 5/31/16, fires the level drain respawn penalty
//uses a special tag the makes the level drain semi-permanent/unremovable
object oLvlDrainer = GetObjectByTag("q6e_ShaorisFellTemple");
ExecuteScript("rui_leveldrain", oLvlDrainer);

 rui_leveldrain.nss which applies the penalty and executes the timer loop:



#include "NW_I0_GENERIC"
#include "nw_i0_spells"

// 6/1/16 applies respawn penalty

void main()
{
    object oTarget = GetLastRespawnButtonPresser();
    int iLevel = GetCharacterLevel(oTarget);
    int iHalfLvl = iLevel / 2;
    effect eDrain = SupernaturalEffect(EffectNegativeLevel(iHalfLvl));
    effect eVis = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);

    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrain, oTarget);
    SendMessageToPC(oTarget, "Level drain applied as a respawn penalty, lasting 3 minutes.");
    ExecuteScript("rui_leveldloop", oTarget);
}

This makes sure the level drain is removed after re-logging + added the timer (rui_leveldloop.nss):



#include "nw_i0_spells"

// 6/1/16 removes respawn penalty, and creates a continuous loop to detect player and remove penalty if player logs off and rejoins
// when a player logs on when the penalty is still active, their timer restarts with 3 minutes remaining
// my thread: http://forum.bioware.com/topic/572976-semi-permanent-level-drain/

void main()
{
    object oPC = OBJECT_SELF;
    if(!GetIsObjectValid(oPC))
    {
        DelayCommand(20.0, ExecuteScript("rui_leveldloop", oPC));
    }
    else
    {
        DelayCommand(180.0, RemoveSpecificEffect(EFFECT_TYPE_NEGATIVELEVEL, oPC));
        DelayCommand(180.0, SendMessageToPC(oPC, "Your respawn penalty is longer in effect."));
    }
}


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #18 on: June 01, 2016, 09:30:28 pm »


               

You might want to use GetLastRespawnButtonPresser() to get the target PC.  The respawner may not be the last player who died.



               
               

               
            

Legacy_r8_

  • Newbie
  • *
  • Posts: 47
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #19 on: June 01, 2016, 09:33:27 pm »


               

Fixed it, thanks.



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #20 on: June 02, 2016, 01:48:15 am »


               

hmmm, not quite there...Your close, but you might want to do it this way...


 


#include "NW_I0_GENERIC"
#include "nw_i0_spells"
 
// 6/1/16 applies respawn penalty
 
void main()
{
    object oTarget = GetLastRespawnButtonPresser();
    int iLevel = GetCharacterLevel(oTarget);
    int iHalfLvl = iLevel / 2;
    effect eDrain = SupernaturalEffect(EffectNegativeLevel(iHalfLvl));
    effect eVis = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);
 
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrain, oTarget);
    SendMessageToPC(oTarget, "Level drain applied as a respawn penalty, lasting 3 minutes.");
    DelayCommand(180.0f, ExecuteScript("rui_leveldloop", oTarget));
}

               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #21 on: June 02, 2016, 01:56:24 am »


               

#@*&%*#!!!!


 


The forum keeps cliping the post.... here is the rest...


 


Delay the running of the leveldloop script


 


#include "nw_i0_spells"
 
// 6/1/16 removes respawn penalty, and creates a continuous loop to detect player and remove penalty if player logs off and rejoins
// when a player logs on when the penalty is still active, their timer restarts with 3 minutes remaining
// my thread: http://forum.bioware.com/topic/572976-semi-permanent-level-drain/
 
void main()
{
    object oPC = OBJECT_SELF;
    if(!GetIsObjectValid(oPC))
    {
        DelayCommand(20.0, ExecuteScript("rui_leveldloop", oPC));
    }
    else
    {
        RemoveSpecificEffect(EFFECT_TYPE_NEGATIVELEVEL, oPC);
        SendMessageToPC(oPC, "Your respawn penalty is longer in effect.");
    }
}

               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #22 on: June 02, 2016, 01:57:34 am »


               

#@*&%*#!!!!


#@*&%*#!!!!


#@*&%*#!!!!


 


here is the last of the post....


 


Then if the pc is found, restore them, otherwise loop....

 

The way you have it now, if the pc logs out after being found by the routine and they log out for whatever reason, the delayed restore wont find them and they will not receive a restore untill the server resets as the routing has terminated.

 

The forum can be fickle at times, and I am really tire. Just had a long day. 

 

Excuse my hieroglyphics ':wacko:'  


               
               

               
            

Legacy_r8_

  • Newbie
  • *
  • Posts: 47
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #23 on: June 02, 2016, 03:01:23 am »


               

...We all have those kinds of days KMdS '<img'>


 



The way you have it now, if the pc logs out after being found by the routine and they log out for whatever reason, the delayed restore wont find them and they will not receive a restore untill the server resets as the routing has terminated.


 


After I posted the leveldloop script earlier, I realized my error--when a PC logs back in (after logging out before the timer ends), their level drain wouldn't be removed properly.


 


So with the initial line:  



DelayCommand(180.0f, ExecuteScript("rui_leveldloop", oTarget));

If the player logs off of the server in less than 180 seconds, rui_leveldloop will still execute on the player object? I'll test this tomorrow.


 


Thanks for your help so far.


               
               

               
            

Legacy_r8_

  • Newbie
  • *
  • Posts: 47
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #24 on: June 02, 2016, 03:52:10 pm »


               

It looks like your method doesn't work if the player relogs during the 180 second DelayCommand. My original scripts don't work in this instance either.


 


eg. level drain is not removed from the PC if he relogs, the only way to remove it is a server restart or switching characters.



               
               

               
            

Legacy_r8_

  • Newbie
  • *
  • Posts: 47
  • Karma: +0/-0
Semi-Permanent Level Drain
« Reply #25 on: June 04, 2016, 07:38:21 pm »


               

I found a solution for removing the level drain.


 


On module OnEnter, I just detect for level drain and remove it after 3 minutes. This makes the DelayCommand loop unnecessary.