1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
global function HealthRegen_Init
global function PilotHealthRegenThinkSP
global function PilotShieldHealthUpdate
struct
{
float healthRegenRate
} file
void function HealthRegen_Init()
{
if ( IsSingleplayer() )
{
file.healthRegenRate = 1.0
}
else
{
file.healthRegenRate = 6.0
AddCallback_PlayerClassChanged( HealthRegen_OnPlayerClassChangedMP )
RegisterSignal( "PilotHealthRegenThink" )
}
}
void function PilotHealthRegenThinkSP( entity player )
{
player.EndSignal( "OnDestroy" )
while ( IsValid( player ) )
{
wait( HEALTH_REGEN_TICK_TIME )
if ( !IsAlive( player ) )
continue
if ( !IsPilot( player ) )
continue
if ( shGlobal.proto_pilotHealthRegenDisabled )
continue
//Assert( IsTestMap() || player.GetPlayerSettings() == DEFAULT_PILOT_SETTINGS, "for now, we should all be pilot_solo at all times, or in a test map." )
if ( player.GetHealth() == player.GetMaxHealth() )
continue
float healthRegenRate = 4.0
float healthRegenStartDelay = GraphCapped( player.GetHealth(), 0, player.GetMaxHealth(), 3.0, 0.8 )
//printt( "recentDamage " + recentDamage + " delay " + healthRegenStartDelay + " rate " + healthRegenRate )
if ( Time() - player.p.lastDamageTime < healthRegenStartDelay )
{
continue
}
player.SetHealth( min( player.GetMaxHealth(), player.GetHealth() + healthRegenRate ) )
}
}
bool function IsHealActive( entity player )
{
return StatusEffect_Get( player, eStatusEffect.stim_visual_effect ) > 0.0
}
void function PilotHealthRegenThinkMP( entity player )
{
player.EndSignal( "OnDestroy" )
player.Signal( "PilotHealthRegenThink" )
player.EndSignal( "PilotHealthRegenThink" )
//float healthRegenStartDelay = player.GetPlayerSettingsField( "powerRegenRateOp" ) // seconds after we take damager to start regen
float healthRegenStartDelay = 5.0 //Needs to use GetPlayerSettingsField() instead of hard coding, waiting on Bug 129567
if ( PlayerHasPassive( player, ePassives.PAS_FAST_HEALTH_REGEN ) )
healthRegenStartDelay = 2.5
while ( IsValid( player ) )
{
wait( HEALTH_REGEN_TICK_TIME )
if ( !IsAlive( player ) )
continue
if ( !IsPilot( player ) )
continue
if ( shGlobal.proto_pilotHealthRegenDisabled )
continue
float healthRegenRate = file.healthRegenRate // health regen per tick
if ( player.GetHealth() == player.GetMaxHealth() )
continue
// No regen during phase shift
if ( player.IsPhaseShifted() )
continue
if ( IsHealActive( player ) )
{
if ( Time() - player.p.lastDamageTime < min( ABILITY_STIM_REGEN_DELAY, healthRegenStartDelay ) )
continue
else
healthRegenRate = healthRegenRate * ABILITY_STIM_REGEN_MOD
}
else if ( Time() - player.p.lastDamageTime < healthRegenStartDelay )
{
continue
}
player.SetHealth( min( player.GetMaxHealth(), player.GetHealth() + healthRegenRate ) )
if ( player.GetHealth() == player.GetMaxHealth() )
{
ClearRecentDamageHistory( player )
ClearLastAttacker( player )
}
}
}
void function HealthRegen_OnPlayerClassChangedMP( entity player )
{
thread PilotHealthRegenThinkMP( player )
}
float function PilotShieldHealthUpdate( entity player, var damageInfo )
{
if ( DamageInfo_GetForceKill( damageInfo ) )
{
player.SetShieldHealth( 0 )
return 0.0
}
int shieldHealth = player.GetShieldHealth()
float shieldDamage = 0
if ( shieldHealth )
{
DamageInfo_AddCustomDamageType( damageInfo, DF_SHIELD_DAMAGE )
shieldDamage = PilotShieldModifyDamage( player, damageInfo )
if ( shieldDamage )
DamageInfo_SetDamage( damageInfo, 0 )
}
return shieldDamage
}
float function PilotShieldModifyDamage( entity player, var damageInfo )
{
float shieldHealth = float( player.GetShieldHealth() )
float damage = DamageInfo_GetDamage( damageInfo )
float newShieldHealth = shieldHealth - damage
float permanentDamage = 0.0
if ( newShieldHealth < 0 )
permanentDamage = fabs( newShieldHealth )
player.SetShieldHealth( maxint( 0, int( newShieldHealth ) ) )
if ( shieldHealth && newShieldHealth <= 0 )
{
EmitSoundOnEntity( player, "titan_energyshield_down" )
}
DamageInfo_SetDamage( damageInfo, permanentDamage )
return min( shieldHealth, damage )
}
|