Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   universal NPC that charge you fee (https://postpacific.loc-online.com/showthread.php?t=7531)

rodier 10.05.2007 11:31

universal NPC that charge you fee
 
Hi all
Im trying to create universal AI code that I can put into any AI NPC and it will charge player some fee and THEN do it something.. (something thats already in npc)

Im currently looking in public_wyvern AI code because its seems to be easies code but I dont know how to strip that AI code to have there simply the charge.

My idea is - I have NPC buffer, I have NPC that give you custom pet..
OK but what if I want ppl will be charged for this service? I want simply some AI code that will paste into AI of that service NPCS and it will simply charge people..

is this possible?

AI.code start
head of npc
--
AI that will charge you
---
AI that will provide some service

? If yes, can anyone give me here code that I can simply paste before AI code that provide some service?

I understand AI - but only a little.. I can read it.. but it seems to me its litle complicated.. full of jumps..etc.. Why its not continual like php..etc? I dont understand where to put that code in which part of NPC AI because I cant find where one thing start and second end..

maybe this part of code will work?

Code:

class 1 buffer_npc : default_npc
parameter_define_begin
        string fnHi "some-service-menu.htm"
        string fnYouAreChaotic "chaotic.htm"
        string fnNotEnoughAdena "adena.htm"
        string fnWait "wait.htm"
        int ItemBuff 57
        int Amount 50000
        int Delay 500
parameter_define_end

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

        push_event        //  myself
        push_const 704
        add
        fetch_i        //  i_ai0
        push_const 308
        add
        push_reg_sp
        fetch_i
        push_const 0
        assign4
        shift_sp -1
handler_end

handler 3 38        //  TALKED
        variable_begin
                "talker"
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end

        push_event        //  talker
        push_const 40
        add
        fetch_i        //  karma
        push_const 468
        add
        fetch_i4
        push_const 0
        greater
        branch_false L2
L1
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
        push_parameter fnYouAreChaotic
        func_call 184680516        //  func[ShowPage]
        shift_sp -2
        shift_sp -1
        jump L3
L2
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
        push_parameter fnHi
        func_call 184680516        //  func[ShowPage]
        shift_sp -2
        shift_sp -1
L3
handler_end

handler 32 134        //  MENU_SELECTED
        variable_begin
                "talker"
                "ask"
                "reply"
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end
       
        push_event        //  ask
        push_const 160
        add
        fetch_i4
        push_const 201
        negate
        equal
        push_reg_sp
        fetch_i       
        branch_false L4
        shift_sp 1
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
        push_parameter ItemBuff
        func_call 184680579        //  func[OwnItemCount]
        shift_sp -2
        push_parameter Amount
        greater_equal
        and
L4
        branch_false L5
L6
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  i_ai0
        push_const 308
        add
        fetch_i4
        push_const 0
        equal
        branch_false L8
L7
        push_event        //  myself
        push_const 704
        add
        fetch_i        //  i_ai0
        push_const 308
        add
        push_reg_sp
        fetch_i
        push_const 1
        assign4
        shift_sp -1
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
        push_parameter ItemBuff
        push_parameter Amount
        func_call 184746114        //  func[DeleteItem1]
        shift_sp -3
        shift_sp -1

and now, original AI code can continue? ... code like
push_parameter fnHi
func_call 184680516 // func[ShowPage]
shift_sp -2
shift_sp -1
handler_end
class_end


so this will charge player for showing him page? (this is only dumb example)..

McBigMac 13.05.2007 08:34

Add this after checking for karma in Talked handler, change the number 38, to the ammount of lines in the handler with this addon text.
Code:

L1337
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
        push_const 57 // Check For Adena
        func_call 184680579        //  func[OwnItemCount]
        shift_sp -2
        push_const 58000 /// Ammount of Adena
        greater_equal
        branch_false L5555
L1338
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
        push_const 57 // Delete Adena
        push_const 58000 // Ammount
        func_call 184746114        //  func[DeleteItem1]
        shift_sp -3
        shift_sp -1
        jump L2
L5555
        push_event        //  myself
        push_const 704
        add
        fetch_i
        push_event        //  talker
        push_const 40
        add
        fetch_i
S2.        "noadenamengz.htm" // You have not adena mengz
        push_string S2
        func_call 184680516        //  func[ShowPage]
        shift_sp -2
        shift_sp -1
        jump L3



All times are GMT. The time now is 15:49.