From 0f94f735f50a320d97c0dacb806de2a65662cc3c Mon Sep 17 00:00:00 2001 From: skotlex Date: Sun, 11 Nov 2007 10:12:58 +0000 Subject: - Cleaned up pc_calc_weapontype - made on-touch areas work with walking npcs. Note that the implementation is performance may not be optimal, but I am not sure if it can be done in any better way. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11713 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/map/map.c | 7 +++++-- src/map/npc.c | 4 +--- src/map/pc.c | 52 +++++++++++++++++++++++++++++++++------------------- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 32a7ae0c2..6545c6806 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/11/12 + * Made on-touch areas work with walking npcs (is somewhat process + intensive, but people do not really care about that, do they?) [Skotlex] * Fixed a bug in r11384 letting you bypass requirements for some skills 2007/11/09 * Expanded weapon_type enum with dual-wield constants (bugreport:384) diff --git a/src/map/map.c b/src/map/map.c index 495676082..19006cf35 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -465,7 +465,9 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if (sc->data[SC_MAGICROD].timer != -1) status_change_end(bl, SC_MAGICROD, -1); } - } + } else + if (bl->type == BL_NPC) npc_unsetcells((BL_NPC*)bl); + if (moveblock) map_delblock_sub(bl,0); #ifdef CELL_NOSTACK else map_delblcell(bl); @@ -488,7 +490,8 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) skill_unit_move_unit_group((struct skill_unit_group *)sc->data[SC_WARM].val4, bl->m, x1-x0, y1-y0); } } - } + } else + if (bl->type == BL_NPC) npc_setcells((BL_NPC*)bl); return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index f6e7f0cf0..4752991c7 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1977,7 +1977,7 @@ void npc_unsetcells(struct npc_data* nd) if (m < 0 || xs < 1 || ys < 1) return; - //Locate max range on which we can localte npce cells + //Locate max range on which we can locate npc cells for(x0 = x-xs/2; x0 > 0 && map_getcell(m, x0, y, CELL_CHKNPC); x0--); for(x1 = x+xs/2-1; x1 < map[m].xs && map_getcell(m, x1, y, CELL_CHKNPC); x1++); for(y0 = y-ys/2; y0 > 0 && map_getcell(m, x, y0, CELL_CHKNPC); y0--); @@ -1999,11 +1999,9 @@ void npc_movenpc(struct npc_data* nd, int x, int y) x = cap_value(x, 0, map[m].xs-1); y = cap_value(y, 0, map[m].ys-1); - npc_unsetcells(nd); map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); map_moveblock(&nd->bl, x, y, gettick()); map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - npc_setcells(nd); } int npc_changename(const char* name, const char* newname, short look) diff --git a/src/map/pc.c b/src/map/pc.c index f07165776..4402409db 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -440,29 +440,43 @@ int pc_calcweapontype(struct map_session_data *sd) nullpo_retr(0, sd); // single-hand - if(sd->weapontype1 != W_FIST && sd->weapontype2 == W_FIST) + if(sd->weapontype2 == W_FIST) { sd->status.weapon = sd->weapontype1; - else if(sd->weapontype1 == W_FIST && sd->weapontype2 != W_FIST) + return 1; + } + if(sd->weapontype1 == W_FIST) { sd->status.weapon = sd->weapontype2; - // dual-wield, matching types - else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_DAGGER) - sd->status.weapon = W_DOUBLE_DD; - else if(sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_1HSWORD) - sd->status.weapon = W_DOUBLE_SS; - else if(sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_1HAXE) - sd->status.weapon = W_DOUBLE_AA; - // dual-wield, mixed types - else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_1HSWORD || sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_DAGGER) - sd->status.weapon = W_DOUBLE_DS; - else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_1HAXE || sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_DAGGER) - sd->status.weapon = W_DOUBLE_DA; - else if(sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_1HAXE || sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_1HSWORD) - sd->status.weapon = W_DOUBLE_SA; - // unknown, default to left hand type - else + return 1; + } + // dual-wield + sd->status.weapon = 0; + switch (sd->weapontype1){ + case W_DAGGER: + switch (sd->weapontype2) { + case W_DAGGER: sd->status.weapon = W_DOUBLE_DD; break; + case W_1HSWORD: sd->status.weapon = W_DOUBLE_DS; break; + case W_1HAXE: sd->status.weapon = W_DOUBLE_DA; break; + } + break; + case W_1HSWORD: + switch (sd->weapontype2) { + case W_DAGGER: sd->status.weapon = W_DOUBLE_DS; break; + case W_1HSWORD: sd->status.weapon = W_DOUBLE_SS; break; + case W_1HAXE: sd->status.weapon = W_DOUBLE_SA; break; + } + break; + case W_1HAXE: + switch (sd->weapontype2) { + case W_DAGGER: sd->status.weapon = W_DOUBLE_DA; break; + case W_1HSWORD: sd->status.weapon = W_DOUBLE_SA; break; + case W_1HAXE: sd->status.weapon = W_DOUBLE_AA; break; + } + } + // unknown, default to right hand type + if (!sd->status.weapon) sd->status.weapon = sd->weapontype1; - return 0; + return 2; } int pc_setequipindex(struct map_session_data *sd) -- cgit v1.2.3-60-g2f50