Author Topic: stunning script  (Read 6377 times)

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
stunning script
« on: December 31, 2004, 01:26:14 PM »
This is our script that declares the functions of our stunner.
But there is a problem I am not able to find...I'm sure the problem is pretty simple but still I can't see it  :angry2:
The script is divided into two parts

  if (GetTag (oItem) == "SpielerStunner")
   {
    object oTarget   = GetItemActivatedTarget();
    int iStunner     = GetLocalInt(oSpieler, "Stunned");
    int iChanged02   = GetLocalInt(oTarget, "AppChanged");

    if (iChanged02 == 1) return;

    if(GetIsDM(oTarget))return;

    if (iStunner == 0)
     {
      effect eVisual1 = EffectVisualEffect(VFX_IMP_LIGHTNING_S);
      effect eVisual2 = EffectVisualEffect(VFX_IMP_LIGHTNING_M);
      effect eVisual3 = EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION);
      effect eVisual4 = EffectVisualEffect(VFX_DUR_ICESKIN);
      effect eVisual5 = EffectVisualEffect(VFX_DUR_PARALYZE_HOLD);
      effect eHold    = EffectStunned();
      effect eHold2   = EffectParalyze();
      effect eHold3   = EffectDominated();
      effect eHold4   = EffectPetrify();
      effect eHold5   = EffectFrightened();

      AssignCommand(oTarget,ClearAllActions());
      SetLocalInt(oTarget, "DM_Hold_Flag", 1);
      SetLocalInt(oTarget, "DM_No_Magic", 1);

      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual1, oTarget);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual2, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVisual3, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVisual4, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVisual5, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHold, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHold2, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHold3, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHold4, oTarget);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHold5, oTarget);

      SetCommandable(FALSE, oTarget);
      SetCutsceneMode(oTarget, TRUE);
      DelayCommand(0.2, SetPlotFlag(oTarget,TRUE));
      SetLocalInt(oTarget, "Stunned", 1);
     }
    if (iStunner == 1)
     {
      // object oTarget =  GetItemActivatedTarget();
      // int iFlag = GetLocalInt(oTarget, "DM_Hold_Flag");

      effect eEffect = GetFirstEffect(oTarget);
      effect eVisual = EffectVisualEffect(VFX_IMP_HEALING_L);
      effect eVisual2 = EffectVisualEffect(VFX_IMP_HEAD_HEAL);
      AssignCommand(oTarget, ClearAllActions());

      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual2, oTarget);

      while (GetIsEffectValid(eEffect))
       {
        RemoveEffect(oTarget, eEffect);
        eEffect = GetNextEffect(oTarget);
       }
      SetLocalInt(oTarget, "DM_Hold_Flag", 0);
      SetLocalInt(oTarget, "DM_No_Magic", 0);
      SetCommandable(TRUE, oTarget);
      SetCutsceneMode(oTarget, FALSE);
      DelayCommand(0.2, SetPlotFlag(oTarget,FALSE));
      SetLocalInt(oTarget, "Stunned", 0);
     }
    }


As it is right now it only stuns the target  <_<
This is how it is supposed to work:

The first time you activate the stunner on a player the player will be stunned and can't do anything...most of us know this effect I suppose  :D
Then when you activate the item a second time on the stunned player the effect is supposed to be undone with some effects.

For Mel:

When you read this please could you simplify this script a little? That would be really great...I tend to do most things a little too complicated  :D

Thanks a lot!

A happy new year to everyone!!!
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Tea-cup

  • Hero Member
  • *****
  • Posts: 916
    • View Profile
stunning script
« Reply #1 on: December 31, 2004, 02:26:48 PM »
Quote
This is our script that declares the functions of our stunner.
But there is a problem I am not able to find...I'm sure the problem is pretty simple but still I can't see it  :angry2:
The script is divided into two parts


As it is right now it only stuns the target  <_<
This is how it is supposed to work:

The first time you activate the stunner on a player the player will be stunned and can't do anything...most of us know this effect I suppose  :D
Then when you activate the item a second time on the stunned player the effect is supposed to be undone with some effects.

For Mel:

When you read this please could you simplify this script a little? That would be really great...I tend to do most things a little too complicated  :D

Thanks a lot!

A happy new year to everyone!!!
[snapback]14436[/snapback]
Made a fix where you did get oSpieler and not oTarget (that's why it doesn't unstuns), and added a few checks. to be sure the target is pc and not yourself.

And gived the code a facelift :P

NOTE: the tag checked for is ante_stunner, you might want to change that again. I used that tag to check it.

Code: [Select]
void main()
{
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
object oPC = GetItemActivator();
int iStunner = GetLocalInt(oTarget, "Stunned"); //this was oSpieler, wrong I think
int iChanged02 = GetLocalInt(oTarget, "AppChanged");
effect eEffect = GetFirstEffect(oTarget);
//stunvisual, impact (eVisual2)
effect eVisual1 = EffectVisualEffect(VFX_IMP_LIGHTNING_S);
effect eVisual2 = EffectLinkEffects(EffectVisualEffect(VFX_IMP_LIGHTNING_M),eVisual1);
//stunvisual, permanent (eHold5)
effect eVisual3 = EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION);
effect eVisual4 = EffectLinkEffects(EffectVisualEffect(VFX_DUR_ICESKIN),eVisual3);
effect eVisual5 = EffectLinkEffects(EffectVisualEffect(VFX_DUR_PARALYZE_HOLD),eVisual4);
effect eHold = EffectLinkEffects(EffectStunned(),eVisual5);
effect eHold2 = EffectLinkEffects(EffectParalyze(),eHold);
effect eHold3 = EffectLinkEffects(EffectDominated(),eHold2);
effect eHold4 = EffectLinkEffects(EffectPetrify(),eHold3);
effect eHold5 = EffectLinkEffects(EffectFrightened(),eHold4);
//unstunvisual, impact(eVisual7)
effect eVisual6 = EffectVisualEffect(VFX_IMP_HEALING_L);
effect eVisual7 = EffectVisualEffect(VFX_IMP_HEAD_HEAL);
//check for cases the stuner may not work
if(GetTag(oItem) != "ante_stunner")return;    //check itemtag
if(iChanged02 == 1)return;                      //check localint "AppChanged"
if(GetIsDM(oTarget) == TRUE)return;             //check if target is DM
if(GetIsPC(oTarget) == FALSE)return;            //check if targer is PC
if(oTarget == oPC)return;                       //check if the player targets himself
//stun/unstun depending in the iStunner variable ("Stunner" localint)
if (iStunner != 1)
{
    //add stuneffects (adding plot as last, as blocks some effects)
    AssignCommand(oTarget,ClearAllActions());
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual2, oTarget);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHold5, oTarget);
    SetCommandable(FALSE, oTarget);
    SetLocalInt(oTarget, "DM_Hold_Flag", 1);
    SetLocalInt(oTarget, "DM_No_Magic", 1);
    SetLocalInt(oTarget, "Stunned", 1);
    SetCutsceneMode(oTarget, TRUE);
    DelayCommand(0.2, SetPlotFlag(oTarget,TRUE));
}
else
{
    //remove stun effects (removeing plot as first , as it blocks some effects)
    SetPlotFlag(oTarget,FALSE);
    SetCutsceneMode(oTarget, FALSE);
    SetLocalInt(oTarget, "Stunned", 0);
    SetLocalInt(oTarget, "DM_No_Magic", 0);
    SetLocalInt(oTarget, "DM_Hold_Flag", 0);
    SetCommandable(TRUE, oTarget);
    while (GetIsEffectValid(eEffect))
    {
        RemoveEffect(oTarget, eEffect);
        eEffect = GetNextEffect(oTarget);
    }
    //do a healing visual
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual7, oTarget);
    AssignCommand(oTarget, ClearAllActions());
}
}

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
stunning script
« Reply #2 on: December 31, 2004, 03:32:53 PM »
Mel that's just great! ... as usual  :D  Thank you!!!  :D

 :D
« Last Edit: January 01, 2005, 06:40:41 AM by Daniel1975 »
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
stunning script
« Reply #3 on: January 01, 2005, 11:01:57 AM »
:excl:
« Last Edit: January 01, 2005, 11:09:39 AM by Daniel1975 »
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Tea-cup

  • Hero Member
  • *****
  • Posts: 916
    • View Profile
stunning script
« Reply #4 on: January 01, 2005, 12:16:59 PM »
Quote
:excl:
[snapback]14520[/snapback]
?? was there something wrong or so? :P

-Mel

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
stunning script
« Reply #5 on: January 01, 2005, 07:01:53 PM »
Quote
Quote
:excl:
[snapback]14520[/snapback]
?? was there something wrong or so? :P

-Mel
[snapback]14534[/snapback]

I wanted to signal the player why the item won't work in some cases that you are checking for so I modified the script a little but at first smt went wrong and I thought you made a mistake but then I noticed I forgot to add a "return;"
now it works pretty fine and the player is told the reason why the item won't work in several cases  :)
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Tea-cup

  • Hero Member
  • *****
  • Posts: 916
    • View Profile
stunning script
« Reply #6 on: January 01, 2005, 07:49:27 PM »
Quote
Quote
Quote
:excl:
[snapback]14520[/snapback]
?? was there something wrong or so? :P

-Mel
[snapback]14534[/snapback]

I wanted to signal the player why the item won't work in some cases that you are checking for so I modified the script a little but at first smt went wrong and I thought you made a mistake but then I noticed I forgot to add a "return;"
now it works pretty fine and the player is told the reason why the item won't work in several cases  :)
[snapback]14569[/snapback]
k
Anyway, I'm going to be offline a lot. + this is what I think of nwn atm ->
And got some other work to do.

Have fun.  B)

Mel.