• 0
Ninja

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

Question

Posted (edited)

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

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now