Jump to content
  • 0

How to get responses from NPC interactions(menus, next, close)


Ninja

Question


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

Hi, long time no see. Here I am again having some free time but now, only for leisure purposes and maybe help out on anything I can.

I've search the forums and didn't find anything related. I am stuck with one problem, I am trying to learn how to catch responses from menus generated via source.

I know it's easy to do this via script and I've done a lot of them but I'm stuck on figuring out how to handle PC responses from source.

Below is a snippet of my code that I'm trying to play with.

skill.inc

// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#include "..\map\clif.hpp"
#include "..\map\script.hpp"
#include "..\common\socket.hpp"
#include "..\common\malloc.hpp"
#include "..\common\strlib.hpp"

void test_skill_inc(struct map_session_data *sd){
	struct s_packet_db* info = &packet_db[RFIFOW(sd->fd,0)];
	if(sd->npc_id == 0){
		//create and display the menu
		char* menu;
		menu = "this:is:a:test";
		clif_scriptmenu(sd, -1, menu);
	} else {
		uint8 select = RFIFOB(sd->fd,info->pos[1]);
		//parse response
		switch(select){
		case 1:
			clif_scriptmes(sd, sd->npc_id, "chose this");
			break;
		case 2:
			clif_scriptmes(sd, sd->npc_id, "chose is");
			break;
		case 3:
			clif_scriptmes(sd, sd->npc_id, "chose a");
			break;
		case 4:
			clif_scriptmes(sd, sd->npc_id, "chose test");
			break;
		}
		clif_scriptclose(sd, sd->npc_id);
	}
}

skill.cpp

#include "../custom/skill.inc"
int skill_castend_nodamage_id(...)
...
	case MC_VENDING:
		if(sd)
		{	//Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex]
			if ( !pc_can_give_items(sd) )
				clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
			else {
				test_skill_inc(sd);
			}
		}
...

My aim is to pop up a menu - in this case, "this," "is," "a," "test" - when the vending skill(or generally any skill) is pressed then creates a message window that contains the chosen item from the menu.

Will be grateful for the help ? thanks.

 

Edited by Ninja
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...