Jump to content

Recommended Posts

Posted (edited)

Hallo there i got it finaly running that my custom created mobs can also enjoy the players carts. 😄

rathena/src/map/clif.cpp:

void clif_getareachar_unit( map_session_data* sd,struct block_list *bl ){
  .....
	case BL_MOB:
	{
 	 .....
			int carttype = 0;
			if (md->sc.getSCE(SC_PUSH_CART)) {
				carttype = md->sc.getSCE(SC_PUSH_CART)->val1;
				PACKET_ZC_EFST_SET_ENTER p{};

				p.packetType = HEADER_ZC_EFST_SET_ENTER;
				p.targetID = md->bl.id;
				p.type = status_db.getIcon(SC_PUSH_CART);
				p.duration = client_tick(9999);
#if PACKETVER >= 20120618
				p.duration2 = p.duration;
#endif
				p.val1 = carttype / 64 - 1;
				p.val2 = 0;
				p.val3 = 0;

				clif_send(&p, sizeof(p), &sd->bl, AREA);
			}
  	...
  	}
 ... 
}

 

Here also a script to set it to a bl->id like a spawned monster or npc
BUILDIN_DEF(setunitcart, "ii"),

BUILDIN_FUNC(setunitcart)
{
	struct block_list* bl = nullptr;
	int carttype = script_getnum(st, 2);

	if (carttype < 0 || carttype > MAX_CARTS) return SCRIPT_CMD_SUCCESS;

	bl = map_id2bl(script_getnum(st, 3));

	if (bl) sc_start(bl, bl, SC_PUSH_CART, 100, carttype, 0);

	return SCRIPT_CMD_SUCCESS;
}



I hope you'll find it usefull like me.

 

A little hint at the end here... you can get the block id of a mob after spawning them (mob_once_spawn in the mob.cpp returns a int32 with a block id or 0 for failed to spawn)

Edited by Hasi105
  • Upvote 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...