Jump to content

The Hankinator's extended MonsterAI script


thehankinator
 Share

Recommended Posts

http://steamcommunity.com/sharedfiles/filedetails/?id=638782739

 

This is a modified version of MonsterAI.lua that adds a

* FOV check when searching for the player (in degrees)

* A simple system for controlling where and how your monster patrols the level.

 

The script should work like the stock script if you do not set the Path property. This script does not handle walking animation because the Crawler doesn't have a walk animation out of box. Feedback welcome, I can think of a couple things that could be added to make this better but I am going to see what people think first.

 

Make monster move to pivots around the map

1) Add a master pivot, give it a name like "CrawlerPath1" without quotes and put it off to the side out of the way

2) Add a pivot to your map that is in the position that you want to be your first point the monster will visit, name it "1" without quotes.

3) Make the pivot a child of "CrawlerPath1"

4) Repeat steps 2 and 3 however many times you want to but increment the number you use for the pivot name.

 

In my map I placed 5 pivots, it looks like this:

2nf7wJx.jpg

 

My CrawlerPath1 looks like this(note how order does not matter, the name defines the order):

Y2HESys.jpg

 

 

5) Attach TH_MonsterAI.lua to your monster

6) Drag your CrawlerPath1 to the "Path" script property

ePu1x4p.jpg

7) Next you can set the behavior of the monster when it reaches the end of your path.

Loop: At the end, the monster will go back to the first pivot, in map image I made above the monster would go to 1, 2, 3, 4, 5, then back to 1, forever.

Reverse: At the end, the monster will go backward through the path in my example, the monster would go to 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, etc, forever. This one is nice if you want the monster patrolling a path.

Stop: The monster would stop at the last point. 1, 2, 3, 4, 5.

 

Actions at pivots

That will make the monster move, but you can also add actions at each point. For each nav point you can attach the script TH_NavPointAction.lua. This will let you make the monster do actions at a pivot before moving on. The properties of this script are:

Animation: This is a name of an animation you want the monster to do

Action: "Delay" will make the monster do the animation set by the Animation property for any amount of time. "Do Animation X times" will have the monster do the animation set by the Animation property X times before moving on.

ActionArg: When Action is set to "Delay", this is the amount of time to wait in milliseconds. When Action is set to "Do Animation X times" this is the number of times you want the monster to do the animation.

AnimationSpeed: This is the speed which the animation is executed.

 

Pivots now can have two functions:

function Script:Arrive(entity)
--do something when the monster arrives at this pivot
end

function Script:Depart(entity)
--do something when the monster leaves this pivot
end

Edited by thehankinator
  • Thanks 1
  • Upvote 6
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...