|
@@ -23280,6 +23280,16 @@ BUILDIN_FUNC(achievementadd) {
|
|
return SCRIPT_CMD_FAILURE;
|
|
return SCRIPT_CMD_FAILURE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if( !sd->state.pc_loaded ){
|
|
|
|
+ if( !running_npc_stat_calc_event ){
|
|
|
|
+ ShowError( "buildin_achievementadd: call was too early. Character %s(CID: '%u') was not loaded yet.\n", sd->status.name, sd->status.char_id );
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }else{
|
|
|
|
+ // Simply ignore it on the first call, because the status will be recalculated after loading anyway
|
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (achievement_add(sd, achievement_id))
|
|
if (achievement_add(sd, achievement_id))
|
|
script_pushint(st, true);
|
|
script_pushint(st, true);
|
|
else
|
|
else
|
|
@@ -23307,6 +23317,16 @@ BUILDIN_FUNC(achievementremove) {
|
|
return SCRIPT_CMD_SUCCESS;
|
|
return SCRIPT_CMD_SUCCESS;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if( !sd->state.pc_loaded ){
|
|
|
|
+ if( !running_npc_stat_calc_event ){
|
|
|
|
+ ShowError( "buildin_achievementremove: call was too early. Character %s(CID: '%u') was not loaded yet.\n", sd->status.name, sd->status.char_id );
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }else{
|
|
|
|
+ // Simply ignore it on the first call, because the status will be recalculated after loading anyway
|
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (achievement_remove(sd, achievement_id))
|
|
if (achievement_remove(sd, achievement_id))
|
|
script_pushint(st, true);
|
|
script_pushint(st, true);
|
|
else
|
|
else
|
|
@@ -23327,6 +23347,23 @@ BUILDIN_FUNC(achievementinfo) {
|
|
return SCRIPT_CMD_FAILURE;
|
|
return SCRIPT_CMD_FAILURE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (achievement_search(achievement_id) == &achievement_dummy) {
|
|
|
|
+ ShowWarning("buildin_achievementinfo: Achievement '%d' doesn't exist.\n", achievement_id);
|
|
|
|
+ script_pushint(st, false);
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if( !sd->state.pc_loaded ){
|
|
|
|
+ script_pushint(st, false);
|
|
|
|
+ if( !running_npc_stat_calc_event ){
|
|
|
|
+ ShowError( "buildin_achievementinfo: call was too early. Character %s(CID: '%u') was not loaded yet.\n", sd->status.name, sd->status.char_id );
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }else{
|
|
|
|
+ // Simply ignore it on the first call, because the status will be recalculated after loading anyway
|
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
script_pushint(st, achievement_check_progress(sd, achievement_id, script_getnum(st, 3)));
|
|
script_pushint(st, achievement_check_progress(sd, achievement_id, script_getnum(st, 3)));
|
|
return SCRIPT_CMD_SUCCESS;
|
|
return SCRIPT_CMD_SUCCESS;
|
|
}
|
|
}
|
|
@@ -23350,6 +23387,17 @@ BUILDIN_FUNC(achievementcomplete) {
|
|
return SCRIPT_CMD_FAILURE;
|
|
return SCRIPT_CMD_FAILURE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ if( !sd->state.pc_loaded ){
|
|
|
|
+ if( !running_npc_stat_calc_event ){
|
|
|
|
+ ShowError( "buildin_achievementcomplete: call was too early. Character %s(CID: '%u') was not loaded yet.\n", sd->status.name, sd->status.char_id );
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }else{
|
|
|
|
+ // Simply ignore it on the first call, because the status will be recalculated after loading anyway
|
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
|
|
ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
|
|
if (i == sd->achievement_data.count)
|
|
if (i == sd->achievement_data.count)
|
|
achievement_add(sd, achievement_id);
|
|
achievement_add(sd, achievement_id);
|
|
@@ -23377,6 +23425,17 @@ BUILDIN_FUNC(achievementexists) {
|
|
return SCRIPT_CMD_SUCCESS;
|
|
return SCRIPT_CMD_SUCCESS;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if( !sd->state.pc_loaded ){
|
|
|
|
+ script_pushint(st, false);
|
|
|
|
+ if( !running_npc_stat_calc_event ){
|
|
|
|
+ ShowError( "buildin_achievementexists: call was too early. Character %s(CID: '%u') was not loaded yet.\n", sd->status.name, sd->status.char_id );
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }else{
|
|
|
|
+ // Simply ignore it on the first call, because the status will be recalculated after loading anyway
|
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
|
|
ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
|
|
script_pushint(st, i < sd->achievement_data.count ? true : false);
|
|
script_pushint(st, i < sd->achievement_data.count ? true : false);
|
|
return SCRIPT_CMD_SUCCESS;
|
|
return SCRIPT_CMD_SUCCESS;
|
|
@@ -23405,6 +23464,16 @@ BUILDIN_FUNC(achievementupdate) {
|
|
return SCRIPT_CMD_FAILURE;
|
|
return SCRIPT_CMD_FAILURE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if( !sd->state.pc_loaded ){
|
|
|
|
+ if( !running_npc_stat_calc_event ){
|
|
|
|
+ ShowError( "buildin_achievementupdate: call was too early. Character %s(CID: '%u') was not loaded yet.\n", sd->status.name, sd->status.char_id );
|
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
|
+ }else{
|
|
|
|
+ // Simply ignore it on the first call, because the status will be recalculated after loading anyway
|
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
|
|
ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
|
|
if (i == sd->achievement_data.count)
|
|
if (i == sd->achievement_data.count)
|
|
achievement_add(sd, achievement_id);
|
|
achievement_add(sd, achievement_id);
|