Regarding The Attack Issue Of HIVE Feedback

by ADMIN 44 views

Introduction

In this article, we will discuss the attack issue of HIVE feedback, specifically focusing on the UpdateTownThreat function. This function is responsible for determining the threat level of a town and sending orders to the captains accordingly. However, there is an issue with the current implementation, which results in the captains receiving orders to go home continuously during an attack. We will analyze the code and provide a solution to this problem.

The Issue

The issue lies in the UpdateTownThreat function, specifically in the elseif statement that checks if the town is threatened. When the town is threatened, the function sets town_threatened to true and calls SetCaptainHome to send the captains back to the town. However, when the threat level is turned off, the function does not reset town_threatened to false, resulting in the captains receiving orders to go home continuously.

The Code

Here is the relevant code snippet:

elseif home_town >= 0 then
  set town_threatened = false
  call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(town_loc[home_town]), GetLocationY(town_loc[home_town])) // Return to known home town
  set captain_home = town_loc[home_town]
  set captain_tp = town_can_tp[home_town]
else
  set town_threatened = false
  call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(home_location), GetLocationY(home_location)) // Final fallback, just use start location
  set captain_home = home_location
  set captain_tp = true
endif

As you can see, the town_threatened variable is not reset to false when the threat level is turned off.

The Solution

To fix this issue, we need to add a condition to check if the threat level is turned off before sending the captains back to the town. We can do this by adding an if statement to check if town_threatened is false before calling SetCaptainHome.

Here is the modified code snippet:

elseif home_town >= 0 then
  if town_threatened then
    set town_threatened = false
    call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(town_loc[home_town]), GetLocationY(town_loc[home_town])) // Return to known home town
  endif
  set captain_home = town_loc[home_town]
  set captain_tp = town_can_tp[home_town]
else
  if town_threatened then
    set town_threatened = false
    call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(home_location), GetLocationY(home_location)) // Final fallback, just use start location
  endif
  set captain_home = home_location
  set captain_tp = true
endif

By adding this condition, we ensure that the captains are not sent back to the town unnecessarily when the threat level is turned off.

Conclusion

In conclusion, the attack issue of HIVE feedback is caused by the UpdateTownThreat function not resetting town_threatened to `` when the threat level is turned off. By adding a condition to check if town_threatened is false before calling SetCaptainHome, we can fix this issue and prevent the captains from receiving orders to go home continuously during an attack.

Additional Code

Here is the additional code snippet that demonstrates the issue:

if most_threatened_player_town >= 0 and town_threat[most_threatened_player_town] > accepted_threat_level and town_threat[most_threatened_player_town] <= playerthreat then //and town_threat[most_threatened_town] > (I2R(c_ally_total + 1) / c_enemy_total) * town_threat[most_threatened_enemy_town] then
  set town_threatened = true
  set town_threat_count = 0
  set most_threatened_town = most_threatened_player_town
  set enemy_army = town_threat_army[most_threatened_town]
   call DisplayTimedTextToPlayer(Player(0),0,0,15,message_add+" town send 1")
  if enemy_army >= 0 then
    call CreateDebugTagLocX("town defended send loc ", 10, GetLocationX(army_loc[enemy_army]), GetLocationY(army_loc[enemy_army]), 1.00, 0.80)
    call SetCaptainHome(BOTH_CAPTAINS,GetLocationX(army_loc[enemy_army]), GetLocationY(army_loc[enemy_army]))
  else
    call CreateDebugTagLocX("town defended send loc ", 10, GetLocationX(town_loc[most_threatened_player_town]), GetLocationY(town_loc[most_threatened_player_town]), 1.00, 0.80)
    call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(town_loc[most_threatened_player_town]), GetLocationY(town_loc[most_threatened_player_town]))
  endif
  set captain_home = town_loc[most_threatened_player_town]
  set captain_tp = town_can_tp[most_threatened_player_town]

This code snippet demonstrates the issue by setting town_threatened to true and then calling SetCaptainHome to send the captains back to the town. However, when the threat level is turned off, the function does not reset town_threatened to false, resulting in the captains receiving orders to go home continuously.

Image 1

Image

Image 2

Q: What is the attack issue of HIVE feedback?

A: The attack issue of HIVE feedback is a problem that occurs when the UpdateTownThreat function does not reset town_threatened to false when the threat level is turned off. This results in the captains receiving orders to go home continuously during an attack.

Q: What is the cause of the attack issue?

A: The cause of the attack issue is the UpdateTownThreat function not resetting town_threatened to false when the threat level is turned off. This is because the function does not have a condition to check if the threat level is turned off before sending the captains back to the town.

Q: How can the attack issue be fixed?

A: The attack issue can be fixed by adding a condition to check if town_threatened is false before calling SetCaptainHome. This ensures that the captains are not sent back to the town unnecessarily when the threat level is turned off.

Q: What is the modified code snippet that fixes the attack issue?

A: The modified code snippet that fixes the attack issue is:

elseif home_town >= 0 then
  if town_threatened then
    set town_threatened = false
    call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(town_loc[home_town]), GetLocationY(town_loc[home_town])) // Return to known home town
  endif
  set captain_home = town_loc[home_town]
  set captain_tp = town_can_tp[home_town]
else
  if town_threatened then
    set town_threatened = false
    call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(home_location), GetLocationY(home_location)) // Final fallback, just use start location
  endif
  set captain_home = home_location
  set captain_tp = true
endif

Q: What is the additional code snippet that demonstrates the issue?

A: The additional code snippet that demonstrates the issue is:

if most_threatened_player_town >= 0 and town_threat[most_threatened_player_town] > accepted_threat_level and town_threat[most_threatened_player_town] <= playerthreat then //and town_threat[most_threatened_town] > (I2R(c_ally_total + 1) / c_enemy_total) * town_threat[most_threatened_enemy_town] then
  set town_threatened = true
  set town_threat_count = 0
  set most_threatened_town = most_threatened_player_town
  set enemy_army = town_threat_army[most_threatened_town]
   call DisplayTimedTextToPlayer(Player(0),0,0,15,message_add+" town send 1")
  if enemy_army >= 0 then
    call CreateDebugTagLocX("town defended send loc ", 10, GetLocationX(army_loc[enemy_army]), GetLocationY(army_loc[enemy_army]), 1.00, 0.80)
    callCaptainHome(BOTH_CAPTAINS,GetLocationX(army_loc[enemy_army]), GetLocationY(army_loc[enemy_army]))
  else
    call CreateDebugTagLocX("town defended send loc ", 10, GetLocationX(town_loc[most_threatened_player_town]), GetLocationY(town_loc[most_threatened_player_town]), 1.00, 0.80)
    call SetCaptainHome(BOTH_CAPTAINS, GetLocationX(town_loc[most_threatened_player_town]), GetLocationY(town_loc[most_threatened_player_town]))
  endif
  set captain_home = town_loc[most_threatened_player_town]
  set captain_tp = town_can_tp[most_threatened_player_town]

Q: What are the images that demonstrate the issue?

A: The images that demonstrate the issue are:

  • Image 1: Image
  • Image 2: Image

Q: How can the attack issue be prevented in the future?

A: The attack issue can be prevented in the future by adding a condition to check if town_threatened is false before calling SetCaptainHome. This ensures that the captains are not sent back to the town unnecessarily when the threat level is turned off. Additionally, regular testing and debugging of the code can help identify and fix issues like this before they become a problem.