Skip to content

Commit

Permalink
Add proximity cooldown for sardines tin entering
Browse files Browse the repository at this point in the history
  • Loading branch information
Amethyst-szs authored and Sanae6 committed Jan 4, 2025
1 parent b425364 commit 8dd95f7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
9 changes: 4 additions & 5 deletions include/server/gamemode/GameModeTimer.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#pragma once

#include <format>
#include <string>
#include "sead/prim/seadSafeString.h"

struct GameTime {
float mMilliseconds = 0;
int mSeconds = 0;
int mMinutes = 0;
int mHours = 0;

const std::string to_string() {
const sead::SafeString to_string() {
if (mHours > 0) {
return std::format("{:01}:{:02}:{:02}", mHours, mMinutes, mSeconds);
return sead::FormatFixedSafeString<0x20>("%01d:%02d:%02d", mHours, mMinutes, mSeconds);
}
return std::format("{:02}:{:02}", mMinutes, mSeconds);
return sead::FormatFixedSafeString<0x20>("%02d:%02d", mMinutes, mSeconds);
}
};

Expand Down
3 changes: 3 additions & 0 deletions include/server/sardines/SardineMode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ class SardineMode : public GameModeBase {
float pullDistanceMinSq = 1000000.f;
float pullPowerRate = 75.f;

int mSardineToggleCooldown = 0;
const int mSardineToggleCooldownLength = 600;

void updateTagState(bool isIt);
};
2 changes: 1 addition & 1 deletion source/server/hns/HideAndSeekIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void HideAndSeekIcon::exeWait() {
al::startAction(this, "Wait", 0);
}

al::setPaneStringFormat(this, "TxtCounter", mInfo->mHidingTime.to_string().c_str());
al::setPaneStringFormat(this, "TxtCounter", mInfo->mHidingTime.to_string().cstr());

auto playerList = getPlayerList();
if (!playerList.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion source/server/sardines/SardineIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void SardineIcon::exeWait() {
al::startAction(this, "Wait", 0);
}

al::setPaneStringFormat(this, "TxtCounter", mInfo->mHidingTime.to_string().c_str());
al::setPaneStringFormat(this, "TxtCounter", mInfo->mHidingTime.to_string().cstr());

auto playerList = getPlayerList();
if (!playerList.isEmpty()) {
Expand Down
5 changes: 5 additions & 0 deletions source/server/sardines/SardineMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void SardineMode::update() {
float closestDistanceSq = 0.f;

bool isPackEmpty = true;

if (mSardineToggleCooldown > 0)
mSardineToggleCooldown--;

if (mIsFirstFrame) {
if (mInfo->mIsUseGravityCam && mTicket) {
Expand Down Expand Up @@ -191,10 +194,12 @@ void SardineMode::update() {
if ( isPlayerAlone() // we're a single sardine
&& other->is2D == ((PlayerActorHakoniwa*)playerBase)->mDimKeeper->is2DModel // we are in the same dimension
&& !PlayerFunction::isPlayerDeadStatus(playerBase) // we're not dead
&& mSardineToggleCooldown == 0 // cooldown isn't active
) {
// in range?
float distanceSq = vecDistanceSq(playerPos, other->playerPos);
if (distanceSq < 90000.0f) { // non-squared: 300.0
mSardineToggleCooldown = mSardineToggleCooldownLength;
updateTagState(true);
break;
}
Expand Down

0 comments on commit 8dd95f7

Please sign in to comment.