summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mercenary.c30
-rw-r--r--src/map/mercenary.h12
-rw-r--r--src/map/script.c130
3 files changed, 164 insertions, 8 deletions
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 4775f9beb..84974e906 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -94,6 +94,25 @@ int mercenary_get_lifetime(struct mercenary_data *md)
return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
}
+int mercenary_get_guild(struct mercenary_data *md)
+{
+ int class_;
+
+ if( md == NULL || md->db == NULL )
+ return -1;
+
+ class_ = md->db->class_;
+
+ if( class_ >= 6017 && class_ <= 6026 )
+ return ARCH_MERC_GUILD;
+ if( class_ >= 6027 && class_ <= 6036 )
+ return SPEAR_MERC_GUILD;
+ if( class_ >= 6037 && class_ <= 6046 )
+ return SWORD_MERC_GUILD;
+
+ return -1;
+}
+
int mercenary_get_faith(struct mercenary_data *md)
{
struct map_session_data *sd;
@@ -110,8 +129,6 @@ int mercenary_get_faith(struct mercenary_data *md)
return sd->status.spear_faith;
if( class_ >= 6037 && class_ <= 6046 )
return sd->status.sword_faith;
- else
- return 0;
return 0;
}
@@ -158,8 +175,6 @@ int mercenary_get_calls(struct mercenary_data *md)
return sd->status.spear_calls;
if( class_ >= 6037 && class_ <= 6046 )
return sd->status.sword_calls;
- else
- return 0;
return 0;
}
@@ -231,6 +246,12 @@ int merc_delete(struct mercenary_data *md, int reply)
if( !sd )
return unit_free(&md->bl, 0);
+ if( md->devotion_flag )
+ {
+ md->devotion_flag = 0;
+ status_change_end(&sd->bl, SC_DEVOTION, -1);
+ }
+
switch( reply )
{
case 0: mercenary_set_faith(md, 1); break; // +1 Loyalty on Contract ends.
@@ -278,6 +299,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag)
sd->md = md = (struct mercenary_data*)aCalloc(1,sizeof(struct mercenary_data));
md->bl.type = BL_MER;
md->bl.id = npc_get_new_npc_id();
+ md->devotion_flag = 0;
md->master = sd;
md->db = db;
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index 826133660..1cc689208 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -7,6 +7,12 @@
#include "status.h" // struct status_data, struct status_change
#include "unit.h" // struct unit_data
+enum {
+ ARCH_MERC_GUILD,
+ SPEAR_MERC_GUILD,
+ SWORD_MERC_GUILD,
+};
+
struct s_mercenary_db {
int class_;
char sprite[NAME_LENGTH], name[NAME_LENGTH];
@@ -31,11 +37,12 @@ struct mercenary_data {
struct s_mercenary_db *db;
struct s_mercenary mercenary;
+ char blockskill[MAX_SKILL];
struct map_session_data *master;
int contract_timer;
-
- char blockskill[MAX_SKILL];
+
+ unsigned devotion_flag : 1;
};
bool merc_class(int class_);
@@ -53,6 +60,7 @@ int merc_delete(struct mercenary_data *md, int reply);
void merc_contract_stop(struct mercenary_data *md);
int mercenary_get_lifetime(struct mercenary_data *md);
+int mercenary_get_guild(struct mercenary_data *md);
int mercenary_get_faith(struct mercenary_data *md);
int mercenary_set_faith(struct mercenary_data *md, int value);
int mercenary_get_calls(struct mercenary_data *md);
diff --git a/src/map/script.c b/src/map/script.c
index d2a77036b..dc1a0fa6d 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -12810,7 +12810,7 @@ BUILDIN_FUNC(setcell)
/*==========================================
* Mercenary Commands
*------------------------------------------*/
-BUILDIN_FUNC(createmercenary)
+BUILDIN_FUNC(mercenary_create)
{
struct map_session_data *sd;
int class_, contract_time;
@@ -12860,6 +12860,128 @@ BUILDIN_FUNC(mercenary_sc_start)
return 0;
}
+BUILDIN_FUNC(mercenary_get_calls)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+ int guild;
+
+ if( sd == NULL )
+ return 0;
+
+ guild = script_getnum(st,2);
+ switch( guild )
+ {
+ case ARCH_MERC_GUILD:
+ script_pushint(st,sd->status.arch_calls);
+ break;
+ case SPEAR_MERC_GUILD:
+ script_pushint(st,sd->status.spear_calls);
+ break;
+ case SWORD_MERC_GUILD:
+ script_pushint(st,sd->status.sword_calls);
+ break;
+ default:
+ script_pushint(st,0);
+ break;
+ }
+
+ return 0;
+}
+
+BUILDIN_FUNC(mercenary_set_calls)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+ int guild, value, *calls;
+
+ if( sd == NULL )
+ return 0;
+
+ guild = script_getnum(st,2);
+ value = script_getnum(st,3);
+
+ switch( guild )
+ {
+ case ARCH_MERC_GUILD:
+ calls = &sd->status.arch_calls;
+ break;
+ case SPEAR_MERC_GUILD:
+ calls = &sd->status.spear_calls;
+ break;
+ case SWORD_MERC_GUILD:
+ calls = &sd->status.sword_calls;
+ break;
+ default:
+ return 0; // Invalid Guild
+ }
+
+ *calls += value;
+ *calls = cap_value(*calls, 0, INT_MAX);
+
+ return 0;
+}
+
+BUILDIN_FUNC(mercenary_get_faith)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+ int guild;
+
+ if( sd == NULL )
+ return 0;
+
+ guild = script_getnum(st,2);
+ switch( guild )
+ {
+ case ARCH_MERC_GUILD:
+ script_pushint(st,sd->status.arch_faith);
+ break;
+ case SPEAR_MERC_GUILD:
+ script_pushint(st,sd->status.spear_faith);
+ break;
+ case SWORD_MERC_GUILD:
+ script_pushint(st,sd->status.sword_faith);
+ break;
+ default:
+ script_pushint(st,0);
+ break;
+ }
+
+ return 0;
+}
+
+BUILDIN_FUNC(mercenary_set_faith)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+ int guild, value, *calls;
+
+ if( sd == NULL )
+ return 0;
+
+ guild = script_getnum(st,2);
+ value = script_getnum(st,3);
+
+ switch( guild )
+ {
+ case ARCH_MERC_GUILD:
+ calls = &sd->status.arch_faith;
+ break;
+ case SPEAR_MERC_GUILD:
+ calls = &sd->status.spear_faith;
+ break;
+ case SWORD_MERC_GUILD:
+ calls = &sd->status.sword_faith;
+ break;
+ default:
+ return 0; // Invalid Guild
+ }
+
+ *calls += value;
+ *calls = cap_value(*calls, 0, INT_MAX);
+ if( mercenary_get_guild(sd->md) == guild )
+ clif_mercenary_updatestatus(sd,SP_MERCFAITH);
+
+ return 0;
+}
+
/******************
Questlog script commands
*******************/
@@ -13290,8 +13412,12 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(hasquest, "i"),
BUILDIN_DEF(setwall,"siiiiis"),
BUILDIN_DEF(delwall,"s"),
- BUILDIN_DEF(createmercenary,"ii"),
+ BUILDIN_DEF(mercenary_create,"ii"),
BUILDIN_DEF(mercenary_heal,"ii"),
BUILDIN_DEF(mercenary_sc_start,"iii"),
+ BUILDIN_DEF(mercenary_get_calls,"i"),
+ BUILDIN_DEF(mercenary_get_faith,"i"),
+ BUILDIN_DEF(mercenary_set_calls,"ii"),
+ BUILDIN_DEF(mercenary_set_faith,"ii"),
{NULL,NULL,NULL},
};