-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simplify and clarify calculate_monster_score calculations #151
Open
earthiverse
wants to merge
3
commits into
kaansoral:main
Choose a base branch
from
earthiverse:calculate-score
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+37
−44
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2297,59 +2297,52 @@ function monster_hunt_logic(player, monster) { | |
} | ||
} | ||
|
||
function calculate_monster_score(player, monster, share) { | ||
var score = min(1, monster.mult * 2.2); | ||
var divider = 1; | ||
if (!share) { | ||
share = 0; | ||
} | ||
if (monster.cooperative) { | ||
divider = 2; | ||
} | ||
for (var id in players) { | ||
var current = players[id]; | ||
if (current.id == player.id) { | ||
continue; | ||
function calculate_monster_score(player, monster, coopShare = 0) { | ||
// NOTE: `.mult` is usually 1, but will be set on server shutdown to the ratio of remaining HP. | ||
// See: shutdown_routine() | ||
let score = Math.min(1, monster.mult * 2.2); | ||
const divisor = monster.cooperative ? 2 : 1; | ||
|
||
for (const id in players) { | ||
const p = players[id]; | ||
if (p.id === player.id) { | ||
continue; // Skip ourself | ||
} | ||
if (current.owner == player.owner && current.type == "merchant" && simple_distance(current, player) < 600) { | ||
score -= 0.2 / divider; | ||
|
||
const sameOwner = p.owner === player.owner; | ||
const sameParty = p.party && p.party === player.party; | ||
if (!sameOwner && !sameParty) { | ||
continue; // Not our character, and in a different party | ||
} | ||
|
||
const isMerchant = p.type === "merchant"; | ||
if (sameOwner && sameParty && !isMerchant) { | ||
score += 0.3 / divisor; // +0.3 points for each additional non-merchant character of ours in our party (even if they are far away) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Old lines 2330 & 2337 |
||
} | ||
|
||
if (isMerchant && simple_distance(p, player) <= 600) { | ||
// Nearby merchants reduce the points | ||
if (sameOwner) { | ||
score -= 0.2 / divisor; // Deduct points if our merchant is nearby | ||
} | ||
if (sameParty) { | ||
score -= 0.1 / divisor; // Deduct points if a merchant in our party is nearby | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Old line 2323 |
||
} | ||
} | ||
if ( | ||
current.party && | ||
current.party == player.party && | ||
current.type == "merchant" && | ||
simple_distance(current, player) < 600 | ||
) { | ||
score -= 0.1 / divider; | ||
} else if ( | ||
current.owner == player.owner && | ||
current.party == player.party && | ||
simple_distance(current, player) < 600 && | ||
current.type != "merchant" | ||
) { | ||
score += 0.3 / divider; | ||
} else if ( | ||
current.owner == player.owner && | ||
current.party && | ||
current.party == player.party && | ||
current.type != "merchant" | ||
) { | ||
score += 0.3 / divider; | ||
} // originally 0.25 | ||
} | ||
if (simple_distance(player, monster) > 600 && share < 0.01) { | ||
score -= 0.3 / divider; | ||
|
||
if (simple_distance(player, monster) > 600 && coopShare < 0.01) { | ||
score -= 0.3 / divisor; // Deduct points if we were far away from the kill, unless it was a coop monster and we contributed | ||
} | ||
if (player.type == "merchant" && player.party) { | ||
score /= 2; | ||
} | ||
if (score < 0) { | ||
score = 0; | ||
// TODO: What if the merchant killed the monster with a golden gun? Should it not get full points then? | ||
score /= 2; // Half points if we're a merchant in a party | ||
} | ||
if (gameplay == "hardcore") { | ||
score *= 10000; | ||
} | ||
return score; | ||
|
||
return Math.max(0, score); | ||
} | ||
|
||
function issue_monster_awards(monster) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could skip the get call on
id
of p and just useid
directly given by the for loopThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/earthiverse/adventureland/blob/2f6b1484405f20b086fe813926b01327eca61034/node/server.js#L9674
It might be a different ID?