Added SetLife and ChangeLife lua functions to Player. Updated changelog.
This commit is contained in:
@@ -4,6 +4,18 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
|
|||||||
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
|
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
2015/12/16
|
||||||
|
----------
|
||||||
|
* [Player] ChangeLife and SetLife functions added. [kyzentun]
|
||||||
|
|
||||||
|
2015/12/13
|
||||||
|
----------
|
||||||
|
* [popn] Judgment levels in popn game mode now use W1 to W5. [parashep]
|
||||||
|
|
||||||
|
2015/12/05
|
||||||
|
----------
|
||||||
|
* [Player] Guitar mode cruft removed from Player. [tertu]
|
||||||
|
|
||||||
2015/12/04
|
2015/12/04
|
||||||
----------
|
----------
|
||||||
* [NoteField] Changed DrawBeatBar to check the M-mod so that smaller beat
|
* [NoteField] Changed DrawBeatBar to check the M-mod so that smaller beat
|
||||||
|
|||||||
@@ -1096,6 +1096,8 @@
|
|||||||
<Function name='LoadFromStats'/>
|
<Function name='LoadFromStats'/>
|
||||||
</Class>
|
</Class>
|
||||||
<Class base='ActorFrame' name='Player'>
|
<Class base='ActorFrame' name='Player'>
|
||||||
|
<Function name='ChangeLife'/>
|
||||||
|
<Function name='SetLife'/>
|
||||||
<Function name='GetPlayerTimingData'/>
|
<Function name='GetPlayerTimingData'/>
|
||||||
<Function name='SetActorWithComboPosition'/>
|
<Function name='SetActorWithComboPosition'/>
|
||||||
<Function name='SetActorWithJudgmentPosition'/>
|
<Function name='SetActorWithJudgmentPosition'/>
|
||||||
|
|||||||
@@ -3366,6 +3366,12 @@ save yourself some time, copy this for undocumented things:
|
|||||||
</Function>
|
</Function>
|
||||||
</Class>
|
</Class>
|
||||||
<Class name='Player'>
|
<Class name='Player'>
|
||||||
|
<Function name='ChangeLife' return='' arguments='float delta'>
|
||||||
|
Changes the life value by delta. This will broadcast a LifeChangedMessageCommand, to allow custom life bars to update to the new value. Do not call ChangeLife from within LifeChangedMessageCommand.
|
||||||
|
</Function>
|
||||||
|
<Function name='SetLife' return='' arguments='float value'>
|
||||||
|
Sets the life to value. This will broadcast a LifeChangedMessageCommand, to allow custom life bars to update to the new value. Do not call SetLife from within LifeChangedMessageCommand.
|
||||||
|
</Function>
|
||||||
<Function name='GetPlayerTimingData' return='TimingData' arguments=''>
|
<Function name='GetPlayerTimingData' return='TimingData' arguments=''>
|
||||||
Returns the current TimingData for this player.
|
Returns the current TimingData for this player.
|
||||||
</Function>
|
</Function>
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public:
|
|||||||
* @param hns the hold note score recently received.
|
* @param hns the hold note score recently received.
|
||||||
* @param tns the score from the initial TapNote. */
|
* @param tns the score from the initial TapNote. */
|
||||||
virtual void ChangeLife( PlayerNumber pn, HoldNoteScore hns, TapNoteScore tns ) = 0;
|
virtual void ChangeLife( PlayerNumber pn, HoldNoteScore hns, TapNoteScore tns ) = 0;
|
||||||
|
virtual void ChangeLife(PlayerNumber pn, float delta) = 0;
|
||||||
|
virtual void SetLife(PlayerNumber pn, float value) = 0;
|
||||||
virtual void HandleTapScoreNone( PlayerNumber pn ) = 0;
|
virtual void HandleTapScoreNone( PlayerNumber pn ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,21 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, float fPercentToMove )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CombinedLifeMeterTug::SetLife(PlayerNumber pn, float value)
|
||||||
|
{
|
||||||
|
switch(pn)
|
||||||
|
{
|
||||||
|
case PLAYER_1:
|
||||||
|
GAMESTATE->m_fTugLifePercentP1= value;
|
||||||
|
break;
|
||||||
|
case PLAYER_2:
|
||||||
|
GAMESTATE->m_fTugLifePercentP1= 1-value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FAIL_M(ssprintf("Invalid player number: %i", pn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ public:
|
|||||||
|
|
||||||
virtual void ChangeLife( PlayerNumber pn, TapNoteScore score );
|
virtual void ChangeLife( PlayerNumber pn, TapNoteScore score );
|
||||||
virtual void ChangeLife( PlayerNumber pn, HoldNoteScore score, TapNoteScore tscore );
|
virtual void ChangeLife( PlayerNumber pn, HoldNoteScore score, TapNoteScore tscore );
|
||||||
|
virtual void ChangeLife( PlayerNumber pn, float fPercentToMove );
|
||||||
|
virtual void SetLife(PlayerNumber pn, float value);
|
||||||
virtual void HandleTapScoreNone( PlayerNumber pn );
|
virtual void HandleTapScoreNone( PlayerNumber pn );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ChangeLife( PlayerNumber pn, float fPercentToMove );
|
|
||||||
|
|
||||||
MeterDisplay m_Stream[NUM_PLAYERS];
|
MeterDisplay m_Stream[NUM_PLAYERS];
|
||||||
AutoActor m_sprSeparator;
|
AutoActor m_sprSeparator;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public:
|
|||||||
* @param hns the hold note grade in question.
|
* @param hns the hold note grade in question.
|
||||||
* @param tns the score received for the initial tap note. */
|
* @param tns the score received for the initial tap note. */
|
||||||
virtual void ChangeLife( HoldNoteScore hns, TapNoteScore tns ) = 0;
|
virtual void ChangeLife( HoldNoteScore hns, TapNoteScore tns ) = 0;
|
||||||
|
virtual void ChangeLife(float delta) = 0;
|
||||||
|
virtual void SetLife(float value) = 0;
|
||||||
virtual void HandleTapScoreNone() = 0;
|
virtual void HandleTapScoreNone() = 0;
|
||||||
virtual bool IsInDanger() const = 0;
|
virtual bool IsInDanger() const = 0;
|
||||||
virtual bool IsHot() const = 0;
|
virtual bool IsHot() const = 0;
|
||||||
|
|||||||
@@ -249,6 +249,13 @@ void LifeMeterBar::ChangeLife( float fDeltaLife )
|
|||||||
AfterLifeChanged();
|
AfterLifeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LifeMeterBar::SetLife(float value)
|
||||||
|
{
|
||||||
|
m_fLifePercentage= value;
|
||||||
|
CLAMP( m_fLifePercentage, 0, LIFE_MULTIPLIER );
|
||||||
|
AfterLifeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
extern ThemeMetric<bool> PENALIZE_TAP_SCORE_NONE;
|
extern ThemeMetric<bool> PENALIZE_TAP_SCORE_NONE;
|
||||||
void LifeMeterBar::HandleTapScoreNone()
|
void LifeMeterBar::HandleTapScoreNone()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
virtual void ChangeLife( TapNoteScore score );
|
virtual void ChangeLife( TapNoteScore score );
|
||||||
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
|
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
|
||||||
virtual void ChangeLife( float fDeltaLifePercent );
|
virtual void ChangeLife( float fDeltaLifePercent );
|
||||||
|
virtual void SetLife(float value);
|
||||||
virtual void HandleTapScoreNone();
|
virtual void HandleTapScoreNone();
|
||||||
virtual void AfterLifeChanged();
|
virtual void AfterLifeChanged();
|
||||||
virtual bool IsInDanger() const;
|
virtual bool IsInDanger() const;
|
||||||
|
|||||||
+19
-13
@@ -169,13 +169,7 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score )
|
|||||||
bSubtract = true;
|
bSubtract = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BroadcastLifeChanged(bSubtract);
|
||||||
Message msg( "LifeChanged" );
|
|
||||||
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
|
|
||||||
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
|
|
||||||
msg.SetParam( "LivesLeft", GetLivesLeft() );
|
|
||||||
msg.SetParam( "LostLife", bSubtract );
|
|
||||||
MESSAGEMAN->Broadcast( msg );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
|
void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
|
||||||
@@ -191,13 +185,25 @@ void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
|
|||||||
SubtractLives(LET_GO_SUBTRACT_LIVES);
|
SubtractLives(LET_GO_SUBTRACT_LIVES);
|
||||||
bSubtract = true;
|
bSubtract = true;
|
||||||
}
|
}
|
||||||
|
BroadcastLifeChanged(bSubtract);
|
||||||
|
}
|
||||||
|
|
||||||
Message msg( "LifeChanged" );
|
void LifeMeterBattery::SetLife(float value)
|
||||||
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
|
{
|
||||||
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
|
int new_lives= static_cast<int>(value);
|
||||||
msg.SetParam( "LivesLeft", GetLivesLeft() );
|
bool lost= (new_lives < m_iLivesLeft);
|
||||||
msg.SetParam( "LostLife", bSubtract );
|
m_iLivesLeft= new_lives;
|
||||||
MESSAGEMAN->Broadcast( msg );
|
BroadcastLifeChanged(lost);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LifeMeterBattery::BroadcastLifeChanged(bool lost_life)
|
||||||
|
{
|
||||||
|
Message msg("LifeChanged");
|
||||||
|
msg.SetParam("Player", m_pPlayerState->m_PlayerNumber);
|
||||||
|
msg.SetParam("LifeMeter", LuaReference::CreateFromPush(*this));
|
||||||
|
msg.SetParam("LivesLeft", GetLivesLeft());
|
||||||
|
msg.SetParam("LostLife", lost_life);
|
||||||
|
MESSAGEMAN->Broadcast(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LifeMeterBattery::HandleTapScoreNone()
|
void LifeMeterBattery::HandleTapScoreNone()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
virtual void ChangeLife( TapNoteScore score );
|
virtual void ChangeLife( TapNoteScore score );
|
||||||
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
|
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
|
||||||
virtual void ChangeLife( float fDeltaLifePercent );
|
virtual void ChangeLife( float fDeltaLifePercent );
|
||||||
|
virtual void SetLife(float value);
|
||||||
virtual void HandleTapScoreNone();
|
virtual void HandleTapScoreNone();
|
||||||
virtual bool IsInDanger() const;
|
virtual bool IsInDanger() const;
|
||||||
virtual bool IsHot() const;
|
virtual bool IsHot() const;
|
||||||
@@ -30,6 +31,8 @@ public:
|
|||||||
virtual float GetLife() const;
|
virtual float GetLife() const;
|
||||||
virtual int GetRemainingLives() const;
|
virtual int GetRemainingLives() const;
|
||||||
|
|
||||||
|
virtual void BroadcastLifeChanged(bool lost_life);
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
int GetLivesLeft() { return m_iLivesLeft; }
|
int GetLivesLeft() { return m_iLivesLeft; }
|
||||||
int GetTotalLives();
|
int GetTotalLives();
|
||||||
|
|||||||
@@ -178,6 +178,20 @@ void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
|
|||||||
SendLifeChangedMessage( fOldLife, tns, hns );
|
SendLifeChangedMessage( fOldLife, tns, hns );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LifeMeterTime::ChangeLife(float delta)
|
||||||
|
{
|
||||||
|
float old_life= m_fLifeTotalLostSeconds;
|
||||||
|
m_fLifeTotalLostSeconds-= delta;
|
||||||
|
SendLifeChangedMessage(old_life, TapNoteScore_Invalid, HoldNoteScore_Invalid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LifeMeterTime::SetLife(float value)
|
||||||
|
{
|
||||||
|
float old_life= m_fLifeTotalLostSeconds;
|
||||||
|
m_fLifeTotalLostSeconds= value;
|
||||||
|
SendLifeChangedMessage(old_life, TapNoteScore_Invalid, HoldNoteScore_Invalid);
|
||||||
|
}
|
||||||
|
|
||||||
void LifeMeterTime::HandleTapScoreNone()
|
void LifeMeterTime::HandleTapScoreNone()
|
||||||
{
|
{
|
||||||
// do nothing.
|
// do nothing.
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public:
|
|||||||
virtual void OnLoadSong();
|
virtual void OnLoadSong();
|
||||||
virtual void ChangeLife( TapNoteScore score );
|
virtual void ChangeLife( TapNoteScore score );
|
||||||
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
|
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
|
||||||
|
virtual void ChangeLife(float delta);
|
||||||
|
virtual void SetLife(float value);
|
||||||
virtual void HandleTapScoreNone();
|
virtual void HandleTapScoreNone();
|
||||||
virtual bool IsInDanger() const;
|
virtual bool IsInDanger() const;
|
||||||
virtual bool IsHot() const;
|
virtual bool IsHot() const;
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ Player::Player( NoteData &nd, bool bVisibleParts ) : m_NoteData(nd)
|
|||||||
{
|
{
|
||||||
m_drawing_notefield_board= false;
|
m_drawing_notefield_board= false;
|
||||||
m_bLoaded = false;
|
m_bLoaded = false;
|
||||||
|
m_inside_lua_set_life= false;
|
||||||
|
|
||||||
m_pPlayerState = NULL;
|
m_pPlayerState = NULL;
|
||||||
m_pPlayerStageStats = NULL;
|
m_pPlayerStageStats = NULL;
|
||||||
@@ -1684,6 +1685,44 @@ void Player::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
|
|||||||
ChangeLifeRecord();
|
ChangeLifeRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::ChangeLife(float delta)
|
||||||
|
{
|
||||||
|
// If ChangeLifeRecord is not called before the change, then the life graph
|
||||||
|
// will show a gradual change from the time of the previous step (or
|
||||||
|
// change) to the time of this change, instead of the sharp change that
|
||||||
|
// actually occurred. -Kyz
|
||||||
|
ChangeLifeRecord();
|
||||||
|
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||||
|
if(m_pLifeMeter)
|
||||||
|
{
|
||||||
|
m_pLifeMeter->ChangeLife(delta);
|
||||||
|
}
|
||||||
|
if(m_pCombinedLifeMeter)
|
||||||
|
{
|
||||||
|
m_pCombinedLifeMeter->ChangeLife(pn, delta);
|
||||||
|
}
|
||||||
|
ChangeLifeRecord();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::SetLife(float value)
|
||||||
|
{
|
||||||
|
// If ChangeLifeRecord is not called before the change, then the life graph
|
||||||
|
// will show a gradual change from the time of the previous step (or
|
||||||
|
// change) to the time of this change, instead of the sharp change that
|
||||||
|
// actually occurred. -Kyz
|
||||||
|
ChangeLifeRecord();
|
||||||
|
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||||
|
if(m_pLifeMeter)
|
||||||
|
{
|
||||||
|
m_pLifeMeter->SetLife(value);
|
||||||
|
}
|
||||||
|
if(m_pCombinedLifeMeter)
|
||||||
|
{
|
||||||
|
m_pCombinedLifeMeter->SetLife(pn, value);
|
||||||
|
}
|
||||||
|
ChangeLifeRecord();
|
||||||
|
}
|
||||||
|
|
||||||
void Player::ChangeLifeRecord()
|
void Player::ChangeLifeRecord()
|
||||||
{
|
{
|
||||||
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||||
@@ -3238,6 +3277,28 @@ RString Player::ApplyRandomAttack()
|
|||||||
class LunaPlayer: public Luna<Player>
|
class LunaPlayer: public Luna<Player>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static int SetLife(T* p, lua_State* L)
|
||||||
|
{
|
||||||
|
if(p->m_inside_lua_set_life)
|
||||||
|
{
|
||||||
|
luaL_error(L, "Do not call SetLife from inside LifeChangedMessageCommand because SetLife causes a LifeChangedMessageCommand.");
|
||||||
|
}
|
||||||
|
p->m_inside_lua_set_life= true;
|
||||||
|
p->SetLife(FArg(1));
|
||||||
|
p->m_inside_lua_set_life= false;
|
||||||
|
COMMON_RETURN_SELF;
|
||||||
|
}
|
||||||
|
static int ChangeLife(T* p, lua_State* L)
|
||||||
|
{
|
||||||
|
if(p->m_inside_lua_set_life)
|
||||||
|
{
|
||||||
|
luaL_error(L, "Do not call ChangeLife from inside LifeChangedMessageCommand because ChangeLife causes a LifeChangedMessageCommand.");
|
||||||
|
}
|
||||||
|
p->m_inside_lua_set_life= true;
|
||||||
|
p->ChangeLife(FArg(1));
|
||||||
|
p->m_inside_lua_set_life= false;
|
||||||
|
COMMON_RETURN_SELF;
|
||||||
|
}
|
||||||
static int SetActorWithJudgmentPosition( T* p, lua_State *L )
|
static int SetActorWithJudgmentPosition( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
Actor *pActor = Luna<Actor>::check(L, 1);
|
Actor *pActor = Luna<Actor>::check(L, 1);
|
||||||
@@ -3258,6 +3319,8 @@ public:
|
|||||||
|
|
||||||
LunaPlayer()
|
LunaPlayer()
|
||||||
{
|
{
|
||||||
|
ADD_METHOD(SetLife);
|
||||||
|
ADD_METHOD(ChangeLife);
|
||||||
ADD_METHOD( SetActorWithJudgmentPosition );
|
ADD_METHOD( SetActorWithJudgmentPosition );
|
||||||
ADD_METHOD( SetActorWithComboPosition );
|
ADD_METHOD( SetActorWithComboPosition );
|
||||||
ADD_METHOD( GetPlayerTimingData );
|
ADD_METHOD( GetPlayerTimingData );
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ public:
|
|||||||
virtual void PushSelf( lua_State *L );
|
virtual void PushSelf( lua_State *L );
|
||||||
|
|
||||||
PlayerState * GetPlayerState() { return this->m_pPlayerState; }
|
PlayerState * GetPlayerState() { return this->m_pPlayerState; }
|
||||||
|
void ChangeLife(float delta);
|
||||||
|
void SetLife(float value);
|
||||||
|
bool m_inside_lua_set_life;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat );
|
void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat );
|
||||||
|
|||||||
Reference in New Issue
Block a user