From fc3884ee9bca1bdd1dc3562a96c0d607c40f23c9 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sun, 16 Jul 2023 13:05:15 -0700 Subject: [PATCH] NSEntity: involve animation frames in the EntityDef event lookup, add new Input 'AddVelocity' (which applies velocity to the entity according to forward,right,up) --- src/shared/NSEntity.qc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/shared/NSEntity.qc b/src/shared/NSEntity.qc index f35830d2..a94fc6b8 100644 --- a/src/shared/NSEntity.qc +++ b/src/shared/NSEntity.qc @@ -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 ); }