Thanks Spike but I'm still fighting with simple animations now!
I'm almost giving up...
This is where I've been so far... practically nowhere!
myenemyCSQC.c
Code: Select all
void myenemyPredraw()
{
local float framewalk,framedur,skeltemp,numbones,bonenumber;
framewalk= time * 0.1;
if (self.skeletonindex){
addentity(self);//use a custom skeleton
}
else{
self.modelindex = myEnemy.modelindex;
self.skeletonindex = skel_create(self.modelindex);
self.frame = frameforname(self.modelindex,"duck");
self.frame2 = frameforname(self.modelindex,"taunt");
self.frame3 = frameforname(self.modelindex,"strafeleft");
self.frame4 = frameforname(self.modelindex,"run");
print ("Model num:",ftos(self.modelindex),"\n");
skeltemp = skel_build(self.skeletonindex, self, self.modelindex, 0, 0, 0, 0);
numbones = skel_get_numbones(self.skeletonindex);
print("-num bones: ",ftos(numbones)," -skeleton index: ",ftos(self.skeletonindex), " -skelbuild ok?: ",ftos(skeltemp),"\n");
print("ModelIndex Num?: ",ftos(myEnemy.modelindex),"\n"); //IT RETURNS -1 : NO MODEL INDEX FOUND
self.frame1time = time;
self.frame2time = time;
self.frame3time = time;
self.frame4time = time;
self.lerpfrac = 0;
self.lerpfrac3 = 0;
self.lerpfrac4 = 0;
addentity(self);
skel_delete(self.skeletonindex);
}
}
void myenemy_spawn()
{
local entity e;
local vector myorg = pippo_placeholder2();
local float numbones,skeltemp,bonenamefind;
myEnemy = spawn();
setorigin(myEnemy, '0 0 -275');
myEnemy.drawmask = MASK_NORMAL;
precache_model ("models/erebus/erebus.iqm");
setmodel(myEnemy, "models/erebus/erebus.iqm");
myEnemy.predraw = myenemyPredraw;
}
CS_main
Code: Select all
void CSQC_Init()
{
myenemy_spawn();
}
The model starts a little with the idle anim and then stops. But I noticed that it does the same thing on SSQC so maybe it's nothing related to the code I made.
I've also read many many times this article
written by Spike (I presume) and I tried the examples in it but nothing.
The only strange thing is that modelindex returns always -1 so it's invalid. I thought that it could be that. Infact I'm using the code for CSQC Animations modified by Nahuel
here and the first thing I've done it was to query this command:
Code: Select all
void UpdateCSPlayer(float newent)
{
if (newent)
{
print("Player is updating\n");
self.classname = "player";
self.legsframe = 212;
self.drawmask = MASK_NORMAL; // makes the entity visible
setmodel (self, "models/max/max.dpm");//the model is rendered here, not in SSQC
if (!self.skeletonindex)
{
self.skeletonindex = skel_create(self.modelindex);
skel_player_update_begin (self.modelindex, 201, 0);
print("PlayerModelIndex Num?: ",ftos(self.modelindex),"\n");//IT RETURNS 2. MODELINDEX VALID!
}
}
}
And the modelindex is 2. So I thought that the model needed to be created in CSQC and then, via AddStat, it needed to port animations, origin and stuff to CSQC.
So I created this in SSQC (I admit, from now on I've no idea what I've written, it was my first time trying to make communicating SSQC + CSQC so please be patient!
)
enemySSQC.c
Code: Select all
//there's an entity in the map named myenemy_spawn
void myenemy_spawn()
{
myenemy = self;
myenemy.classname = "myenemy";
//setmodel(myenemy, "models/erebus/erebus.iqm"); //disabled. I want to see the model in CSQC
setsize (myenemy, VEC_HULL2_MIN, VEC_HULL2_MAX);
myenemy.solid = SOLID_SLIDEBOX;
myenemy.movetype = MOVETYPE_STEP;
//myenemy.SendEntity = SendEnemyToCSQC;//tried to send it from here with no luck
}
worldSSQC.c
Code: Select all
void Adding_New_stats_To_CSQC()
{
AddStat (STAT_MDLPLAYER, 8, PersID);
AddStat (STAT_MYENEMY, 8, myEnemyID);
}
void worldspawn()
{
... other stuff
Adding_New_stats_To_CSQC();
... other stuff
}
clientSSQC.c
Code: Select all
float SendEnemyToCSQC()
{
// msg_entity = self;
WriteByte(MSG_ENTITY, ENT_MYENEMY);
WriteByte(MSG_ENTITY, myenemy.frame); //FIXME NEED COMPRESSION
WriteByte(MSG_ENTITY, myenemy.myEnemyID);
WriteByte(MSG_ENTITY, myenemy.v_angle_x*(256/360));
WriteByte(MSG_ENTITY, myenemy.v_angle_y*(256/360));
WriteCoord(MSG_ENTITY, myenemy.origin_x);
WriteCoord(MSG_ENTITY, myenemy.origin_y);
WriteCoord(MSG_ENTITY, myenemy.origin_z);
WriteShort(MSG_ENTITY, myenemy.velocity_x);
WriteShort(MSG_ENTITY, myenemy.velocity_y);
WriteShort(MSG_ENTITY, myenemy.velocity_z);
return TRUE;
}
void() PutClientInServer =
{
...other stuff
local entity spot;
spot = find (world, classname, "info_player_start");
if (!spot)
error ("PutClientInServer: no info_player_start on level");
self.classname = "player";
self.SendEntity = SendPlayerToCSQC;//VITAL! Otherwise the camera will stand at a funny angle and player skel won't move!
myenemy.SendEntity = SendEnemyToCSQC; //I don't think this does anything
self.Version = self.Version + 1;
};
defsSSQC.c
Code: Select all
const float STAT_MYENEMY= 33;//toneddu2000
entity myenemy;//toneddu2000
.float myEnemyID;//toneddu2000
defsCSQC.c
Code: Select all
float ENT_MYENEMY = 2; //toneddu2000
.float myEnemyID;//toneddu2000
But of course, nothing. I completely aware that the code I wrote is junk. I mean, how can it be possible that CSQC knows that myenemy_spawn() function in enemySSQC.c holds the stats to be ported?
Sorry guys for the total mess post but this is exactly what my mind is right now!