Aller au contenu

Photo

Just go away and die


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

#1
Jereniva

Jereniva
  • Members
  • 114 messages

I had another thread about doing a force jump across areas.

I've given up on that, it's wasting too much time.

 

I'm trying to get this NPC, at the conclusion of a conversation, to start walking towards a waypoint and after about 5 seconds just disappear, die, explode, whatever, I could care less, just leave my game!

 

I cannot get this to work .

 

I even made a simple ActionMoveToObject, set it to a waypoint and surrounded the waypoint with a trigger that did a clear all actions, and a destroy object. Even this wouldn't work, NPC arrived in the trigger, actions were cleared... and NPC just stood there.

 

Finally, I have just tried DestroyObject at end of the conversation, but even this doesn't do anything.

 

I checked and NPC is not marked Plot or Immortal.

 

Even a nearly 20 year old game like Baldur's Gate could manage an NPC walking away after a conversation, unable to be distracted from the death march, and disappear after a few seconds. :)

 

What am I doing incorrectly?



#2
Tchos

Tchos
  • Members
  • 5 030 messages

Well, I wish you weren't having such a hard time with jumping NPCs across areas.  It's visible in action in my campaign if you attack any random citizen in town (without killing them).  They run to a waypoint, jump to a hidden place in another area, and return after a couple of minutes.

 

To make them walk toward a waypoint and be destroyed after a certain number of seconds whether or not they reach the waypoint, I use ga_force_exit.



#3
Dann-J

Dann-J
  • Members
  • 3 161 messages

If the NPC proves to be a veritable Molly Brown, you could always use a delayed SetScripHidden() function. The NPC will still technically be there, but only you and your hairdresser will know for sure.



#4
kevL

kevL
  • Members
  • 4 052 messages
i wrote this some time ago. Since it's difficult to decipher what 'ga_force_exit' does, as it weaves its way through about 5 subfunctions and 2 include files, this distills it:
 
// 'ga_force_exit_plot'
//
// Sends creature to an exit.
// - patched together from 'ga_force_exit'
// 2013 apr 11, kevL
// 2015 sep 20, tweakz
//
// sTarget:     tag of creature (in current area) to exit (default OBJECT_SELF).
// sExit:       tag of exit object (default "WP_EXIT").
// bRun:        to run or not (default FALSE).
// bPlot:       set as Plot, ie. get out alive for sure (default FALSE).
// fRange:      meters away from destination to be considered at destination;
//              large creatures require more (default 3.0).
// fTimeout:    seconds to keep trying to get to destination before
//              automatically vaporizing (default 60.0).
//
// note, The defaults ought work fine, just put in a tag to walk to.


// helper for despawning roster members
void Despawn(object oTarget);

//__________
//** MAIN **
void main(string sTarget, string sExit, int bRun, int bPlot, float fRange, float fTimeout)
{
    object oTarget;
    if (sTarget == "")
        oTarget = OBJECT_SELF;
    else
        oTarget = GetNearestObjectByTag(sTarget);

    if (GetIsObjectValid(oTarget))
    {
        AssignCommand(oTarget, SetCommandable(TRUE));
        AssignCommand(oTarget, ClearAllActions(TRUE));

        if (sExit == "") sExit = "WP_EXIT";

        object oExit = GetNearestObjectByTag(sExit);
        if (GetIsObjectValid(oExit))
        {
            if (fRange == 0.f) fRange = 3.f;
            if (fTimeout == 0.f) fTimeout = 60.f;

            AssignCommand(oTarget, ActionForceMoveToObject(oExit, bRun, fRange, fTimeout));
        }

        if (GetIsRosterMember(oTarget))
        {
            int bPlot_pre = GetPlotFlag(oTarget);
            AssignCommand(oTarget, ActionDoCommand(SetPlotFlag(oTarget, bPlot_pre)));
            AssignCommand(oTarget, ActionDoCommand(SetCommandable(TRUE)));
            AssignCommand(oTarget, ActionDoCommand(Despawn(oTarget)));
        }
        else
        {
            AssignCommand(oTarget, SetIsDestroyable(TRUE));
            AssignCommand(oTarget, ActionDoCommand(SetPlotFlag(oTarget, FALSE)));
            AssignCommand(oTarget, ActionDoCommand(DestroyObject(oTarget)));
        }

        if (bPlot) SetPlotFlag(oTarget, TRUE);
        AssignCommand(oTarget, SetCommandable(FALSE));
    }
}

// helper for despawning roster members
void Despawn(object oTarget)
{
    DespawnRosterMember(GetRosterNameFromObject(oTarget));
}
It adds a fair bit of tweakability, though the defaults ought work fine (just put in a tag to walk to)
 

What am I doing incorrectly?


? AssignCommand(), used when 'target' is not OBJECT_SELF, and the function doesn't take a target. (Or as above when assigning actions in sequence)

#5
rjshae

rjshae
  • Members
  • 4 478 messages

ga_force_exit works fine for me.



#6
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages

if you could post the script, that would let us debug it.  It's probably some trivial object reference issue, that the script isn't telling the right creature to go die at the right time.

 

It helps to write a void function to handle the walking and disappearing, and then using DelayCommand to call that function.  You can also use ExecuteScript to force the creature to do something later.  Just adding things to the action queue doesn't usually work, because the AI messes with the action queue all the time.  DestroyObject doesn't work well when called from the object being destroyed, and creatures in an active conversation won't even go script hidden until the conversation is over.  You might need to have an i-point object run the conversation, with the NPC's tags pasted into the conversation by hand. 



#7
Tchos

Tchos
  • Members
  • 5 030 messages

i wrote this some time ago. Since it's difficult to decipher what 'ga_force_exit' does, as it weaves its way through about 5 subfunctions and 2 include files, this distills it:

 

I deciphered and unraveled ga_force_exit some time ago as well, and it was the basis of the script I think I posted somewhere else which sends the NPC to another area instead of destroying it.



#8
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages

In my Silverwand Sample Campaign I have an NPC (Randall I think) who will have a conversation with you and then if you decide not to let him join your party he walks off and disappears.  You can look there how I did it.  If you have the ga_force_exit on the end node, try moving it so that the end node follows it.  Sometimes I've found that when an end node has an action script it does not always work properly.

 

Also, if you created the NPC from scratch rather than copying an existing blueprint then that might of created this problem.  I always copy and modify rather than creating from scratch. Try creating a new NPC from an existing blueprint and testing ga_force_exit with him. That may tell you if the problem is the NPC object or the conversation or script.

 

Hope this helps.

 

Regards



#9
Tchos

Tchos
  • Members
  • 5 030 messages

To go with Kaldor's suggestion about creating NPCs, you might consider making some base blueprints of male and female members of each race without the default armour and equipped weapon that the existing blueprints have (plus they don't have any females), with any default settings you usually use (such as faction, level, class, default conversation, etc.) and copying those when you make your new NPCs.  I've found it useful.



#10
Dann-J

Dann-J
  • Members
  • 3 161 messages

I tend to design my NPC appearances in a test module, and once I'm happy with them I export them as an ERF and import that into the 'real' module. That way any wackiness the NPC might have inherited from the object it was modified from gets stripped away, and the blueprint comes in nice and clean.

 

I've found that many mysterious scripting problems that have no identifiable reason to occur have been caused by objects stubbornly inheriting things from the object you copied and modified to make them. Deleting the problem object and recreating it cleanly often solves the problem.


  • GCoyote aime ceci

#11
Jereniva

Jereniva
  • Members
  • 114 messages

A million thank you's. Not only are you all so knowledgeable, but you're all willing to share it and so quickly! 

I can't thank you all enough

 

So...

I went in and deleted the NPC.

Then I remade her by doing Create Blueprint -> Module. (Kaldor, I had not read your post yet).

Gave a totally different tag just in case something, somewhere was hosing this up based on that.

Then I put the ga_force_exit on the Player choice that ends the dialog.

This worked.

 

Now, back to look at my original script, but...

I stupidly overwrote the script that was not working, else I'd put it here.

but I had the "guts" of it copied to notepad, minus the declarations, and it was basically this:

After a few seconds, the NPC would stop walking, so I assumed the ClearAllActions was working. 

But the Destroy didn't do anything. oTarget was fine, I triple, quadruple, quintuple checked the GetObjectByTag

 

   ActionForceMoveToObject(oWayPoint);
    DelayCommand((4.5, ClearAllActions());
    DelayCommand(5.0, DestroyObject(oTarget));



#12
kevL

kevL
  • Members
  • 4 052 messages
note Clear actions should come before ForcedMove.

- actions don't need to be cleared before Destroy, they should be cleared before the initial Action. To make room for it as it were.

#13
rjshae

rjshae
  • Members
  • 4 478 messages

    ActionForceMoveToObject(oWayPoint);
    DelayCommand((4.5, ClearAllActions());
    DelayCommand(5.0, DestroyObject(oTarget));

 

As you aren't assigning ActionForceMoveToObject or ClearAllActions to a target, it's being executing by the owner of the script. Is that the same as oTarget?



#14
Dann-J

Dann-J
  • Members
  • 3 161 messages

Note that the DestroyObject() function has it's own built-in delay option. It may be that the function doesn't work well wrapped in a DelayCommand() function, so they built one into it directly. As a function that returns a void it *should* have no problems running from within DelayCommand(), but that doesn't mean that it *doesn't*.



#15
Dann-J

Dann-J
  • Members
  • 3 161 messages

As you aren't assigning ActionForceMoveToObject or ClearAllActions to a target, it's being executing by the owner of the script. Is that the same as oTarget?

 

If it's a GA_ script run from within a conversation action node, then the conversation owner should be the implied OBJECT_SELF (ie. the script owner). As long as the conversation is attached to the NPC directly then it shouldn't matter. If the conversation is being started by means other than clicking on the NPC, then things might be problematic.