[Include] Simple AI Police Officer NPC using RNPC
#25

Quote:
Originally Posted by [FeK]DraKiNs
View Post
Good working Mauzen !!
I am creating a system of zombies, advise the use of RNPC !!

Kill NPC
pawn Code:
// top of gm
new tirosLevados[MAX_PLAYERS];

// onplayer update
static targetplayer,  Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
targetplayer = GetPlayerTargetPlayer(playerid);

if(targetplayer != INVALID_PLAYER_ID && Keys == KEY_FIRE || Keys == 132)
{
    if(IsPlayerNPC(targetplayer)) {
        tirosLevados[targetplayer]++;
        SetPVarInt(playerid, "timesTick", GetTickCount());
        if(tirosLevados[targetplayer] > 20) { // 20 shoots +-
            SpawnPlayer(targetplayer);
            OnPlayerDeath(targetplayer, playerid, GetPlayerWeapon(playerid));
            tirosLevados[targetplayer] = 0;
          }
    }
}


Follow
pawn Code:
CHK_RowMoviment(n, moviment) {

    if(moviment > rowNPCMove[n]) {
        return false;
    }
   
    static
        rowSTR[3][32];

    format(rowSTR[0], 32, "rowNPC%dX", moviment);
    format(rowSTR[1], 32, "rowNPC%dY", moviment);
    format(rowSTR[2], 32, "rowNPC%dZ", moviment);

    return IsPlayerInRangeOfPoint(n, 1.5, GetPVarFloat(n, rowSTR[0]),GetPVarFloat(n, rowSTR[1]),GetPVarFloat(n, rowSTR[2]));
}

EXE_RowMoviment(n) {

    if(!rowNPCMove[n] || execROWMoviment[n] > (rowNPCMove[n] - 1))  {
        return false;
    }

    if(execROWMoviment[n]) {
        if(!CHK_RowMoviment(n, execROWMoviment[n]-1)) {
            return false;
        }
    }

   
    static
        rowSTR[4][32];


    if(execROWMoviment[n] > 1) {
        for(new i = execROWMoviment[n]-1; i > -1; i--) {
            format(rowSTR[0], 32, "rowNPC%dX", i);
            format(rowSTR[1], 32, "rowNPC%dY", i);
            format(rowSTR[2], 32, "rowNPC%dZ", i);
            format(rowSTR[3], 32, "rowNPC%dS", i);

            DeletePVar(n,rowSTR[0]);
            DeletePVar(n,rowSTR[1]);
            DeletePVar(n,rowSTR[2]);
            DeletePVar(n,rowSTR[3]);
        }
    }
   
    format(rowSTR[0], 32, "rowNPC%dX", execROWMoviment[n]);
    format(rowSTR[1], 32, "rowNPC%dY", execROWMoviment[n]);
    format(rowSTR[2], 32, "rowNPC%dZ", execROWMoviment[n]);
    format(rowSTR[3], 32, "rowNPC%dS", execROWMoviment[n]);
   
    MoveRNPC(n, GetPVarFloat(n, rowSTR[0]),GetPVarFloat(n, rowSTR[1]),GetPVarFloat(n, rowSTR[2]),GetPVarFloat(n, rowSTR[3]));

    return execROWMoviment[n]++;
}

ADD_RowMoviment(n, Float:x, Float:y, Float:z, Float:s) {

    static str[32];

    format(str, 32, "rowNPC%dX", rowNPCMove[n]);
    SetPVarFloat(n, str, x);
   
    format(str, 32, "rowNPC%dY", rowNPCMove[n]);
    SetPVarFloat(n, str, y);
   
    format(str, 32, "rowNPC%dZ", rowNPCMove[n]);
    SetPVarFloat(n, str, z);
   
    format(str, 32, "rowNPC%dS", rowNPCMove[n]);
    SetPVarFloat(n, str, s);

    return rowNPCMove[n]++;
}
Now use:
pawn Code:
ADD_RowMoviment(npcid, x-0.1, y-0.1, z,0.006);
// MoveRNPC(npcid, x-0.1, y-0.1, z,0.006);
EXE_RowMoviment(npcid);
pawn Code:
new execROWMoviment[MAX_PLAYERS];
new rowNPCMove[MAX_PLAYERS];
This follows exactly where the player walks. It can also be optimized ..

- So the NPC does not fly on the wall, or walk inside them or fly into holes
I'm looking forward to your zombies npc
Reply


Messages In This Thread
Simple AI Police Officer NPC using RNPC - by Mauzen - 11.07.2012, 09:47
Re: Simple AI Police Officer NPC - by AIped - 11.07.2012, 09:50
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 11.07.2012, 14:32
Re: Simple AI Police Officer NPC using RNPC - by Lorenc_ - 11.07.2012, 16:57
Re: Simple AI Police Officer NPC using RNPC - by lordturhan - 11.07.2012, 17:04
Re: Simple AI Police Officer NPC using RNPC - by Larceny - 11.07.2012, 17:10
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 11.07.2012, 18:06
Re: Simple AI Police Officer NPC using RNPC - by Mauzen - 11.07.2012, 18:41
Re: Simple AI Police Officer NPC using RNPC - by Georgi166 - 11.07.2012, 18:59
Re: Simple AI Police Officer NPC using RNPC - by Mauzen - 11.07.2012, 19:04
Respuesta: Simple AI Police Officer NPC using RNPC - by ipsBruno - 11.07.2012, 23:00
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 12.07.2012, 11:10
Re: Simple AI Police Officer NPC using RNPC - by Lorenc_ - 12.07.2012, 12:11
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 12.07.2012, 12:39
Re: Simple AI Police Officer NPC using RNPC - by McCurdy - 13.07.2012, 03:41
Re: Simple AI Police Officer NPC using RNPC - by qq757679895 - 14.07.2012, 08:00
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 14.07.2012, 10:48
Re: Simple AI Police Officer NPC using RNPC - by qq757679895 - 14.07.2012, 10:50
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 14.07.2012, 10:52
Re: Simple AI Police Officer NPC using RNPC - by qq757679895 - 14.07.2012, 11:12
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 15.07.2012, 10:58
Re: Simple AI Police Officer NPC using RNPC - by qq757679895 - 15.07.2012, 11:20
Respuesta: Simple AI Police Officer NPC using RNPC - by Marricio - 15.07.2012, 16:27
Re: Simple AI Police Officer NPC using RNPC - by Igi_Guduric - 15.07.2012, 19:56
Re: Respuesta: Simple AI Police Officer NPC using RNPC - by ds811888 - 15.07.2012, 19:57
Re: Simple AI Police Officer NPC using RNPC - by Mauzen - 15.07.2012, 20:06
Re: Simple AI Police Officer NPC using RNPC - by qq757679895 - 16.07.2012, 01:34
Re: Simple AI Police Officer NPC using RNPC - by TheArcher - 16.07.2012, 10:46
Re: Simple AI Police Officer NPC using RNPC - by Mauzen - 16.07.2012, 12:07
Re: Simple AI Police Officer NPC using RNPC - by Mauzen - 20.08.2012, 13:43
Re: Simple AI Police Officer NPC using RNPC - by ajwar - 09.01.2013, 21:12

Forum Jump:


Users browsing this thread: 1 Guest(s)