Aller au contenu

Photo

Head scratcher with ActionForceFollowObject


  • Veuillez vous connecter pour répondre
18 réponses à ce sujet

#1
Indigo

Indigo
  • Members
  • 22 messages

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

          }
     }
}

 



#2
Proleric

Proleric
  • Members
  • 2 354 messages
When I want control of a player, I clear actions, assgn the commands, then SetCommandable FALSE.

#3
Indigo

Indigo
  • Members
  • 22 messages

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? :o



#4
Indigo

Indigo
  • Members
  • 22 messages

Okay. That part works, but now they're not going through area transitions. Odd. :o

 

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



#5
meaglyn

meaglyn
  • Members
  • 811 messages

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.



#6
Indigo

Indigo
  • Members
  • 22 messages

So more local variables? :P

 

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



#7
meaglyn

meaglyn
  • Members
  • 811 messages

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...



#8
Indigo

Indigo
  • Members
  • 22 messages

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. :o

 

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! :o 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;
    }
}


#9
WhiZard

WhiZard
  • Members
  • 1 204 messages

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



#10
Indigo

Indigo
  • Members
  • 22 messages

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? :o 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. =/



#11
MrZork

MrZork
  • Members
  • 940 messages

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?



#12
Indigo

Indigo
  • Members
  • 22 messages

That'd be viable, though I wouldn't know how to do that. :o 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.



#13
Indigo

Indigo
  • Members
  • 22 messages

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. :D

 

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



#14
Indigo

Indigo
  • Members
  • 22 messages

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? :o 



#15
Indigo

Indigo
  • Members
  • 22 messages

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!



#16
MrZork

MrZork
  • Members
  • 940 messages

Sorry, I haven't been able to look at this over the weekend (and I probably won't again for several more days). But, what I meant was to use the JumpToLocation() command in the heartbeat. That is, something like the following pseudocode

 

    If the guard and the arrestee are still defined and that the arrestee is still arrested:

        Get the locations of the guard and the arrestee and their areas.

        If the areas of the guard and the arrestee are not the same and that the arrestee's area is valid (he's not transitioning):

            Make the arrestee commandable

            Clear the arrestee's actions

            Call AssignCommand(oCriminalScum, JumpToLocation(locGuard))

            Put the arrestee back into follow mode. (Possibly, this should be done with DelayCommand to allow the area transition.)

            Make the arrestee uncommandable.



#17
Indigo

Indigo
  • Members
  • 22 messages

Sorry I haven't been able to get back to you on this. Had another problem that I had to deal with, but it's been smited. xD

 

That's how I was trying to do it, but it wouldn't carry over through to the next area (ie, they'd make it through the transition, but the effects wouldn't carry over at all). Other portions didn't want to compile. So I'm pretty sure it's my scripts that are botched (the ones I posted, as well as the others I had tossed). I can try it again using your method, but I don't have much time as of late I'm afraid, since the server's already launched and I've moved onto outdated scripts that needs a bit of revamping (spells, scrying, resting, certain subraces, etc). 



#18
Shadooow

Shadooow
  • Members
  • 4 470 messages

I wasnt watching this thread much but to solve your problem, dont make your animal an associate, keep him neutral so its not in PC party then script his movement/AI from scratch.



#19
Indigo

Indigo
  • Members
  • 22 messages

I wasnt watching this thread much but to solve your problem, dont make your animal an associate, keep him neutral so its not in PC party then script his movement/AI from scratch.

 

Both characters are PCs. I dun think I can script PC AI. :P Unless I'm misunderstanding, of course. :o