NSEntity: involve animation frames in the EntityDef event lookup, add new Input 'AddVelocity' (which applies velocity to the entity according to forward,right,up)

This commit is contained in:
Marco Cawthorne 2023-07-16 13:05:15 -07:00
parent c65c33ef13
commit fc3884ee9b
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 32 additions and 0 deletions

View File

@ -348,6 +348,31 @@ void NSEntity::SetFrame( float newFrame ) {
frame = newFrame;
frame1time = 0.0f;
#ifdef SERVER
/* check if an event callback exists */
{
int eDefEvents = tokenize(m_strModelEventCB);
string ourName = frametoname(modelindex, frame);
print(sprintf("New frame! %S\n", ourName));
for (int i = 0; i < eDefEvents; i+=3) {
string testName = argv(i+0);
string testInput = argv(i+1);
string testData = argv(i+2);
if (ourName == testName) {
if (testData != "")
Input(this, testInput, testData);
else
Input(this, testInput, ""); /* no parms passed. */
tokenize(m_strModelEventCB); /* ensure argv() is 'rewound'... */
}
}
}
#endif
}
void NSEntity::SetSkin( float newSkin ) {
@ -761,6 +786,13 @@ void NSEntity::Input( entity eAct, string strInput, string strData ) {
case "StartSoundDef":
StartSoundDef(strData, CHAN_VOICE, true);
break;
case "AddVelocity":
vector velAdd = stov(strData);
makevectors(angles);
velocity += v_forward * velAdd[0];
velocity += v_right * velAdd[1];
velocity += v_up * velAdd[2];
break;
default:
NSTrigger::Input( eAct, strInput, strData );
}