diff options
-rw-r--r-- | conf/map/battle/feature.conf | 5 | ||||
-rw-r--r-- | db/constants.conf | 27 | ||||
-rw-r--r-- | doc/constants.md | 28 | ||||
-rw-r--r-- | doc/script_commands.txt | 47 | ||||
-rw-r--r-- | src/map/achievement.c | 6 | ||||
-rw-r--r-- | src/map/battle.c | 1 | ||||
-rw-r--r-- | src/map/battle.h | 2 | ||||
-rw-r--r-- | src/map/pet.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 132 | ||||
-rw-r--r-- | src/map/script.h | 21 | ||||
-rw-r--r-- | src/plugins/sample.c | 9 |
11 files changed, 214 insertions, 66 deletions
diff --git a/conf/map/battle/feature.conf b/conf/map/battle/feature.conf index 1ed94b2a4..c306dd97b 100644 --- a/conf/map/battle/feature.conf +++ b/conf/map/battle/feature.conf @@ -83,4 +83,9 @@ features: { // Attendance End time in the format YearMonthDay feature_attendance_endtime: 20180331 + + // Enable Achievement System + // true: enable (Default) + // false: disable + enable_achievement_system: true } diff --git a/db/constants.conf b/db/constants.conf index 2e379cb14..66e0ef066 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -1483,12 +1483,27 @@ constants_db: { e_panic: 79 e_whisp: 80 - comment__: "petstat" - PET_CLASS: 1 - PET_NAME: 2 - PET_LEVEL: 3 - PET_HUNGRY: 4 - PET_INTIMATE: 5 + comment__: "petstat - deprecated, use *getpetinfo" + PET_CLASS: { + Value: 1 + Deprecated: true + } + PET_NAME: { + Value: 2 + Deprecated: true + } + PET_LEVEL: { + Value: 3 + Deprecated: true + } + PET_HUNGRY: { + Value: 4 + Deprecated: true + } + PET_INTIMATE: { + Value: 5 + Deprecated: true + } comment__: "getmonsterinfo" MOB_NAME: 0 diff --git a/doc/constants.md b/doc/constants.md index 9225ce924..83d248493 100644 --- a/doc/constants.md +++ b/doc/constants.md @@ -1407,13 +1407,13 @@ - `e_panic`: 79 - `e_whisp`: 80 -### petstat +### petstat - deprecated, use *getpetinfo -- `PET_CLASS`: 1 -- `PET_NAME`: 2 -- `PET_LEVEL`: 3 -- `PET_HUNGRY`: 4 -- `PET_INTIMATE`: 5 +- `PET_CLASS`: 1 **(DEPRECATED)** +- `PET_NAME`: 2 **(DEPRECATED)** +- `PET_LEVEL`: 3 **(DEPRECATED)** +- `PET_HUNGRY`: 4 **(DEPRECATED)** +- `PET_INTIMATE`: 5 **(DEPRECATED)** ### getmonsterinfo @@ -4294,6 +4294,22 @@ - `MERCINFO_LEVEL`: 7 - `MERCINFO_GID`: 8 +### getpetinfo options + +- `PETINFO_ID`: 0 +- `PETINFO_CLASS`: 1 +- `PETINFO_NAME`: 2 +- `PETINFO_INTIMACY`: 3 +- `PETINFO_HUNGRY`: 4 +- `PETINFO_RENAME`: 5 +- `PETINFO_GID`: 6 +- `PETINFO_EGGITEM`: 7 +- `PETINFO_FOODITEM`: 8 +- `PETINFO_ACCESSORYITEM`: 9 +- `PETINFO_ACCESSORYFLAG`: 10 +- `PETINFO_EVO_EGGID`: 11 +- `PETINFO_AUTOFEED`: 12 + ### monster skill states - `MSS_ANY`: -1 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 19f189f81..416a84dc7 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3115,6 +3115,7 @@ invoking character has in its inventory, including all the data needed to recreate these items perfectly if they are destroyed. Here's what you get: @inventorylist_id[] - array of item ids. +@inventorylist_idx[] - array of item inventory index. @inventorylist_amount[] - their corresponding item amounts. @inventorylist_equip[] - will return the slot the item is equipped on, if at all. @inventorylist_refine[] - for how much it is refined. @@ -3531,20 +3532,21 @@ Examples : --------------------------------------- -*gettimestr(<format string>, <max length>) +*gettimestr(<format string>, <max length>{, <timestamp>}) This function will return a string containing time data as specified by the format string. -This uses the C function 'strfmtime', which obeys special format +This uses the C function 'strftime', which obeys special format characters. For a full description see, for example, the description of -'strfmtime' at http://www.delorie.com/gnu/docs/glibc/libc_437.html +'strftime' at http://www.delorie.com/gnu/docs/glibc/libc_437.html All the format characters given in there should properly work. Max length is the maximum length of a time string to generate. The example given in Hercules sample scripts works like this: mes(gettimestr("%Y-%m/%d %H:%M:%S", 21)); + mes(gettimestr("%Y-%m/%d %H:%M:%S", 21, getcalendartime(0, 0))); This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'. @@ -3833,26 +3835,34 @@ how many skills a character has. *getpetinfo(<type>) -This function will return pet information for the pet the invoking -character currently has active. Valid types are: +This command will return the currently active pet information of the invoking character. +These fields are associate in 'db/(pre-)re/pet_db.conf'. Valid types are: - 0 - Unique pet ID number as stored by the char server and distinguishing - it from all other pets the characters actually have. This value is - currently useless, at most you can use it to tell pets apart reliably. - 1 - Pet class number as per 'db/pet_db.txt' - will tell you what kind of - a pet it is. - 2 - Pet name. Will return "null" if there's no pet. - 3 - Pet friendly level (intimacy score). 1000 is full loyalty. - 4 - Pet hungry level. 100 is completely full. - 5 - Pet rename flag. 0 means this pet has not been named yet. - -If the invoking player doesn't own a pet, this command will return -"null" for type 2, and return 0 for other types. + PETINFO_ID - Pet Database ID, stored in `pet` table to distinguish from other pets. + PETINFO_CLASS - Pet class ID. (Id field) + PETINFO_NAME - Pet Name, return "null" if there's no active pet. + PETINFO_INTIMACY - Pet Intimacy level. 1000 is full loyalty. + PETINFO_HUNGRY - Pet hungry level. 100 is completely full. + PETINFO_RENAME - Pet rename flag. 0 means this pet has not been named yet. + PETINFO_GID - Pet Game ID + PETINFO_EGGITEM - Pet EggItem + PETINFO_FOODITEM - Pet FoodItem + PETINFO_ACCESSORYITEM - Pet AccessoryItem + PETINFO_ACCESSORYFLAG - return 1 if the pet currently equipping accessory, return 0 otherwise. + PETINFO_EVO_EGGID - Pet Evolve EggID + PETINFO_AUTOFEED - Pet AutoFeed flag. + +If the invoking player doesn't own a pet, this command will +return "null" for type PETINFO_NAME, and return 0 for other types. --------------------------------------- *petstat(<flag>) + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @ /!\ This command is deprecated @ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + Returns current pet status, all are integers except name. Returns 0 or "" if the player doesn't have pets. @@ -3866,6 +3876,9 @@ PET_INTIMATE Example: .@i = petstat(PET_CLASS); +This command is deprecated and it should not be used in new scripts, as it is +likely to be removed at a later time. Please use 'getpetinfo' instead. + --------------------------------------- *getmonsterinfo(<mob ID>, <type>) diff --git a/src/map/achievement.c b/src/map/achievement.c index 057ea29c3..7ab80e183 100644 --- a/src/map/achievement.c +++ b/src/map/achievement.c @@ -301,6 +301,9 @@ static int achievement_validate_type(struct map_session_data *sd, enum achieveme Assert_ret(criteria->goal != 0); + if (battle_config.feature_enable_achievement == 0) + return 0; + if (type == ACH_QUEST) { ShowError("achievement_validate_type: ACH_QUEST is not handled by this function. (use achievement_validate())\n"); return 0; @@ -358,6 +361,9 @@ static bool achievement_validate(struct map_session_data *sd, int aid, unsigned Assert_retr(false, progress > 0); Assert_retr(false, obj_idx < MAX_ACHIEVEMENT_OBJECTIVES); + if (battle_config.feature_enable_achievement == 0) + return false; + if ((ad = achievement->get(aid)) == NULL) { ShowError("achievement_validate: Invalid Achievement %d provided.", aid); return false; diff --git a/src/map/battle.c b/src/map/battle.c index 1b7bf909e..798f50b13 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7414,6 +7414,7 @@ static const struct battle_data { { "min_item_sell_price", &battle_config.min_item_sell_price, 0, 0, INT_MAX, }, { "display_fake_hp_when_dead", &battle_config.display_fake_hp_when_dead, 1, 0, 1, }, { "magicrod_type", &battle_config.magicrod_type, 0, 0, 1, }, + { "features/enable_achievement_system", &battle_config.feature_enable_achievement, 1, 0, 1, }, }; static bool battle_set_value_sub(int index, int value) diff --git a/src/map/battle.h b/src/map/battle.h index c797e665a..7e03f0a8e 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -578,6 +578,8 @@ struct Battle_Config { int display_fake_hp_when_dead; int magicrod_type; + + int feature_enable_achievement; }; /* criteria for battle_config.idletime_critera */ diff --git a/src/map/pet.c b/src/map/pet.c index c9603a76c..e2e4c4690 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -251,7 +251,7 @@ static int pet_hungry(int tid, int64 tick, int id, intptr_t data) pd->pet.hungry--; /* Pet Autofeed */ - if (battle_config.feature_enable_homun_autofeed != 0) { + if (battle_config.feature_enable_pet_autofeed != 0) { if (pd->petDB->autofeed == 1 && pd->pet.autofeed == 1 && pd->pet.hungry <= 25) { pet->food(sd, pd); } diff --git a/src/map/script.c b/src/map/script.c index bba559df8..b20cb44f2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10604,24 +10604,36 @@ static BUILDIN(gettime) return true; } -/*========================================== +/* * GetTimeStr("TimeFMT", Length); - *------------------------------------------*/ + */ static BUILDIN(gettimestr) { char *tmpstr; const char *fmtstr; int maxlen; - time_t now = time(NULL); + time_t now; - fmtstr=script_getstr(st,2); - maxlen=script_getnum(st,3); + fmtstr = script_getstr(st, 2); + maxlen = script_getnum(st, 3); - tmpstr=(char *)aMalloc((maxlen+1)*sizeof(char)); - strftime(tmpstr,maxlen,fmtstr,localtime(&now)); - tmpstr[maxlen]='\0'; + if (script_hasdata(st, 4)) { + int timestamp = script_getnum(st, 4); + if (timestamp < 0) { + ShowWarning("buildin_gettimestr: UNIX timestamp must be in positive value.\n"); + return false; + } - script_pushstr(st,tmpstr); + now = (time_t)timestamp; + } else { + now = time(NULL); + } + + tmpstr = (char *)aMalloc((maxlen +1)*sizeof(char)); + strftime(tmpstr, maxlen, fmtstr, localtime(&now)); + tmpstr[maxlen] = '\0'; + + script_pushstr(st, tmpstr); return true; } @@ -14857,6 +14869,7 @@ static BUILDIN(getinventorylist) } pc->setreg(sd,reference_uid(script->add_variable("@inventorylist_expire"), j),sd->status.inventory[i].expire_time); pc->setreg(sd,reference_uid(script->add_variable("@inventorylist_bound"), j),sd->status.inventory[i].bound); + pc->setreg(sd, reference_uid(script->add_variable("@inventorylist_idx"), j), i); j++; } } @@ -15573,36 +15586,74 @@ static BUILDIN(recovery) return true; } -/*========================================== - * Get your pet info: getpetinfo(n) - * n -> 0:pet_id 1:pet_class 2:pet_name - * 3:friendly 4:hungry, 5: rename flag. - *------------------------------------------*/ +/* + * Get your current pet information + */ static BUILDIN(getpetinfo) { struct map_session_data *sd = script->rid2sd(st); - struct pet_data *pd; - int type=script_getnum(st,2); + if (sd == NULL) + return true; - if (sd == NULL || sd->pd == NULL) { - if (type == 2) - script_pushconststr(st,"null"); + struct pet_data *pd = sd->pd; + int type = script_getnum(st, 2); + if (pd == NULL) { + if (type == PETINFO_NAME) + script_pushconststr(st, "null"); else - script_pushint(st,0); + script_pushint(st, 0); return true; } - pd = sd->pd; + switch(type) { - case 0: script_pushint(st,pd->pet.pet_id); break; - case 1: script_pushint(st,pd->pet.class_); break; - case 2: script_pushstrcopy(st,pd->pet.name); break; - case 3: script_pushint(st,pd->pet.intimate); break; - case 4: script_pushint(st,pd->pet.hungry); break; - case 5: script_pushint(st,pd->pet.rename_flag); break; - default: - script_pushint(st,0); - break; + case PETINFO_ID: + script_pushint(st, pd->pet.pet_id); + break; + case PETINFO_CLASS: + script_pushint(st, pd->pet.class_); + break; + case PETINFO_NAME: + script_pushstrcopy(st, pd->pet.name); + break; + case PETINFO_INTIMACY: + script_pushint(st, pd->pet.intimate); + break; + case PETINFO_HUNGRY: + script_pushint(st, pd->pet.hungry); + break; + case PETINFO_RENAME: + script_pushint(st, pd->pet.rename_flag); + break; + case PETINFO_GID: + script_pushint(st, pd->bl.id); + break; + case PETINFO_EGGITEM: + script_pushint(st, pd->pet.egg_id); + break; + case PETINFO_FOODITEM: + script_pushint(st, pd->petDB->FoodID); + break; + case PETINFO_ACCESSORYITEM: + script_pushint(st, pd->petDB->AcceID); + break; + case PETINFO_ACCESSORYFLAG: + script_pushint(st, (pd->pet.equip != 0)? 1:0); + break; + case PETINFO_EVO_EGGID: + if (VECTOR_DATA(pd->petDB->evolve_data) != NULL) + script_pushint(st, VECTOR_DATA(pd->petDB->evolve_data)->petEggId); + else + script_pushint(st, 0); + break; + case PETINFO_AUTOFEED: + script_pushint(st, pd->pet.autofeed); + break; + default: + ShowWarning("buildin_getpetinfo: Invalid type %d.\n", type); + script_pushint(st, 0); + return false; } + return true; } @@ -18926,6 +18977,8 @@ static BUILDIN(setunitdata) break; case UDT_LEVEL: md->level = val; + if (battle_config.show_mob_info & 4) + clif->charnameack(0, &md->bl); break; case UDT_HP: status->set_hp(bl, (unsigned int) val, STATUS_HEAL_DEFAULT); @@ -25378,7 +25431,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(savepoint,"sii"), BUILDIN_DEF(gettimetick,"i"), BUILDIN_DEF(gettime,"i"), - BUILDIN_DEF(gettimestr,"si"), + BUILDIN_DEF(gettimestr, "si?"), BUILDIN_DEF(openstorage,""), BUILDIN_DEF(guildopenstorage,""), BUILDIN_DEF(itemskill,"vi?"), @@ -25598,7 +25651,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getd,"s"), BUILDIN_DEF(setd,"sv"), // <--- [zBuffer] List of dynamic var commands - BUILDIN_DEF(petstat,"i"), + BUILDIN_DEF_DEPRECATED(petstat, "i"), // Deprecated 2019-03-11 BUILDIN_DEF(callshop,"s?"), // [Skotlex] BUILDIN_DEF(npcshopitem,"sii*"), // [Lance] BUILDIN_DEF(npcshopadditem,"sii*"), @@ -26182,6 +26235,21 @@ static void script_hardcoded_constants(void) script->set_constant("MERCINFO_LEVEL", MERCINFO_LEVEL, false, false); script->set_constant("MERCINFO_GID", MERCINFO_GID, false, false); + script->constdb_comment("getpetinfo options"); + script->set_constant("PETINFO_ID", PETINFO_ID, false, false); + script->set_constant("PETINFO_CLASS", PETINFO_CLASS, false, false); + script->set_constant("PETINFO_NAME", PETINFO_NAME, false, false); + script->set_constant("PETINFO_INTIMACY", PETINFO_INTIMACY, false, false); + script->set_constant("PETINFO_HUNGRY", PETINFO_HUNGRY, false, false); + script->set_constant("PETINFO_RENAME", PETINFO_RENAME, false, false); + script->set_constant("PETINFO_GID", PETINFO_GID, false, false); + script->set_constant("PETINFO_EGGITEM", PETINFO_EGGITEM, false, false); + script->set_constant("PETINFO_FOODITEM", PETINFO_FOODITEM, false, false); + script->set_constant("PETINFO_ACCESSORYITEM", PETINFO_ACCESSORYITEM, false, false); + script->set_constant("PETINFO_ACCESSORYFLAG", PETINFO_ACCESSORYFLAG, false, false); + script->set_constant("PETINFO_EVO_EGGID", PETINFO_EVO_EGGID, false, false); + script->set_constant("PETINFO_AUTOFEED", PETINFO_AUTOFEED, false, false); + script->constdb_comment("monster skill states"); script->set_constant("MSS_ANY", MSS_ANY, false, false); script->set_constant("MSS_IDLE", MSS_IDLE, false, false); diff --git a/src/map/script.h b/src/map/script.h index 54c5aad2a..008da9c3c 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -478,6 +478,27 @@ enum script_mercinfo_types { }; /** + * Pet Info types. + */ +enum script_petinfo_types { + PETINFO_ID = 0, + PETINFO_CLASS, + PETINFO_NAME, + PETINFO_INTIMACY, + PETINFO_HUNGRY, + PETINFO_RENAME, + PETINFO_GID, + PETINFO_EGGITEM, + PETINFO_FOODITEM, + PETINFO_ACCESSORYITEM, + PETINFO_ACCESSORYFLAG, + PETINFO_EVO_EGGID, + PETINFO_AUTOFEED, + + PETINFO_MAX +}; + +/** * Player blocking actions related flags. */ enum pcblock_action_flag { diff --git a/src/plugins/sample.c b/src/plugins/sample.c index b37f7c4f7..7ad6794b3 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -23,6 +23,7 @@ #include "common/hercules.h" /* Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces) */ #include "common/memmgr.h" #include "common/mmo.h" +#include "common/random.h" #include "common/socket.h" #include "common/strlib.h" #include "map/clif.h" @@ -79,13 +80,13 @@ void sample_packet0f3(int fd) { data->lastMSGPosition.map = sd->status.last_point.map; data->lastMSGPosition.x = sd->status.last_point.x; data->lastMSGPosition.y = sd->status.last_point.y; - data->someNumber = rand()%777; + data->someNumber = rnd()%777; ShowInfo("Created Appended sockt->session[] data, %d %d %d %u\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); addToSession(sockt->session[fd],data,0,true); } else { ShowInfo("Existent Appended sockt->session[] data, %d %d %d %u\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); - if( rand()%4 == 2 ) { + if (rnd()%4 == 2) { ShowInfo("Removing Appended sockt->session[] data\n"); removeFromSession(sockt->session[fd],0); } @@ -98,13 +99,13 @@ void sample_packet0f3(int fd) { data->lastMSGPosition.map = sd->status.last_point.map; data->lastMSGPosition.x = sd->status.last_point.x; data->lastMSGPosition.y = sd->status.last_point.y; - data->someNumber = rand()%777; + data->someNumber = rnd()%777; ShowInfo("Created Appended map_session_data data, %d %d %d %u\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); addToMSD(sd,data,0,true); } else { ShowInfo("Existent Appended map_session_data data, %d %d %d %u\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); - if( rand()%4 == 2 ) { + if (rnd()%4 == 2) { ShowInfo("Removing Appended map_session_data data\n"); removeFromMSD(sd,0); } |