Dynamic NPC
#1

Hello guys. First of all, I would like to apologize about my english.

I had a look at wiki page, and I have saw some NPC's Callbacks. But I don't know how to use them. I would like to create a lots of NPCS (60~100). Some questions:

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?

I would be happy if you guys could give me some answers. Thanks.
Reply
#2

http://forum.sa-mp.com/index.php?topic=119947.0

good luck
Reply
#3

But, how about setting the pos for an NPC? Instead of playerid i would use npcid?
Reply
#4

try to use [size=14pt]>Search<
Reply
#5

Oh my god, you are so rude. I did a >SEARCH< and could not find anything. Being rude will not solve my questions.
Reply
#6

This is a help forum, if you dont know how to help him, stop saying: "Click on Search" or sending URL.

If you wanna help, then help! If not, dont come here.

I m sorry Hot, i dont know how to solve your problem(yet).
Reply
#7

Okay, at leat you said it honestly. I will be waiting for some help.
Reply
#8

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?
1)
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);
        }
    }
}
2)
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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)