Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   Little issues with AI (https://postpacific.loc-online.com/showthread.php?t=3439)

Truffe 22.02.2006 04:59

Little issues with AI
 
I'm trying to create a npc who trades a few items for another one, (don't say "use multisell" :shock: ) so I wrote this :

Code:

class blehblehbleh : default_npc
{
parameter:
        string fnNoItem = "";

handler:                               
        EventHandler MENU_SELECTED(talker, ask ,reply)                       
        {                       
                if(ask == -6)               
                {               
                        if(OwnItemCount(talker, @small_sword) >= 1 && OwnItemCount(talker, @long_sword) >= 3 && OwnItemCount(talker, @broad_sword) >= 3)
                        {       
                                DeleteItem1(talker, @long_sword, 3);
                                DeleteItem1(talker, @broad_sword, 3);
                                GiveItem1(talker, @club, 1);
                        }       
                        else       
                        {       
                                ShowPage(talker, fnNoItem);
                        }
                }       
        }               
}

It compiles fine,
But it gives an "Invalid Class[0]" error
Once I managed to get rid of that error, but this NPC's AI still wasn't working :?

So...Any ideas on what's wrong with it ? :?

Kirikups 22.02.2006 05:22

Try this:

Code:

class default_npc
{}
 
class blehblehbleh : default_npc
{
parameter:
  string fnNoItem = "";

handler:           
  EventHandler MENU_SELECTED(talker, ask ,reply)         
  {         
      if(ask == -6)     
      {     
        if(OwnItemCount(talker, @small_sword) >= 1 && OwnItemCount(talker, @long_sword) >= 3 && OwnItemCount(talker, @broad_sword) >= 3)
        {   
            DeleteItem1(talker, @long_sword, 3);
            DeleteItem1(talker, @broad_sword, 3);
            GiveItem1(talker, @club, 1);
        }   
        else   
        {   
            ShowPage(talker, fnNoItem);
        }
      }   
  }     
}

or this

Code:

class blehblehbleh
{
parameter:
  string fnNoItem = "";

handler:           
  EventHandler MENU_SELECTED(talker, ask ,reply)         
  {         
      if(ask == -6)     
      {     
        if(OwnItemCount(talker, @small_sword) >= 1 && OwnItemCount(talker, @long_sword) >= 3 && OwnItemCount(talker, @broad_sword) >= 3)
        {   
            DeleteItem1(talker, @long_sword, 3);
            DeleteItem1(talker, @broad_sword, 3);
            GiveItem1(talker, @club, 1);
        }   
        else   
        {   
            ShowPage(talker, fnNoItem);
        }
      }   
  }     
}

:)

RumanticK 22.02.2006 11:57

i suppose, you've missed parent class in your source-code.

Truffe 22.02.2006 13:12

No, I've got the same issue even with the parent class in the source, NASC doesn't give any errors.

Thanks Kirikups, but I already tried such things :?

Truffe 22.02.2006 15:27

Nvm, I solved my problem :D


All times are GMT. The time now is 16:39.