NPCS TRACKING THE PLAYER WITH AN AI SCHEDULE
- Wrote by Bioko the 07 November 2010
- Edited for the last time the 19 November 2010
- WWW.BIOKOXOMODDING.TK
- Licensed under the Creative Commons
In this tutorial, we will see how we can make that an NPC, once he spawns, search the player via an aiscripted_schedule. This method can be useful if you want to make a "survival" map, where for instance, the zombies must search by themselves the player who is hiding in a town or a forest. What is cool here is that you don't have to create a complex path where the NPCs will patrol and spend time scripting the whole shit... No here the NPC will search the player wherever he is ! You will also learn how to use the entity called aiscripted_schedule.
I - Defining the NPC
So first, you will need to create a template NPC who will be spawned on the map and who will search the player. It can be a combine, a zombie, a vortigaunts, a rebel... It is very important that once you placed your npc, you convert it to a template NPC (take a tour to the "Flags" tab) and that you give to him a name (I will use NPC_Seeker here) ! Or else, it won't work !
II - Defining the aiscripted_shedule
Create somewhere in a map an entity called aiscripted_schedule and name it (I will name it AISchedule_Seeker). You must also enter in the field called "Target NPC" the name of your template NPC (since mine is named NPC_Seeker, I will write NPC_Seeker).
Then be sure that the rest of the fields are like those above :
- Name : AI_Schedule_Seeker
- Target NPC : NPC_Seeker
- Searh Radius (0=everywhere) : 0 (let this to zero so the NPC will search everywhere in the map to find the player)
- AIl in radius : Yes
- AI state to set : Set state to COMBAT
- Shedule to run : Run to Goal Entity (You can also make that the NPC just walk to the player or follow his path)
- Interruptability : Damage or Death (The NPC will stop search the player once he die or get damaged)
- Goat entity : !player (You can also put the name of another entity or NPC)
The last thing to do is to be sure that in the flags, the case "Repeatable" is checked and the other don't.
III - Defining the NPC spawner
Okay so now we have an aiscripted_schedule who will order the Template NPC to search the player ! But there is still something who is missing... You don't have any idea ? Well, how are we going to spawn an npc if there is no any npc_template_maker on the map ? The answer ; Create a npc_template_maker !
So now let's stop joking and finish the job we started here. Create somewhere a npc_template_maker this is where the NPC will spawn) and write the name of your Template NPC in the field "Name of the Template NPC" (I may write NPC_Seeker). You can also configure the other options who fit you the best. When you have done, go to the Output Tab and add a new output with these parameters :
- My output named : OnSpawnNPC
- Targets entitie named : AISchedule_Seeker (the name of your aiscripted_schedule)
- Via this Input : StartSchedule
- With a parameter override of : *Leave Blank*
- After a delay in seconds of : 0
Conclusion :
Once you finish that, then congratulation ! You may now have NPCs searching you in the whole map ! If you want to see what does it looks like in-game, I use this method in a map of Alien Wave called "Frozen Hell". You can download this mod at my website (section "Mods)". Anyway, I hope this tutorial would have been helpful for the community of Source mappers !
- Bioko
SOURCE : Biokoxomodding.tk
Cheers for the tutorial... but how do you make custom models? (people, guns, cars, etc.)
How else...modeling.
You can use many programs, such as 3ds Max, Blender, Maya, Softimage XSI, Houdini3d, Z-brush, and\or Mudbox.
I use 3ds Max and Mudbox.
Cheers mate, I'll have a go at that.
There are great tutorials on here that can help.
Great tutorial, it worked. :D I have a question though. I have a staircase in my map, and whenever I go up the staircase, if there are zombies on the bottom, they just either try walking straight towards me going under the staircase, or just turn around and walk away. How do I fix this?
Well, are you sure that you correctly placed the nodes ?
NPC's dislike climbing up stairs, you should place a clip that ramps up the staircase, so zombies can climb up it alot easier, it'll also work alot easier for your info_nodes. If you already have that clip, then i'm not sure what's wrong. D:
What program do you need to do this?
hey you need source sdk you can get it free with any source game you get on steam
great tut, i use it for years in my sp-maps.
one small remark though, you don't need to add a npc_template_maker. you can also just add a npc itself to the map and add his name as name to the Target NPC field.
it makes combats all the more interesting because now you are sure the enemies will attack the player, without this scripting in a lot of cases combines and other npc's just walked away in a different direction when they didn't see the player anymore.
leon
This comment is currently awaiting admin approval, join now to view.