Jump to content

Release: @petstats command


sader1992

Recommended Posts


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

@petstats command


this command will show you the pet stats

see the screenshot for more info

image.png.f12c2fa11d533b8369438550a7d73060.png

you can add it inside /rAthena/src/map/atcommand.cpp or if you use old rathena add it at /rAthena/src/map/atcommand.c file

add it like you add any new atcommand

and recompile

 


 

  • Upvote 1
  • Love 3
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  197
  • Topics Per Day:  0.08
  • Content Count:  883
  • Reputation:   28
  • Joined:  02/13/17
  • Last Seen:  

Thank you for this @sader1992

where do we insert the script?

Link to comment
Share on other sites


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

@Quesooo it's not script it's for Source Modification

you can add it inside /rAthena/src/map/atcommand.cpp or if you use old rathena add it at /rAthena/src/map/atcommand.c file

add it like you add any new atcommand

and recompile

Edited by sader1992
  • Love 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  197
  • Topics Per Day:  0.08
  • Content Count:  883
  • Reputation:   28
  • Joined:  02/13/17
  • Last Seen:  

@sader1992 i believed i need to use your petstats.cpp since im using latest rathena, after inserting the codes and recompile, checking ingame using poring pet and use @petstats command the system said that not available command or something unknown command, am i missing something?

Link to comment
Share on other sites


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

then you didn't add the command correctly

Link to comment
Share on other sites

  • 10 months later...

  • Group:  Forum Moderator
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  830
  • Reputation:   316
  • Joined:  02/11/19
  • Last Seen:  

Could you update this sader, please? 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  16
  • Reputation:   7
  • Joined:  06/06/19
  • Last Seen:  

//===== rAthena Script =======================================
//= saders @petstats command
//===== By: ==================================================
//= Sader1992
//= Free!!
//https://rathena.org/board/profile/30766-sader1992/
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: ===================================== 
//= rAthena Project
//https://github.com/sader1992/sader_scripts
//===== Description: =========================================
//==== @petstats command
//============================================================

ACMD_FUNC(petstats)
{
	struct pet_data *pd = sd->pd;
	nullpo_retr(-1, sd);
	char output[CHAT_SIZE_MAX], petname[100], mobname[100], infostring1[100], infostring2[100];
	int i;
	struct {
		const char* format;
		int value;
	} output_table[] = {
		{ NULL, 0 },
		{ NULL, 0 },
		{ "Pet ID - %d", 0 },
		{ "Pet Level - %d", 0 },
		{ "Pet Loyalty - %d", 0 },
		{ "Pet equip - %d", 0 },
		{ "Pet Hungry - %d", 0 },
		{ NULL, 0 },
		{ NULL, 0 },
		{ "Mob ID - %d", 0 },
		{ "Egg ID - %d", 0 },
		{ "Food ID - %d", 0 },
		{ "Equip ID - %d", 0 },
	};
	
	pd = sd->pd;
	if (!pd) {
		clif_displaymessage(fd, msg_txt(sd, 184)); // Sorry, but you have no pet.
		return -1;
	}
	std::shared_ptr<s_pet_db> pet_db_ptr = pd->get_pet_db();
	memset(infostring1, '\0', sizeof(infostring1));
	memset(output, '\0', sizeof(output));
	memset(petname, '\0', sizeof(petname));
	memset(infostring2, '\0', sizeof(infostring2));
	memset(mobname, '\0', sizeof(mobname));
	sprintf(infostring2, "- Pet Information -");
	output_table[0].format = infostring2;
	sprintf(petname, "Pet Name - %s", pd->pet.name);
	output_table[1].format = petname;
	output_table[2].value = pd->pet.pet_id;
	output_table[3].value = pd->pet.level;
	output_table[4].value = pd->pet.intimate;
	output_table[5].value = pd->pet.equip;
	output_table[6].value = pd->pet.hungry;
	sprintf(infostring1, "- Database Information -");
	output_table[7].format = infostring1;
	// sprintf(mobname, "Mob Name - %s", pet_db_ptr->);
	output_table[8].format = mobname;
	output_table[9].value = pet_db_ptr->class_;
	output_table[10].value = pet_db_ptr->EggID;
	output_table[11].value = pet_db_ptr->FoodID;
	output_table[12].value = pet_db_ptr->AcceID;
	for (i = 0; i<13; i++) {
		sprintf(output, output_table[i].format, output_table[i].value);
		clif_displaymessage(fd, output);
	}
	return 0;
}

atcommand.inc

ACMD_DEF(petstats),

atcommand_def.inc

or alternatively you can use on npc scripts.

-	script	petinfo	-1,{
OnInit:
	bindatcmd "petinfo",strnpcinfo(0)+"::OnPetInfo";
	end;
OnPetInfo:
    .@pid = getpetinfo(PETINFO_ID);
    .@pclassid = getpetinfo(PETINFO_CLASS);
    .@pname$ = getpetinfo(PETINFO_NAME);
    .@phungry = getpetinfo(PETINFO_HUNGRY);
    .@pintimacy = getpetinfo(PETINFO_INTIMATE);
    .@pfoodid = getpetinfo(PETINFO_FOODID);

    .@pname$ = getmonsterinfo(.@pclassid,MOB_NAME);

    if (.@pid == 0) {
		dispbottom "You do not have a pet.",0xff0000;
		dispbottom "@petinfo failed.",0xff0000;
		end;
	}

    dispbottom " ===== Pet information =====",0x00ff00;
    dispbottom "Original Name: "+.@pname$+" - Name: "+.@pname$,0x00ff00;
    dispbottom "Hungry: "+.@phungry+" - Intimacy "+.@pintimacy,0x00ff00;
    dispbottom "Pet Food: "+F_ItemL2(.@pfoodid),0x00ff00;
    end;
}

the result image.png.8b24a7914146f71199c22be8ac39bba6.png

Edited by YJ1994
  • Love 2
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  796
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

Nice idea looks good, thank u ?

 

Rynbef~

Link to comment
Share on other sites

  • 8 months later...

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  65
  • Reputation:   0
  • Joined:  12/10/14
  • Last Seen:  

Thanks for sharing this feature.

I have a problem trying to compile. Attached image, I appreciate very much who can help me to solve it.

 

i use the ( petstats rAthena Cpp.cs )

petstats.png

Link to comment
Share on other sites


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

On 4/6/2020 at 6:02 AM, Xiao said:

Thanks for sharing this feature.

I have a problem trying to compile. Attached image, I appreciate very much who can help me to solve it.

 

i use the ( petstats rAthena Cpp.cs )

petstats.png

try this

ACMD_FUNC(petstats)
{
	struct pet_data* pd;
	std::shared_ptr<s_pet_db> pet_db_ptr;
	nullpo_retr(-1, sd);
	char output[CHAT_SIZE_MAX];
	char petname[100];
	char mobname[100];
	char infostring1[100];
	char infostring2[100];
	int i;
	struct {
		const char* format;
		int value;
	} output_table[] = {
		{ NULL, 0 },
		{ NULL, 0 },
		{ "Pet ID - %d", 0 },
		{ "Pet Level - %d", 0 },
		{ "Pet Loyalty - %d", 0 },
		{ "Pet equip - %d", 0 },
		{ "Pet Hungry - %d", 0 },
		{ NULL, 0 },
		{ NULL, 0 },
		{ "Mob ID - %d", 0 },
		{ "Egg ID - %d", 0 },
		{ "Food ID - %d", 0 },
		{ "Equip ID - %d", 0 },
	};

	pd = sd->pd;
	if (!pd) {
		clif_displaymessage(fd, msg_txt(sd, 184)); // Sorry, but you have no pet.
		return -1;
	}
	pet_db_ptr = pd->get_pet_db();
	memset(infostring1, '\0', sizeof(infostring1));
	memset(output, '\0', sizeof(output));
	memset(petname, '\0', sizeof(petname));
	memset(infostring2, '\0', sizeof(infostring2));
	memset(mobname, '\0', sizeof(mobname));
	sprintf(infostring2, "- Pet Information -");
	output_table[0].format = infostring2;
	sprintf(petname, "Pet Name - %s", pd->pet.name);
	output_table[1].format = petname;
	output_table[2].value = pd->pet.pet_id;
	output_table[3].value = pd->pet.level;
	output_table[4].value = pd->pet.intimate;
	output_table[5].value = pd->pet.equip;
	output_table[6].value = pd->pet.hungry;
	sprintf(infostring1, "- Database Information -");
	output_table[7].format = infostring1;
	sprintf(mobname, "Mob Name - %s", mob_db(pet_db_ptr->class_)->jname);
	output_table[8].format = mobname;
	output_table[9].value = pet_db_ptr->class_;
	output_table[10].value = pet_db_ptr->EggID;
	output_table[11].value = pet_db_ptr->FoodID;
	output_table[12].value = pet_db_ptr->AcceID;
	for (i = 0; i < 13; i++) {
		sprintf(output, output_table[i].format, output_table[i].value);
		clif_displaymessage(fd, output);
	}
	return 0;
}

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  65
  • Reputation:   0
  • Joined:  12/10/14
  • Last Seen:  

Thanks!

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  1
  • Reputation:   0
  • Joined:  11/18/17
  • Last Seen:  

thxx you

Link to comment
Share on other sites

  • 1 year later...

  • Group:  Members
  • Topic Count:  99
  • Topics Per Day:  0.02
  • Content Count:  623
  • Reputation:   94
  • Joined:  05/11/12
  • Last Seen:  

This need be updated!

Link to comment
Share on other sites


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

4 hours ago, Kakaroto said:

This need be updated!

on what hash? , I use petstats rAthena Cpp 25_04_2020 on around 1 month old rathena and still work with a small warning for string

image.thumb.png.6bcf4827b4f3bf5c461c707a5bc70d1c.png

Edited by sader1992
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  99
  • Topics Per Day:  0.02
  • Content Count:  623
  • Reputation:   94
  • Joined:  05/11/12
  • Last Seen:  

32 minutes ago, sader1992 said:

on what hash? , I use petstats rAthena Cpp 25_04_2020 on around 1 month old rathena and still work with a small warning for string

image.thumb.png.6bcf4827b4f3bf5c461c707a5bc70d1c.png

 

1>atcommand.cpp
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,36): error C2064: term does not evaluate to a function taking 1 arguments
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,19): warning C4473: 'sprintf' : not enough arguments passed for format string
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,19): message : placeholders and their parameters expect 1 variadic arguments, but 0 were provided
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,19): message : the missing variadic argument 1 is required by format string '%s'
1>battle.cpp
1>Done building project "map-server.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 12 up-to-date, 0 skipped ==========

Sh4490M.png

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

1 hour ago, Kakaroto said:

 

1>atcommand.cpp
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,36): error C2064: term does not evaluate to a function taking 1 arguments
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,19): warning C4473: 'sprintf' : not enough arguments passed for format string
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,19): message : placeholders and their parameters expect 1 variadic arguments, but 0 were provided
1>F:\GitHub\Emulador\src\custom\atcommand.inc(675,19): message : the missing variadic argument 1 is required by format string '%s'
1>battle.cpp
1>Done building project "map-server.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 12 up-to-date, 0 skipped ==========

Sh4490M.png

oh I see , when I fixed the warning , I also changed the function call , didn't notice that

will update it

the fix is from

sprintf(mobname, "Mob Name - %s", mob_db(pet_db_ptr->class_)->jname);

to

std::string temp_name = "Mob Name - " + mob_db.find(pet_db_ptr->class_)->jname;
strcpy(mobname, temp_name.c_str());

Thank you for notifying me!

Edited by sader1992
  • MVP 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  99
  • Topics Per Day:  0.02
  • Content Count:  623
  • Reputation:   94
  • Joined:  05/11/12
  • Last Seen:  

23 hours ago, sader1992 said:

oh I see , when I fixed the warning , I also changed the function call , didn't notice that

will update it

the fix is from

sprintf(mobname, "Mob Name - %s", mob_db(pet_db_ptr->class_)->jname);

to

std::string temp_name = "Mob Name - " + mob_db.find(pet_db_ptr->class_)->jname;
strcpy(mobname, temp_name.c_str());

Thank you for notifying me!

 

Noice work man!

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   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...