Jump to content

Make NPC use a lever.


Recommended Posts

I have a NPC that has a package UseSpecialFurniture. The furniture is a lever, same as the ones found at sawmills. It has a condition of a global being set to 1. He won't do it. I checked the global in game 'getglobalvalue xxxxxx' and it is 1. The same script that sets the global to 1 runs an EvaluatePackage immedietely after setting the global. It is the only package the NPC has. I changed the package to activate, still NPC does nothing. Navmesh covers the lever area, nothing blocking the way, navmesh does go over a retrasctable bridge but the bridge is down so NPC can cross it.

The complete scenario goes like this-

Player enters area.

NPC is enabled when player isn't looking and begins shooting player with bow.

Player cannot get to NPC to attack him.

Player operates a lever which drops a retractable bridge. This lever jas a MoveTo script on it which moves NPC farther down the area (player doesn't see this happen).

Player pusues the NPC, only 1 way to go.

Player sees NPC across another retractable bridge, which is up, NPC starts shooting player again.

Player operates another lever which drops a retractable bridge so he can get to the NPC. The operation of this lever sets the global to 1 and evaluates the NPC's only package.

NPC should now run to another lever, pull it, a bridge retracts and player cannot get to NPC. This ISN'T happening.

Finally, not done this part yet as can't get previous part to work, NPC flees the area.

Help please.

Link to comment
Share on other sites

Since you are using an AI package to do this, have you ensured that the lever is within the packages operational radius?

 

You may need to set an xMarker near the lever and use the AI package to make them travel to the xMarker and then in the package end script fragment have the NPC activate the lever.

 

Also, it may help others to help you if you post a screenshot of the AI package you are trying to use. I haven't worked with them much so I do not know all of what may be possible.

Link to comment
Share on other sites

IsharaMeradin suggestion is one way to go.
Or
Did not test it, but is a simple script.
Place it in a trigger box and place an xMarker near - front of the " Lever ", the path needs to have no obstacles, otherwise the sequence will be interrupted.


Actor Property ActorREF Auto
{Actor REF to assign}
 
ObjectReference Property MoveToTargetREF auto
{The xMarker - where the ACTOR will be walking or running to}
 
ObjectReference Property MyLever01 auto
{Link REF the Lever - Activator}
 
 
EVENT onTriggerEnter(objectReference actronaut)
           if actronaut == ActorREF
              ActorREF.PathToReference(MoveToTargetREF, 0.5)
              MyLever01.Activate(ActorREF)
              Utility.Wait(5.0)
              Self.Disable()
              Utility.Wait(0.5)
              Self.Delete()
        EndIf
EndEvent
 
 
; 0.0  to  1.0 the speed that the Actor : WALKS (0.1) - RUN (1.0)
; Utility.Wait(5.0) is set so that the scripts disable/deletion doesn't interupt with the Actor Lever's activation sequence


 

 

 

If you are using packages, then :
OnPackageEnd()
* You can also have multiple xMarkers and have the Actor move from one to the other and to the other....
Edited by maxarturo
Link to comment
Share on other sites

I forgot to add that:

The trigger box should be placed just after where the NPC Package Ends, otherwise if the npc walks into it while the package is running nothing will happen, the script won't fire.




Adding a script to the actor that will fire OnPackageEnd()

If the Package ends near the Lever is an other way to go.




Extends ACTOR


Actor Property ActorREF Auto
{Actor to REF to assign}

ObjectReference Property MoveToTargetREF auto
{The xMarker - where the ACTOR will be walking or running to}

ObjectReference Property MyLever01 auto
{Link REF the Lever - Activator}


EVENT OnPackageEnd(Package akOldPackage)
ActorREF.PathToReference(MoveToTargetREF, 0.5)
MyLever01.Activate(ActorREF)
EndEvent


Edited by maxarturo
Link to comment
Share on other sites

It was radius related. Even though there is no option to enter a radius in an Activate package. Matter of positioning NPC close enough and my God he takes his sweet time to activate, player is up his a** before he bends down. need to slow down player progress while Mr. Slow does his thing.

Link to comment
Share on other sites

Now the next issue.

NPC now activates lever which lowers the bridge for him to escape but he won't cross it. Navmesh goes over the bridge, there are no navmesh cuts. I put a collision plane under the bridge, just in case and the xmarker on the left is where he should travel to, from right to left. I first tried FleeTo package but he wouldn't cross and neither will he cross with a Travel package.

 

 

Link to comment
Share on other sites

Maybe make smaller triangles on the navmesh. Give it a bit more space around the rock. You've also got some bridge that isn't covered by the navmesh. All that combined might cause the NPC to be unable to figure a path past the rock and thus refuse to move. Just a thought, I know next to nothing about navmesh. Just know that it has to be wherever you want NPCs to roam.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...