A few minor bugs fixed in pet system. Tweaked loyalty a bit.
This commit is contained in:
+1
-1
@@ -254,7 +254,7 @@ const int PLAYER_ITEM_BREAK_ROLL_MAX = 200;
|
|||||||
const int PET_START_LOYALTY = 5;
|
const int PET_START_LOYALTY = 5;
|
||||||
const int PET_LOYALTY_HELP_LOSS = 1;
|
const int PET_LOYALTY_HELP_LOSS = 1;
|
||||||
const int PET_LOYALTY_HUNGER_LOSS = 2;
|
const int PET_LOYALTY_HUNGER_LOSS = 2;
|
||||||
const int PET_LOYALTY_ACTION_COST = 1;
|
const int PET_LOYALTY_CALLOUT_COST = 1;
|
||||||
const int PET_LOYALTY_EAT_BONUS = 2;
|
const int PET_LOYALTY_EAT_BONUS = 2;
|
||||||
const int PET_LOYALTY_MAX = 10;
|
const int PET_LOYALTY_MAX = 10;
|
||||||
const int PET_ATTACK_COOLDOWN = 1600; // Same as axe
|
const int PET_ATTACK_COOLDOWN = 1600; // Same as axe
|
||||||
|
|||||||
+28
-9
@@ -7,6 +7,8 @@ string petType = "";
|
|||||||
string petGender = "";
|
string petGender = "";
|
||||||
int petLoyalty = 0;
|
int petLoyalty = 0;
|
||||||
bool petOut = false;
|
bool petOut = false;
|
||||||
|
int petPosition = 0;
|
||||||
|
bool petPositionValid = false;
|
||||||
|
|
||||||
timer petAttackTimer;
|
timer petAttackTimer;
|
||||||
timer petRetrieveTimer;
|
timer petRetrieveTimer;
|
||||||
@@ -223,6 +225,8 @@ void reset_pet_state() {
|
|||||||
petGender = "";
|
petGender = "";
|
||||||
petLoyalty = 0;
|
petLoyalty = 0;
|
||||||
petOut = false;
|
petOut = false;
|
||||||
|
petPosition = 0;
|
||||||
|
petPositionValid = false;
|
||||||
petEventMessages.resize(0);
|
petEventMessages.resize(0);
|
||||||
petEventSounds.resize(0);
|
petEventSounds.resize(0);
|
||||||
petEventPositions.resize(0);
|
petEventPositions.resize(0);
|
||||||
@@ -272,10 +276,15 @@ void check_pet_call_key() {
|
|||||||
if (petOut) {
|
if (petOut) {
|
||||||
petOut = false;
|
petOut = false;
|
||||||
stop_pet_travel();
|
stop_pet_travel();
|
||||||
|
petPositionValid = false;
|
||||||
speak_with_history("Pet called back.", true);
|
speak_with_history("Pet called back.", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
adjust_pet_loyalty(-PET_LOYALTY_CALLOUT_COST);
|
||||||
|
if (!petActive) return;
|
||||||
petOut = true;
|
petOut = true;
|
||||||
|
petPosition = x;
|
||||||
|
petPositionValid = true;
|
||||||
if (file_exists("sounds/pets/call_pet.ogg")) {
|
if (file_exists("sounds/pets/call_pet.ogg")) {
|
||||||
p.play_stationary("sounds/pets/call_pet.ogg", false);
|
p.play_stationary("sounds/pets/call_pet.ogg", false);
|
||||||
}
|
}
|
||||||
@@ -288,6 +297,8 @@ void adopt_pet(const string&in soundPath) {
|
|||||||
petGender = (random(0, 1) == 0) ? "Male" : "Female";
|
petGender = (random(0, 1) == 0) ? "Male" : "Female";
|
||||||
petLoyalty = PET_START_LOYALTY;
|
petLoyalty = PET_START_LOYALTY;
|
||||||
petOut = false;
|
petOut = false;
|
||||||
|
petPosition = 0;
|
||||||
|
petPositionValid = false;
|
||||||
petAttackTimer.restart();
|
petAttackTimer.restart();
|
||||||
petRetrieveTimer.restart();
|
petRetrieveTimer.restart();
|
||||||
petTravelTimer.restart();
|
petTravelTimer.restart();
|
||||||
@@ -306,8 +317,8 @@ void stop_pet_travel() {
|
|||||||
petTravelSoundHandle = -1;
|
petTravelSoundHandle = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_pet_travel_duration_ms(int targetPos) {
|
int get_pet_travel_duration_ms(int startPos, int targetPos) {
|
||||||
int distance = abs(targetPos - x);
|
int distance = abs(targetPos - startPos);
|
||||||
int duration = distance * PET_MOVE_SPEED;
|
int duration = distance * PET_MOVE_SPEED;
|
||||||
if (duration < PET_TRAVEL_MIN_MS) duration = PET_TRAVEL_MIN_MS;
|
if (duration < PET_TRAVEL_MIN_MS) duration = PET_TRAVEL_MIN_MS;
|
||||||
return duration;
|
return duration;
|
||||||
@@ -317,11 +328,11 @@ void start_pet_travel_attack(int targetPos, const string&in targetLabel, int tar
|
|||||||
stop_pet_travel();
|
stop_pet_travel();
|
||||||
petTravelActive = true;
|
petTravelActive = true;
|
||||||
petTravelAction = PET_TRAVEL_ATTACK;
|
petTravelAction = PET_TRAVEL_ATTACK;
|
||||||
petTravelStartPos = x;
|
petTravelStartPos = petPositionValid ? petPosition : x;
|
||||||
petTravelTargetPos = targetPos;
|
petTravelTargetPos = targetPos;
|
||||||
petTravelTargetLabel = targetLabel;
|
petTravelTargetLabel = targetLabel;
|
||||||
petTravelTargetKind = targetKind;
|
petTravelTargetKind = targetKind;
|
||||||
petTravelDurationMs = get_pet_travel_duration_ms(targetPos);
|
petTravelDurationMs = get_pet_travel_duration_ms(petTravelStartPos, targetPos);
|
||||||
petTravelTimer.restart();
|
petTravelTimer.restart();
|
||||||
|
|
||||||
if (petSoundPath != "" && file_exists(petSoundPath)) {
|
if (petSoundPath != "" && file_exists(petSoundPath)) {
|
||||||
@@ -339,9 +350,9 @@ void start_pet_travel_retrieve(int targetPos) {
|
|||||||
stop_pet_travel();
|
stop_pet_travel();
|
||||||
petTravelActive = true;
|
petTravelActive = true;
|
||||||
petTravelAction = PET_TRAVEL_RETRIEVE;
|
petTravelAction = PET_TRAVEL_RETRIEVE;
|
||||||
petTravelStartPos = x;
|
petTravelStartPos = petPositionValid ? petPosition : x;
|
||||||
petTravelTargetPos = targetPos;
|
petTravelTargetPos = targetPos;
|
||||||
petTravelDurationMs = get_pet_travel_duration_ms(targetPos);
|
petTravelDurationMs = get_pet_travel_duration_ms(petTravelStartPos, targetPos);
|
||||||
petTravelTimer.restart();
|
petTravelTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +388,15 @@ void update_pet_travel() {
|
|||||||
if (hit) {
|
if (hit) {
|
||||||
queue_pet_event("Your " + petType + " attacks the " + petTravelTargetLabel + ".", petTravelTargetPos);
|
queue_pet_event("Your " + petType + " attacks the " + petTravelTargetLabel + ".", petTravelTargetPos);
|
||||||
}
|
}
|
||||||
adjust_pet_loyalty(-PET_LOYALTY_ACTION_COST);
|
petPosition = petTravelTargetPos;
|
||||||
|
petPositionValid = true;
|
||||||
|
int nextTargetPos = -1;
|
||||||
|
string nextTargetLabel = "";
|
||||||
|
int nextTargetKind = -1;
|
||||||
|
if (!find_pet_attack_target(nextTargetPos, nextTargetLabel, nextTargetKind)) {
|
||||||
|
petOut = false;
|
||||||
|
petPositionValid = false;
|
||||||
|
}
|
||||||
} else if (petTravelAction == PET_TRAVEL_RETRIEVE) {
|
} else if (petTravelAction == PET_TRAVEL_RETRIEVE) {
|
||||||
WorldDrop@ drop = get_drop_at(petTravelTargetPos);
|
WorldDrop@ drop = get_drop_at(petTravelTargetPos);
|
||||||
if (drop !is null) {
|
if (drop !is null) {
|
||||||
@@ -386,9 +405,9 @@ void update_pet_travel() {
|
|||||||
remove_drop_at(drop.position);
|
remove_drop_at(drop.position);
|
||||||
queue_pet_event(message);
|
queue_pet_event(message);
|
||||||
petOut = false;
|
petOut = false;
|
||||||
|
petPositionValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adjust_pet_loyalty(-PET_LOYALTY_ACTION_COST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_pet_travel();
|
stop_pet_travel();
|
||||||
@@ -614,8 +633,8 @@ void attempt_pet_random_find() {
|
|||||||
add_personal_count(itemType, added);
|
add_personal_count(itemType, added);
|
||||||
string itemName = (added == 1) ? item_registry[itemType].singular : item_registry[itemType].name;
|
string itemName = (added == 1) ? item_registry[itemType].singular : item_registry[itemType].name;
|
||||||
queue_pet_event("Your " + petType + " retrieved " + added + " " + itemName + ".", x);
|
queue_pet_event("Your " + petType + " retrieved " + added + " " + itemName + ".", x);
|
||||||
adjust_pet_loyalty(-PET_LOYALTY_ACTION_COST);
|
|
||||||
petOut = false;
|
petOut = false;
|
||||||
|
petPositionValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_pet_hourly_update(int hour) {
|
void handle_pet_hourly_update(int hour) {
|
||||||
|
|||||||
Reference in New Issue
Block a user