28.02.2010, 16:56
Quote:
Originally Posted by Hot
1 - How to create random spawns for NPCs? (I know how to create for players, but not for a NPC).
2 - How to make the NPC move toward a player? 3 - How to make NPCs attack players? |
Like with normal players
Example (in a filterscript)
pawn Code:
#define NPC_NAME ("MyNPC")
#define NPC_SCRIPT ("mynpc")
new MyNPC;
pawn Code:
public OnFilterScriptInit()
{
if(!MyNPC) ConnectNPC(NPC_NAME, NPC_SCRIPT);
MyNPC = INVALID_PLAYER_ID;
for(new i, name[MAX_PLAYER_NAME]; i < MAX_PLAYERS; i++)
{
if(IsPlayerNPC(i))
{
GetPlayerName(i, name, MAX_PLAYER_NAME))
if(strmp(name, NPC_NAME, false) == 0)
{
MyNPC = i;
break;
}
}
} // Gets the id of the NPC
if(MyNPC == INVALID_PLAYER_ID) SetTimer("OnFilterScriptInit", 5_000, false);
}
pawn Code:
public OnPlayerSpawn(playerid)
{
if(playerid == MyNPC)
{
switch(random(2) + 1)
{
case 1: SetPlayerPos(playerid, 1000.0, 2000.0, 3000.0);
case 2: SetPlayerPos(playerid, 3000.0, 2000.0, 1000.0);
}
}
}
NPC's only follow the record paths, if the record stops they are just standing around (kind of freezed)
You can apply animations to the NPC (in your case moving animations) but "normal walking" isnt possible
3)
Like above the NPC's are freezed after replaying the record, so they wont shot by themself
You can apply shot animations, too, and degrees the target health
There is something that Mo3 already made -> The NPC REVOLUTION - smart acting and performing bots (videos - no source code)