Forum

CSQC and IQM: How do i get Frames?

Discuss CSQC related programming.

Moderator: InsideQC Admins

CSQC and IQM: How do i get Frames?

Postby drm_wayne » Thu Apr 06, 2017 11:12 am

I finally got my CSCQ viewmodels to work and they are looking really good.
However, theres one thing i can figure out: I want to place reloading sounds on a specific
frame (not an animation sequence), is there a way to get the frames somehow with iqm?

EDIT: i saw IQM has "event [ANIM,]<POSE> <EVENTCODE> <"EVENTDATA">", so how do i use it in fte for sounds?
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: CSQC and IQM: How do i get Frames?

Postby Spike » Thu Apr 06, 2017 5:25 pm

if you have a framegroup/animation defined in your iqm, then you can use the following code:
Code: Select all
//inside csqcsubs.qc or whereever.
enum int
{
GLOBALSOUNDEVENT = 435600 //or whatever your mod wants to support. some standards would be nice. note that the engine does not currently have any awareness of the possible values.
};
void(float timestamp, int code, string data) handlemodelevents =   //probably you won't ever need to use timestamp.
{
  switch(code)
  {
  case GLOBALSOUNDEVENT:  // tokenize data if you need more args, or something. or just create more events.
    precache_sound(data); //should precache some time...
    sound(self, CHAN_AUTO, data, 1, ATTN_NONE);
    break;
  default:
    print(sprintf("unknown sound event: %i\n", code));
    break;
  }
};

//inside your viewmodel's predraw, or really any ent's predraw function
//WARNING: also does 'self.frame1time' = 'self.frame1time + frametime' with these args, so you can skip doing that elsewhere. you should probably do frame2time the normal way.
//calls 'handlemodelevents' for each frame event found between the two timestamps (so you should probably ensure that 'self' is correct for the call).
processmodelevents(self.modelindex, self.frame, self.frame1time, self.frame1time + frametime, handlemodelevents);


if you want to properly precache the sounds, you could make a few calls one for each framegroup with basetime reset to 0 each time, targettime set to what frameduration returns (so that it doesn't wrap), and with a simpler callback that just does precaches. if you do use it from ssqc too, you'll probably want to use a different set of events so you don't get both client+server playing the same sounds or whatever.

you can either embed the events into the iqm with the iqm exporter fork on fte's svn, or you create some foo.iqm.events file (which should also work for mdl, psk, etc).
(it would be awesome to see some ssqc using this to avoid all the run4 etc functions in each monster's qc file, but that's probably overkill)
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: CSQC and IQM: How do i get Frames?

Postby drm_wayne » Thu Apr 06, 2017 10:38 pm

Thanks, im going to test this :D

EDIT: thanks, works fine :D
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm


Return to CSQC Programming

Who is online

Users browsing this forum: No registered users and 1 guest