Skip to content

Commit

Permalink
Merge pull request #247 from aleos89/hotfix/issue138
Browse files Browse the repository at this point in the history
Fixed #138 - Updated trap visibility to official settings.
  • Loading branch information
aleos89 committed Feb 7, 2015
2 parents bc74ffe + 73243e8 commit a427dbf
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
9 changes: 5 additions & 4 deletions conf/battle/skill.conf
Expand Up @@ -119,10 +119,11 @@ skill_nofootset: 1
// Default on official servers: 1 (for players)
gvg_traps_target_all: 1

// Some traps settings (add as necessary):
// 1: Traps are invisible to those who come into view of it. When unset, all traps are visible at all times.
// (Invisible traps can be revealed through Hunter's Detecting skill)
traps_setting: 0
// Hunter's traps visibility setting:
// 1: (Official) Many of Hunter's traps are invisible at all times.
// But any player who see the Hunter laying the trap will be able to see the trap until they move out of sight of it.
// Although, invisible traps can be revealed through Hunter's Detecting skill.
traps_setting: 1

// Restrictions applied to the Alchemist's Summon Flora skill (add as necessary)
// 1: Enable players to damage the floras outside of versus grounds.
Expand Down
32 changes: 24 additions & 8 deletions src/map/clif.c
Expand Up @@ -4545,10 +4545,10 @@ static void clif_graffiti(struct block_list *bl, struct skill_unit *unit, enum s
/// 08c7 <lenght>.W <id> L <creator id>.L <x>.W <y>.W <unit id>.B <range>.W <visible>.B (ZC_SKILL_ENTRY3)
/// 099f <lenght>.W <id> L <creator id>.L <x>.W <y>.W <unit id>.L <range>.W <visible>.B (ZC_SKILL_ENTRY4)
/// 09ca <lenght>.W <id> L <creator id>.L <x>.W <y>.W <unit id>.L <range>.B <visible>.B <skill level>.B (ZC_SKILL_ENTRY5)
void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *unit, enum send_target target) {
void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *unit, enum send_target target, uint8 flag) {
int header = 0, unit_id = 0, pos = 0, fd = 0, len = -1;
unsigned char buf[128];

nullpo_retv(bl);
nullpo_retv(unit);

Expand All @@ -4558,15 +4558,31 @@ void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *unit,
if (unit->group->state.guildaura)
return;

if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP)
unit_id = UNT_DUMMYSKILL; //Use invisible unit id for traps.
else if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE)
if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE)
unit_id = unit->val2&UF_SONG ? UNT_DISSONANCE : UNT_UGLYDANCE;
else if (skill_get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
unit_id = UNT_DUMMYSKILL; //Use invisible unit id for other case of rangedsingle unit
unit_id = UNT_DUMMYSKILL; // Use invisible unit id for other case of rangedsingle unit
else
unit_id = unit->group->unit_id;

if (flag && battle_config.traps_setting&1) {
switch(unit->group->skill_id) {
case HT_ANKLESNARE:
if (!map_flag_vs(((TBL_PC*)bl)->bl.m))
break;
case HT_SKIDTRAP:
case MA_SKIDTRAP:
case HT_SHOCKWAVE:
case HT_SANDMAN:
case MA_SANDMAN:
case HT_FLASHER:
case HT_FREEZINGTRAP:
case MA_FREEZINGTRAP:
unit_id = UNT_DUMMYSKILL; // Use invisible unit id for Hunter's traps
break;
}
}

#if PACKETVER >= 3
if (unit_id == UNT_GRAFFITI) { // Graffiti [Valaris]
clif_graffiti(bl, unit, target);
Expand Down Expand Up @@ -4690,7 +4706,7 @@ static int clif_getareachar(struct block_list* bl,va_list ap)
clif_getareachar_item(sd,(struct flooritem_data*) bl);
break;
case BL_SKILL:
clif_getareachar_skillunit(&sd->bl, (TBL_SKILL*)bl, SELF);
clif_getareachar_skillunit(&sd->bl, (TBL_SKILL*)bl, SELF, 1);
break;
default:
if(&sd->bl == bl)
Expand Down Expand Up @@ -4778,7 +4794,7 @@ int clif_insight(struct block_list *bl,va_list ap)
clif_getareachar_item(tsd,(struct flooritem_data*)bl);
break;
case BL_SKILL:
clif_getareachar_skillunit(&tsd->bl, (TBL_SKILL*)bl, SELF);
clif_getareachar_skillunit(&tsd->bl, (TBL_SKILL*)bl, SELF, 1);
break;
default:
clif_getareachar_unit(tsd,bl);
Expand Down
2 changes: 1 addition & 1 deletion src/map/clif.h
Expand Up @@ -553,7 +553,7 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id

void clif_produceeffect(struct map_session_data* sd,int flag, unsigned short nameid);

void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *unit, enum send_target target);
void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *unit, enum send_target target, uint8 flag);
void clif_skill_delunit(struct skill_unit *unit);
void clif_skillunit_update(struct block_list* bl);

Expand Down
14 changes: 7 additions & 7 deletions src/map/skill.c
Expand Up @@ -4017,7 +4017,7 @@ static int skill_reveal_trap(struct block_list *bl, va_list ap)
{ //Reveal trap.
//Change look is not good enough, the client ignores it as an actual trap still. [Skotlex]
//clif_changetraplook(bl, su->group->unit_id);
clif_getareachar_skillunit(&su->bl, su, AREA);
clif_getareachar_skillunit(&su->bl, su, AREA, 0);
return 1;
}
return 0;
Expand Down Expand Up @@ -10954,8 +10954,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
src->m, x-i, y-i, x+i,y+i,BL_CHAR,
src,NULL,SC_SIGHT,tick);
if(battle_config.traps_setting&1)
map_foreachinarea( skill_reveal_trap,
src->m, x-i, y-i, x+i,y+i,BL_SKILL);
map_foreachinarea(skill_reveal_trap, src->m, x-i, y-i, x+i, y+i, BL_SKILL);
break;
break;

case SR_RIDEINLIGHTNING:
Expand Down Expand Up @@ -11818,7 +11818,7 @@ static int skill_dance_overlap_sub(struct block_list* bl, va_list ap)
else //Remove dissonance
target->val2 &= ~UF_ENSEMBLE;

clif_getareachar_skillunit(&target->bl, target, AREA); //Update look of affected cell.
clif_getareachar_skillunit(&target->bl, target, AREA, 0); //Update look of affected cell.

return 1;
}
Expand Down Expand Up @@ -16997,7 +16997,7 @@ struct skill_unit *skill_initunit(struct skill_unit_group *group, int idx, int x
break;
}

clif_getareachar_skillunit(&unit->bl, unit, AREA);
clif_getareachar_skillunit(&unit->bl, unit, AREA, 0);
return unit;
}

Expand Down Expand Up @@ -17840,7 +17840,7 @@ void skill_unit_move_unit(struct block_list *bl, int dx, int dy) {

map_moveblock(bl, dx, dy, tick);
map_foreachincell(skill_unit_effect,bl->m,bl->x,bl->y,su->group->bl_flag,bl,tick,1);
clif_getareachar_skillunit(bl, su, AREA);
clif_getareachar_skillunit(bl, su, AREA, 0);
return;
}

Expand Down Expand Up @@ -17934,7 +17934,7 @@ void skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 d
if (!(m_flag[i]&0x2)) { //We only moved the cell in 0-1
if (group->state.song_dance&0x1) //Check for dissonance effect.
skill_dance_overlap(unit1, 1);
clif_getareachar_skillunit(&unit1->bl, unit1, AREA);
clif_getareachar_skillunit(&unit1->bl, unit1, AREA, 0);
map_foreachincell(skill_unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,1);
}
}
Expand Down

0 comments on commit a427dbf

Please sign in to comment.