Author Topic: Head scratcher with ActionForceFollowObject  (Read 469 times)

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« on: January 13, 2015, 05:56:09 pm »


               

So I ran into another problem with a widget. This time what I'm trying to do is make "chain" tool for player guards to "arrest" someone in the server. It's supposed to make the player who's being arrested follow them where ever they wanted, but I've ran into two problems.


 


Edit: Found the EffectBeam entry in the Lexicon. The beam effect is fixed now.


 


 


Just thought I'd warn ya.


 


The other thing that seems to be messing up is that the player who's being arrested can still move around, which cancels the command. My brain's still pretty foggy on how to stop this as well as making the arrested player follow the guard player around. I know it's been done before, but I'm drawing blanks here. When I use the widget again, it changes the local variables just fine like a toggle should.. I just can't seem to get it where the player can't cancel out the forced walk. Preferably where the player that's arrested can still talk. I know how to disable the hud.. But giving players a chance to plead their case on their way to the slammer would be epic.


 


 


Ran into an additional problem; the player of the widget can have an unlimited amount of people following them. x.x I'm gonna try another local variable to stop that and see if that works.


 


 


And an optional: If someone could show me how to make it where the player being arrested has to roll a reflex save better than 40 or be arrested, that'd be extra awesome! But it's not required. I was never good at applying checks like that to my scripts (kind of like what's happening to my visual effects right now, they just won't show up). =/


 


 


Anyways! I'm sorry for going on and on. This is the script I'm working with now. I tried to comment what does what (or at least what I'm wanting it to do) within the script.


 


And as always any and all help is greatly appreciated!


 


Another edit: Updated the script to mark my fixes, but I also removed SetCommands as I don't think they work for PC's. But PLEASE correct me if I'm wrong! Cause, I love learning. :D



#include "nw_i0_spells"

void main()
{
    effect eVFX;
    object oUser = GetItemActivated();
    object oCriminalScum = GetItemActivatedTarget();
    location lActTarget = GetItemActivatedTargetLocation();
    object oActivator = GetItemActivator();

    if (GetIsObjectValid(oCriminalScum))
     {
        if (GetLocalInt(oCriminalScum, "Arrested"))
          {      //Remove Local
            DeleteLocalInt(oCriminalScum, "Arrested");
                 //Remove Beam Chain visuals
            effect eVFX = EffectVisualEffect(VFX_BEAM_CHAIN);
            RemoveSpecificEffect(EFFECT_TYPE_VISUALEFFECT, oCriminalScum);

                 // Clear all actions and allow them to move again.
            AssignCommand(oCriminalScum, ClearAllActions());

          }
        else
          {      //Set Local
            SetLocalInt(oCriminalScum, "Arrested", TRUE);
                 //Use Beam Chain visual effects
            object oSource = GetItemActivatedTarget();
            object oTarget = GetItemActivator();
            effect eBeam = EffectBeam(VFX_BEAM_CHAIN, oSource, BODY_NODE_CHEST);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBeam, oTarget);
                 //Set the player to follow and not break from Force Follow.
      AssignCommand(oCriminalScum, ActionForceFollowObject(oActivator, 0.8));

          }
     }
}


 



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #1 on: January 13, 2015, 09:50:03 pm »


               When I want control of a player, I clear actions, assgn the commands, then SetCommandable FALSE.
               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #2 on: January 13, 2015, 10:26:11 pm »


               

Hmm.. I'll try that again and see if it works. I was able to still move with those. I was thinking about using the Domination effect, but apparently if you have Immunity to Mind Spells it doesn't work. Is there a specific way to setup SetCommandable? And does it work from oPC to oPC? '<img'>



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #3 on: January 13, 2015, 10:44:45 pm »


               

Okay. That part works, but now they're not going through area transitions. Odd. '<img'>


 


Edit: Here's the script thus far;



#include "nw_i0_spells"

void main()
{

    object oUser = GetItemActivated();
    object oCriminalScum = GetItemActivatedTarget();
    location lActTarget = GetItemActivatedTargetLocation();
    object oActivator = GetItemActivator();



        if ( GetLocalInt(oActivator, "ONEPERSON") == 1 )
            {
                //Remove Local
                DeleteLocalInt(oActivator, "ONEPERSON");
                DeleteLocalInt(oActivator, "Arrest");
                   //Remove Beam Chain visuals
                RemoveSpecificEffect(EFFECT_TYPE_BEAM, oCriminalScum);
                RemoveSpecificEffect(EFFECT_TYPE_BEAM, oActivator);
                   // Clear all actions and allow them to move again.
                AssignCommand(oCriminalScum, ClearAllActions());
                AssignCommand(oCriminalScum, SetCommandable(TRUE));
            }

        else
          {      //Set Local
            SetLocalInt(oActivator, "ONEPERSON", 1);
            SetLocalInt(oActivator, "Arrest", 1);
                 //String to player on how many people can be arrested at once (one)
            FloatingTextStringOnCreature("You can only arrest one person!", oActivator);
                 //Use Beam Chain visual effects
            object oSource = GetItemActivatedTarget();
            object oTarget = GetItemActivator();
            effect eBeam = EffectBeam(VFX_BEAM_CHAIN, oSource, BODY_NODE_CHEST);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBeam, oTarget);
                 //Set the player to follow and not break from Force Follow.
            AssignCommand(oCriminalScum, ClearAllActions());
            AssignCommand(oCriminalScum, SetCommandable(FALSE));
            AssignCommand(oCriminalScum, ActionForceFollowObject(oActivator, 0.8));
          }
        }


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #4 on: January 14, 2015, 12:11:42 am »


               

Yeah, area transitions require commandability.  You'll need to script around that. I've done that in the past with a trigger a bit larger thatn the transition with an on enter script that checks if the PC is in the right state (in this case a prisoner) and if so jumps to the right place.



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #5 on: January 14, 2015, 12:17:18 am »


               

So more local variables? '<img'>


 


Edit; Also, is there a template for something like that? The jumping part I mean. '<img'> Also, just to be sure, generic triggers yeah?



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #6 on: January 14, 2015, 01:55:54 am »


               

Yes, you probably want a variable on the criminal scum saying he or she is a prisoner. But there are probably a number of ways to do it. I don't remember exactly what I did to make that work. I believe it was basically : set commandable to true, clear actions, jump to location of transition and


then put the follow command back on and set commandable back to false on the other side. You may want to track the capturer object on the prisoner to make setting that back up easier.    If you need to be able to do this anywhere in your module it will get pretty messy/tedious though...



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #7 on: January 14, 2015, 03:51:45 am »


               

So something like this? I'm mixing some things from the Script Generator since I never got into bypassing game mechanics. xD


 


Edit; I don't think the GetObjectByTag will work on the item though. Reading the Lexicon about how if the item's in an inventory they won't be found. Gonna try waypoints instead unless someone knows a better way or has a template. '<img'>


 


Edit 2; I can get them through areas pretty snappy, but I can't seem to get the widget's effect to reapply. I'm tinkering though! '<img'> If I fix it, I'll definitely post back.


 


Edit 3: Still can't seem to get the effect to reapply after adding scripts OnEnter of areas. Even OnExit. Since it's a unique power used on a player by a player, I'd say that there's probably more to it than I'm thinking. If I try to apply the effects through the OnEnter of the area, I cycle in and out of the areas somehow (probably waypoints). I wonder what's up with that.. =/



void main()
{
    object oTarget;

    //Trigger conditions
    object oPC = GetEnteringObject();

    // Local variable
    if ( GetLocalInt(oPC, "Arrest") == 1 )
    {
       //List of commands
        AssignCommand(oPC, SetCommandable(TRUE));
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, ActionJumpToObject(GetObjectByTag("guardchain")));
        //Small delay to revert Commandables back to False
        DelayCommand(0.2, AssignCommand(oPC, SetCommandable(FALSE)));
        return;
    }
}


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #8 on: January 14, 2015, 04:24:03 pm »


               

If you are using enduring beams, it is best to make them extraordinary or supernatural effects to avoid dispelling issues.



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #9 on: January 14, 2015, 05:32:09 pm »


               


If you are using enduring beams, it is best to make them extraordinary or supernatural effects to avoid dispelling issues.




 


 


Waaaaait... I can do that? '<img'> Could the same be applied for the forcewalk through transitions?


 


I still haven't gotten that to work. They'll follow through to the other side, but I don't think I'm getting the item user correctly. I'm not sure how to go about that. I also found out that you can use EffectCutsceneDominate to stop the player from controlling their character, but then I run into the same problem. Reapplying the effects when they enter the area on the other side. =/



               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #10 on: January 14, 2015, 07:23:17 pm »


               

Adding extra triggers around each area transition (and door object) in the module may be a pretty big task, unless there are only a few you expect the guards to lead the arrestee through. I wonder if it might also be viable to add a pseudo-heartbeat to the arrestee so that he checks whether the guard is still in the same area every round or two and, if not, jumps him to the guard's position?



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #11 on: January 14, 2015, 07:36:53 pm »


               

That'd be viable, though I wouldn't know how to do that. '<img'> I was thinking something similar that I could just script on the item's script itself, to check and see if they're both still in the same area, if not, then the arresstee jumps to the guard's location. Your idea sounds better though. Would you mind showing me how to set something like that up (like a script template since this is definitely out of my comfort zone, but I'm definitely picking things up)? Cause I'm thinking it might be better to have the arrested PC jump to the guard PC anyways, just in case the arrestee gets stuck somewhere, somehow within the forcedfollow.



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #12 on: January 15, 2015, 02:23:56 am »


               

Update: I got them to follow through with an OnHeartbeat script and an include script with a jump function. However it I get a repeated cycle of toggling the widget. I can't figure out what I'm wrong. I also can't get the chains to stay after the area jump. Anyone have any suggestions? Here's the scripts.


 


In the meantime, I think I'm gonna try and put them in the OnEnter area properties to see what that gives me. But I'm getting closer, I can feel it. '<img'>


 


Edit: LOL. So... I put them OnEnter of the area, nothing. I put them OnEnter of a trigger? NWServer crashed on me. So I'm pretty sure it's my borked/butchered script that's definitely borked. They haven't changed in terms of the actual scripting, just where I put them.


 


Edit 2: I got the player to go across one transition and hold all of the effects. However when trying to go back the way I was leading them, they got stuck behind the second transition. This, I really think has to do with the OnHeartbeat script. I've cleaned the other two to the best of my ability, though I'm wondering why it's not refiring. Waited 2 minutes and the other player didn't pop through the transition. I threw them on triggers to see if I got that crash after I cleaned them thoroughly, and so far no crashes. It's aaaaaaall most there, I can feel it in my bones! Also, there's a few functions and commands that are commented out, that's mostly me doing the whole "Nope. It's not this." trial and error spiel. 


 


OnHeartbeat:



#include "inc_guardchain"


void checkareas(object oActivator, object oCriminalScum = OBJECT_SELF)
{
  object oGuardArea = GetArea(oActivator);
  object oCriminalArea = GetArea(oCriminalScum);

  if ( GetLocalInt (oCriminalScum, "IsArrested") == 1)
    {
      if (oCriminalArea != oGuardArea)
        {//Incorrect areas, so jump
        AssignCommand(oCriminalScum, GuardCommand_Follow(oActivator, TRUE));
        }
     }


Item Activate script




#include "nw_i0_spells"
#include "inc_guardchain"

void main()
{

    object oUser = GetItemActivated();
    object oCriminalScum = GetItemActivatedTarget();
    location lActTarget = GetItemActivatedTargetLocation();
    object oActivator = GetItemActivator();



       if ( GetLocalInt(oActivator, "ONEPERSON") == 1 )
         {
            //Reset Local Variables (Though they kind of don't seem to?)
            DeleteLocalInt(oActivator, "ONEPERSON");
            SetLocalInt(oCriminalScum, "IsArrested", 0);
            //Assign Commands
            RemoveSpecificEffect(EFFECT_TYPE_BEAM, oCriminalScum);
            RemoveSpecificEffect(EFFECT_TYPE_DOMINATED, oCriminalScum);
            AssignCommand(oCriminalScum, ClearAllActions());
            AssignCommand(oCriminalScum, SetCommandable(TRUE));
            //Send float to guard
            FloatingTextStringOnCreature("You unbind your prisoner.", oActivator);
            //Remove any beams on guard.
            RemoveSpecificEffect(EFFECT_TYPE_BEAM, oActivator);
         }
       else
         {  //***Set Local Variables to 1.
            SetLocalInt(oActivator, "ONEPERSON", 1);
            SetLocalInt(oCriminalScum, "IsArrested", 1);
            //String to player on how many people can be arrested at once (one)
            FloatingTextStringOnCreature("You have a person arrested!", oActivator);
            AssignCommand(oCriminalScum, GuardCommand_Follow(oActivator, TRUE));

         }
}


 


 



 

And the include script that I'm using to link commands from:



#include "nw_i0_spells"



void GuardCommand_Follow(object oActivator, int bJump = FALSE)
{ // Follow oTarget
    if(bJump)
    ClearAllActions();
    // Queue: Jump to Target
    JumpToObject(oActivator);
    // Set Commands to false
    //SetCommandable(FALSE);
    // Queue: Follow oTarget
    object oSource = GetItemActivatedTarget();
    object oTarget = GetItemActivator();
    effect eBeam = EffectBeam(VFX_BEAM_CHAIN, oSource, BODY_NODE_CHEST);
    effect eDom = SupernaturalEffect( EffectCutsceneDominated());
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBeam, oTarget);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDom, oSource);
    //Set the player to follow and not break from Force Follow.
    DelayCommand(2.0, ActionForceFollowObject(oActivator, 0.8));
}


               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #13 on: January 15, 2015, 10:02:09 pm »


               

Update: Still doing the same things. I found DoA's psuedo-heartbeat scripts and tried that and it's not working either. So either something's wrong with my original scripts, or I'm going about this all wrong. Can someone pretty please correct my scripts or show me how to do it so I can compare/make my own? '<img'> 



               
               

               
            

Legacy_Indigo

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
Head scratcher with ActionForceFollowObject
« Reply #14 on: January 16, 2015, 11:08:36 pm »


               

Another update: Tried making the jump scripts simpler and even then, the effects didn't stick after the transition from area to area. They'll go through, but only once. I can't spend too much more time on it for a while due to time issues. If any one can give me ANY information or templates (or at least tell me where my code is wrong), that'd be awesome. Thank you!