Post Pacific

Post Pacific (https://postpacific.mmorpg-game.online/index.php)
-   Lineage 2 Help (https://postpacific.mmorpg-game.online/forumdisplay.php?f=37)
-   -   ≈ [HELP] How to make NPCs stop chasing after a certain point. (https://postpacific.mmorpg-game.online/showthread.php?t=7838)

PyroMaker 16.06.2007 17:29

[HELP] How to make NPCs stop chasing after a certain point.
 
Hi,

I've finally managed to make NPCs aggro correctly, and finished my Project Gondor, it works perfectly. Thank you all for your support.

However, I have a very last issue, people get NPCs to chase them and bring them to spawn point, since their AI has no movement at all (wanted to make them stand still) they don't go back to their original positions.

So I was wondering, is it possible to make an NPC chase you until a certain point and after that make it come back to its original position?

If that is so, can you gimme a hand here?

Thank you for your help and attention.

Best regards,
Mike Philippe.

Sdw 16.06.2007 17:32

Check those two :

func[InstantRandomTeleportInMyTerritory]
func[InMyTerritory]

m4rk 16.06.2007 17:35

This is not a solution for what you asked, read down
They may get stuck while trying to come back (I don't know) but try to add this to your gondor class

nasc code
Code:

        EventHandler NO_DESIRE()
        {
                myself->AddMoveToDesire(myself.start_x,myself.start_y,myself.start_z,30);
        }

basically copy pasting this into ur gondor class
Code:

handler 0 29        //  NO_DESIRE
        variable_begin
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end

        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  start_x
        push_const 588
        add
        fetch_i4
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  start_y
        push_const 592
        add
        fetch_i4
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  start_z
        push_const 596
        add
        fetch_i4
        push_const 30
        func_call 184811540        //  func[AddMoveToDesire]
        shift_sp -4
        shift_sp -1
handler_end

If you see they get stuck or something then just replace the addmovedesire by a instantteleport

OK, read now xD
edit: Ok, at first I did not read correctly what you wanted. What I've put up here only solves the problem once the gondor guard has nothing to (i.e. the char he was attacking too bsoed).

I guess a good solution would be using the func[InMyTerritory] this way:
Code:

if (myself->InMyTerritory(myself.sm))
{
}
else
{
                        myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
                        RemoveAllAttackDesire();
}


Bloodust 16.06.2007 17:42

I answered PyroMaker in IRC with a lot more simplier answer :D
[20:31:07] <Bloodust> if distance from current position is higher than something, move to spawn point ?
[20:33:09] <Bloodust> is that possible ?

Sdw 16.06.2007 18:10

You can check this way if (myself->InMyTerritory(myself.sm) == 0)

Code:

        func_call 184615156        //  func[InMyTerritory]
        shift_sp -1
        push_const 0
        equal

So
Code:

if (myself->InMyTerritory(myself.sm) == 0)
{
                        myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
                        RemoveAllAttackDesire();
}

or

Code:

if (myself->InMyTerritory(attacker) == 0)
{
                        myself->RemoveAllAttackDesire(attacker->id);
                        myself->InstantTeleportInMyTerritory(start_x,start_y,start_z);
}

I would use func[InstantTeleportInMyTerritory] instead of InstantTeleport but, well, it's the very same.

m4rk 16.06.2007 18:24

This should work:
It checks every 5 seconds if it's in his territory...
Remember that the territory is defined in npcpos, so if you've done a little territory for each npc you'll have to change it to the area you want it to be their territory!

nasc
Code:

/***************************************************************************
*                                Change Log
*                            ------------------
*  xx.xx.2007
*  Script Decompiled by SauDecompiler build 102306.2
*
***************************************************************************/

class gondor : whatever
{
handler:
        EventHandler TIMER_FIRED_EX(timer_id)
        {
                if( myself->InMyTerritory(myself.sm) == 0 )
                {
                        myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
                        RemoveAllAttackDesire();
                }
                myself->AddTimerEx(1234,5000);
                super;
        }

        EventHandler CREATED()
        {
                myself->AddTimerEx(1234,5000);
                super;
        }

}

ai
Code:

class 1 gondor : whatever

handler 12 77        //  TIMER_FIRED_EX
        variable_begin
                "timer_id"
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end

        push_event        //  timer_id
        push_const 236
        add
        fetch_i4
        push_const 3001
        equal
        branch_false L4
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  sm
        push_const 544
        add
        fetch_i
        func_call 184615156        //  func[InMyTerritory]
        shift_sp -1
        push_const 0
        equal
        branch_false L2

L1
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  sm
        push_const 544
        add
        fetch_i
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  start_x
        push_const 588
        add
        fetch_i4
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  start_y
        push_const 592
        add
        fetch_i4
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  start_z
        push_const 596
        add
        fetch_i4
        func_call 184811596        //  func[InstantTeleport]
        shift_sp -4
        shift_sp -1
        push_event        //  myself
        push_const 704
        add
        fetch_i
        func_call 184549401        //  func[RemoveAllAttackDesire]
        shift_sp -1
L2
L3
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_const 1234
        push_const 5000
        func_call 184680487        //  func[AddTimerEx]
        shift_sp -2
        shift_sp -1
L4
  call_super
handler_end

handler 13 10        //  CREATED
        variable_begin
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end

        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_const 1234
        push_const 5000
        func_call 184680487        //  func[AddTimerEx]
        shift_sp -2
        shift_sp -1
        call_super
handler_end


class_end



All times are GMT. The time now is 22:50.