How to avoid NPC's going through objects.
#1

Hey, if it's not possible how could I just block one area for NPC's?
Reply
#2

how big is the area you want to block NPCs from?
is it a 2d-plane or a 3d-room?
are there more areas planned to be added?

i had success at creating a 6000x6000 sized array of integers, each defining 1 square meter which defines IF a npc is allowed to walk on. setting these "forbidden"/"allowed" numbers are hard work - since the area(s) need to be precisely mapped (each mІ) - please provide us more about your intentions so we can help you elaborate a good solution.
my way is not even close to a good solution, since blocking one little area for npcs doesnt justify wasting 72MB.

you could simply add a loop in a timer, where each npc gets checked for being close to your desired location, but as soon you add either more locations and/or npcs, that loop will take more and more CPU time...
Reply
#3

I want to block the entire mall area. I'm wondering if y_areas could be the solution?
Reply
#4

i didnt use y_areas yet, but it sounds like its the best way to go, since ******' codes are proven to work excellent, countless times.

your effort will be to script the npc's leaving that area (or not going there in first place), so one question remains:
are your npcs using pre-recorded paths, or are they moving dynamically?

-for the first case using .record path files, its close to impossibe, since you cannot change the path once its playing back. you will need to record each path again, avoiding all desired areas.

-for the second case, check if the "next step" for any npc would be inside/close to the mall area, therefore avoid them going there, by changing their direction for the next move.
Reply
#5

Quote:
Originally Posted by Babul
Посмотреть сообщение
-for the second case, check if the "next step" for any npc would be inside/close to the mall area, therefore avoid them going there, by changing their direction for the next move.
how to know the direction which their next move will be?
Reply
#6

You could use gang zones and then check if they entered a dynamic area by using the SA-MP callback public OnPlayerEnterDynamicArea(playerid, areaid)...

pawn Код:
public OnPlayerEnterDynamicArea(playerid, areaid) {
    npcOnPlayerEnterDynamicArea(playerid, areaid);
}
npcOnPlayerEnterDynamicArea(playerid, areaid) {
    if(IsPlayerNPC(playerid)) {
    // Code here
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by whatthefuck123
Посмотреть сообщение
how to know the direction which their next move will be?
that depends on your algorithm: if you are using a node map, then excluding nodes in the "forbidden" area will do fine. as start, to see if the npc stepped into the mall, you can, as first attempt, simply respawn them. as soon that works, you can change the moving-algorithm to chose a different direction, i.e. the second best route (let the npc walk around the mall).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)