env_shooter: Add Input() method
This commit is contained in:
parent
8b2d484917
commit
c60012b757
|
@ -35,6 +35,9 @@ Shoots model entities from its location.
|
||||||
- "m_flGibLife" : Life of the individual model piece.
|
- "m_flGibLife" : Life of the individual model piece.
|
||||||
- "scale" : Scale modifier of the model pieces.
|
- "scale" : Scale modifier of the model pieces.
|
||||||
|
|
||||||
|
# INPUTS
|
||||||
|
- "Shoot" : Causes the shooter to shoot.
|
||||||
|
|
||||||
# TRIVIA
|
# TRIVIA
|
||||||
This entity was introduced in Half-Life (1998).
|
This entity was introduced in Half-Life (1998).
|
||||||
*/
|
*/
|
||||||
|
@ -50,7 +53,9 @@ public:
|
||||||
virtual void SpawnKey(string,string);
|
virtual void SpawnKey(string,string);
|
||||||
virtual void Respawn(void);
|
virtual void Respawn(void);
|
||||||
virtual void Trigger(entity, triggermode_t);
|
virtual void Trigger(entity, triggermode_t);
|
||||||
|
virtual void Input(entity, string, string);
|
||||||
nonvirtual void ShootGib(void);
|
nonvirtual void ShootGib(void);
|
||||||
|
nonvirtual void ShooterLoop(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_iGibs;
|
int m_iGibs;
|
||||||
|
@ -64,6 +69,7 @@ private:
|
||||||
float m_flShootSounds;
|
float m_flShootSounds;
|
||||||
float m_flScale;
|
float m_flScale;
|
||||||
float m_flSkin;
|
float m_flSkin;
|
||||||
|
bool m_bCanScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -79,6 +85,7 @@ env_shooter::env_shooter(void)
|
||||||
m_flShootSounds = 0;
|
m_flShootSounds = 0;
|
||||||
m_flScale = 1.0;
|
m_flScale = 1.0;
|
||||||
m_flSkin = 0;
|
m_flSkin = 0;
|
||||||
|
m_bCanScale = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -112,6 +119,11 @@ env_shooter::Spawned(void)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* figure out if we're a sprite... */
|
||||||
|
if (Util_ExtensionFromString(m_strShootModel) == "spr") {
|
||||||
|
m_bCanScale = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -128,6 +140,7 @@ env_shooter::Save(float handle)
|
||||||
SaveFloat(handle, "m_flShootSounds", m_flShootSounds);
|
SaveFloat(handle, "m_flShootSounds", m_flShootSounds);
|
||||||
SaveFloat(handle, "m_flScale", m_flScale);
|
SaveFloat(handle, "m_flScale", m_flScale);
|
||||||
SaveFloat(handle, "m_flSkin", m_flSkin);
|
SaveFloat(handle, "m_flSkin", m_flSkin);
|
||||||
|
SaveBool(handle, "m_bCanScale", m_bCanScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -164,6 +177,9 @@ env_shooter::Restore(string strKey, string strValue)
|
||||||
case "m_flSkin":
|
case "m_flSkin":
|
||||||
m_flSkin = ReadFloat(strValue);
|
m_flSkin = ReadFloat(strValue);
|
||||||
break;
|
break;
|
||||||
|
case "m_bCanScale":
|
||||||
|
m_bCanScale = ReadBool(strValue);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
super::Restore(strKey, strValue);
|
super::Restore(strKey, strValue);
|
||||||
}
|
}
|
||||||
|
@ -241,7 +257,7 @@ env_shooter::ShootGib(void)
|
||||||
the env_shooter entities in lambda_bunker.bsp rely
|
the env_shooter entities in lambda_bunker.bsp rely
|
||||||
on this exact behaviour. if Source added support
|
on this exact behaviour. if Source added support
|
||||||
for this you need to differentiate between the two. */
|
for this you need to differentiate between the two. */
|
||||||
if (substring(m_strShootModel, 0, 8) == "sprites/") {
|
if (m_bCanScale == true) {
|
||||||
eGib.SetScale(m_flScale);
|
eGib.SetScale(m_flScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,12 +300,17 @@ env_shooter::ShootGib(void)
|
||||||
eGib.SetVelocity(vecThrowVel);
|
eGib.SetVelocity(vecThrowVel);
|
||||||
eGib.SetAngularVelocity(vecSpinVel);
|
eGib.SetAngularVelocity(vecSpinVel);
|
||||||
eGib.ScheduleThink(Destroy, m_flGibLife);
|
eGib.ScheduleThink(Destroy, m_flGibLife);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
env_shooter::ShooterLoop(void)
|
||||||
|
{
|
||||||
|
ShootGib();
|
||||||
m_iGibsLeft--;
|
m_iGibsLeft--;
|
||||||
|
|
||||||
/* keep shooting til we're done */
|
/* keep shooting til we're done */
|
||||||
if (m_iGibsLeft) {
|
if (m_iGibsLeft) {
|
||||||
ScheduleThink(ShootGib, m_flDelay);
|
ScheduleThink(ShooterLoop, m_flDelay);
|
||||||
} else {
|
} else {
|
||||||
/* no more gibs left, destroy if wanted */
|
/* no more gibs left, destroy if wanted */
|
||||||
if (HasSpawnFlags(EVSHOOTER_REPEATABLE) == false) {
|
if (HasSpawnFlags(EVSHOOTER_REPEATABLE) == false) {
|
||||||
|
@ -311,7 +332,7 @@ env_shooter::Trigger(entity act, triggermode_t state)
|
||||||
m_iGibsLeft = m_iGibs;
|
m_iGibsLeft = m_iGibs;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleThink(ShootGib, m_flDelay);
|
ScheduleThink(ShooterLoop, m_flDelay);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (IsThinking() == false)
|
if (IsThinking() == false)
|
||||||
|
@ -320,3 +341,14 @@ env_shooter::Trigger(entity act, triggermode_t state)
|
||||||
Trigger(act, TRIG_OFF);
|
Trigger(act, TRIG_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
env_shooter::Input(entity entityActivator, string inputName, string dataField)
|
||||||
|
{
|
||||||
|
switch (inputName) {
|
||||||
|
case "Shoot":
|
||||||
|
ShootGib();
|
||||||
|
default:
|
||||||
|
super::Input(entityActivator, inputName, dataField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue