NPCS TRACKING THE PLAYER WITH AN AI SCHEDULE
- Wrote by Bioko the 07 November 2010
- Edited for the last time the 19 November 2010
- 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
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 !
SOURCE : Biokoxomodding.tk