Skip to content

Commit

Permalink
Fixed Bug #7091
Browse files Browse the repository at this point in the history
 -Updated SN_SIGHT to its RE behavior.
 -Updated RE behavior that deals with NPC dialogs and using items/skills.

Signed-off-by: malufett <malufett.eat.my.binaries@gmail.com>
  • Loading branch information
malufett committed Feb 23, 2013
1 parent 6c6fbf0 commit adda8d7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/map/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,10 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
skillratio += -100 + 100 * skill_lv;
break;
}

#ifdef RENEWAL
if( sc && sc->data[SC_TRUESIGHT] )
skillratio += 2*sc->data[SC_TRUESIGHT]->val1;
#endif
ATK_RATE(skillratio);

//Constant/misc additions from skills
Expand Down Expand Up @@ -3068,8 +3071,10 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo

//The following are applied on top of current damage and are stackable.
if ( sc ) {
#ifndef RENEWAL
if( sc->data[SC_TRUESIGHT] )
ATK_ADDRATE(2*sc->data[SC_TRUESIGHT]->val1);
#endif
if( sc->data[SC_GLOOMYDAY_SK] &&
( skill_id == LK_SPIRALPIERCE || skill_id == KN_BRANDISHSPEAR ||
skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ||
Expand Down
25 changes: 13 additions & 12 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -9520,7 +9520,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd)
sd->st->state = END;

sd->progressbar.npc_id = sd->progressbar.timeout = 0;
npc_scriptcont(sd, npc_id);
npc_scriptcont(sd, npc_id, false);
}


Expand Down Expand Up @@ -10179,12 +10179,7 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd)
return;
}

//This flag enables you to use items while in an NPC. [Skotlex]
if (sd->npc_id) {
if (sd->npc_id != sd->npc_item_flag)
return;
}
else if ( pc_istrading(sd) || sd->chatID )
if ( (!sd->npc_id && pc_istrading(sd)) || sd->chatID )
return;

//Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex]
Expand Down Expand Up @@ -10795,6 +10790,12 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
// Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
sd->idletime = last_tick;

if( sd->npc_id ){
#ifdef RENEWAL
clif_msg(sd, 0x783); // TODO look for the client date that has this message.
#endif
return;
}
if( pc_cant_act(sd) && skill_id != RK_REFRESH && !(skill_id == SR_GENTLETOUCH_CURE && (sd->sc.opt1 == OPT1_STONE || sd->sc.opt1 == OPT1_FREEZE || sd->sc.opt1 == OPT1_STUN)) )
return;
if( pc_issit(sd) )
Expand Down Expand Up @@ -11129,15 +11130,15 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
}

sd->npc_menu = select;
npc_scriptcont(sd,npc_id);
npc_scriptcont(sd,npc_id, false);
}


/// NPC dialog 'next' click (CZ_REQ_NEXT_SCRIPT).
/// 00b9 <npc id>.L
void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
{
npc_scriptcont(sd,RFIFOL(fd,2));
npc_scriptcont(sd,RFIFOL(fd,2), false);
}


Expand All @@ -11149,7 +11150,7 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
int amount = (int)RFIFOL(fd,6);

sd->npc_amount = amount;
npc_scriptcont(sd, npcid);
npc_scriptcont(sd, npcid, false);
}


Expand All @@ -11165,7 +11166,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
return; // invalid input

safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE));
npc_scriptcont(sd, npcid);
npc_scriptcont(sd, npcid, false);
}


Expand All @@ -11175,7 +11176,7 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
{
if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
return;
npc_scriptcont(sd,RFIFOL(fd,2));
npc_scriptcont(sd, RFIFOL(fd,2), true);
}


Expand Down
5 changes: 4 additions & 1 deletion src/map/npc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
/*==========================================
*
*------------------------------------------*/
int npc_scriptcont(struct map_session_data* sd, int id)
int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
{
nullpo_retr(1, sd);

Expand Down Expand Up @@ -1229,6 +1229,9 @@ int npc_scriptcont(struct map_session_data* sd, int id)
if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,gettick()) > 0 )
return 1;

if( closing )
sd->st->state = END;

run_script_main(sd->st);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/map/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int npc_touch_areanpc2(struct mob_data *md); // [Skotlex]
int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range);
int npc_touchnext_areanpc(struct map_session_data* sd,bool leavemap);
int npc_click(struct map_session_data* sd, struct npc_data* nd);
int npc_scriptcont(struct map_session_data* sd, int id);
int npc_scriptcont(struct map_session_data* sd, int id, bool closing);
struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl);
int npc_buysellsel(struct map_session_data* sd, int id, int type);
int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
Expand Down
8 changes: 8 additions & 0 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4232,6 +4232,14 @@ int pc_useitem(struct map_session_data *sd,int n)

nullpo_ret(sd);

//This flag enables you to use items while in an NPC. [Skotlex]
if( sd->npc_id && sd->npc_id != sd->npc_item_flag ){
#ifdef RENEWAL
clif_msg(sd, 0x783); // TODO look for the client date that has this message.
#endif
return 0;
}

if( sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0 )
return 0;

Expand Down
2 changes: 1 addition & 1 deletion src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -4392,7 +4392,7 @@ BUILDIN_FUNC(close)
if( sd == NULL )
return 0;

st->state = END;
st->state = STOP;
clif_scriptclose(sd, st->oid);
return 0;
}
Expand Down

0 comments on commit adda8d7

Please sign in to comment.