summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-01-06 08:09:56 -0300
committerJesusaves <cpntb1@ymail.com>2021-01-06 08:09:56 -0300
commit174d11705a13bd780dbb5c908f786fc65a6c2f9c (patch)
treeb8fbb3bcce34dcf74ead90e905afad539be37a73 /src
parente9505e1a1a958e51bdc4380c88f58b79f83a0fb8 (diff)
downloadhercules-174d11705a13bd780dbb5c908f786fc65a6c2f9c.tar.gz
hercules-174d11705a13bd780dbb5c908f786fc65a6c2f9c.tar.bz2
hercules-174d11705a13bd780dbb5c908f786fc65a6c2f9c.tar.xz
hercules-174d11705a13bd780dbb5c908f786fc65a6c2f9c.zip
[TMW2] Patch Level: Homunculus Skill Tree Pre-Requeriments
Diffstat (limited to 'src')
-rw-r--r--src/map/homunculus.c39
-rw-r--r--src/map/mob.c13
2 files changed, 35 insertions, 17 deletions
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index fbb94334c..0b501a93f 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -305,27 +305,46 @@ static int homunculus_skill_tree_get_max(int id, int b_class)
static void homunculus_skillup(struct homun_data *hd, uint16 skill_id)
{
- int i = 0 ;
+ int i = 0;
nullpo_retv(hd);
- if(hd->homunculus.vaporize != HOM_ST_ACTIVE)
+ if (hd->homunculus.vaporize != HOM_ST_ACTIVE)
return;
i = skill_id - HM_SKILLBASE;
Assert_retv(i >= 0 && i < MAX_HOMUNSKILL);
- if(hd->homunculus.skillpts > 0 &&
+ if (hd->homunculus.skillpts > 0 &&
hd->homunculus.hskill[i].id &&
hd->homunculus.hskill[i].flag == SKILL_FLAG_PERMANENT && //Don't allow raising while you have granted skills. [Skotlex]
hd->homunculus.hskill[i].lv < homun->skill_tree_get_max(skill_id, hd->homunculus.class_)
)
{
- hd->homunculus.hskill[i].lv++;
- hd->homunculus.skillpts-- ;
- status_calc_homunculus(hd,SCO_NONE);
- if (hd->master) {
- clif->homskillup(hd->master, skill_id);
- clif->hominfo(hd->master,hd,0);
- clif->homskillinfoblock(hd->master);
+ bool stop = false;
+ // Check if pre-requisites were met
+ if (!battle_config.skillfree) {
+ int c = hd->homunculus.class_ - HM_CLASS_BASE;
+ if (hd->homunculus.intimacy < homun->dbs->skill_tree[c][i].intimacylv)
+ stop = true;
+ if (!stop) {
+ for (int j = 0; j < MAX_HOM_SKILL_REQUIRE; j++) {
+ if (homun->dbs->skill_tree[c][i].need[j].id &&
+ homun->checkskill(hd, homun->dbs->skill_tree[c][i].need[j].id) < homun->dbs->skill_tree[c][i].need[j].lv) {
+ stop = true;
+ break;
+ }
+ }
+ }
+ }
+ // Level up skill if requisites were met
+ if (!stop) {
+ hd->homunculus.hskill[i].lv++;
+ hd->homunculus.skillpts-- ;
+ status_calc_homunculus(hd, SCO_NONE);
+ if (hd->master) {
+ clif->homskillup(hd->master, skill_id);
+ clif->hominfo(hd->master, hd, 0);
+ clif->homskillinfoblock(hd->master);
+ }
}
}
}
diff --git a/src/map/mob.c b/src/map/mob.c
index 2ea189c23..ca1ce3585 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1364,10 +1364,10 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick)
) {
short x = bl->x, y = bl->y;
mob_stop_attack(md);
- const struct mob_data *m_md = BL_CCAST(BL_MOB, bl);
- nullpo_retr(0, m_md);
- if (map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
- && (battle_config.slave_chase_masters_chasetarget == 0 || !mob->is_in_battle_state(m_md))
+ const struct mob_data *m_md = BL_CCAST(BL_MOB, bl); // Can be NULL due to master being BL_PC
+ // If master is BL_MOB and in battle, lock & chase to master's target instead, unless configured not to.
+ if ((battle_config.slave_chase_masters_chasetarget == 0 || (m_md != NULL && !mob->is_in_battle_state(m_md)))
+ && map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
&& unit->walktoxy(&md->bl, x, y, 0))
return 1;
}
@@ -1380,13 +1380,12 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick)
//Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex]
if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) {
struct unit_data *ud = unit->bl2ud(bl);
- struct mob_data *m_md = BL_CAST(BL_MOB, bl);
+ struct mob_data *m_md = BL_CAST(BL_MOB, bl); // Can be NULL due to master being BL_PC
nullpo_retr(0, ud);
- nullpo_retr(0, m_md);
md->last_linktime = tick;
struct block_list *tbl = NULL;
- if (battle_config.slave_chase_masters_chasetarget == 1 && m_md->target_id != 0) { // possibly chasing something
+ if (battle_config.slave_chase_masters_chasetarget == 1 && m_md != NULL && m_md->target_id != 0) { // possibly chasing something
tbl = map->id2bl(m_md->target_id);
} else if (ud->target != 0 && ud->state.attack_continue != 0) {
tbl = map->id2bl(ud->target);