NSRenderableEntity: Increase network precision of body field, add new methods 'SetBodyInGroup(int, int)' and 'GetBodyInGroup(int)'
This commit is contained in:
parent
3cda024a33
commit
d5bb5f933d
7 changed files with 63 additions and 13 deletions
|
@ -1626,7 +1626,7 @@ NSMonster::SendEntity(entity ePEnt, float flChanged)
|
|||
SENDENTITY_FLOAT(skin, MONFL_CHANGED_SKINHEALTH)
|
||||
SENDENTITY_FLOAT(health, MONFL_CHANGED_SKINHEALTH)
|
||||
SENDENTITY_FLOAT(effects, MONFL_CHANGED_EFFECTS)
|
||||
SENDENTITY_BYTE(m_iBody, MONFL_CHANGED_BODY)
|
||||
SENDENTITY_SHORT(m_iBody, MONFL_CHANGED_BODY)
|
||||
SENDENTITY_FLOAT(scale, MONFL_CHANGED_SCALE)
|
||||
SENDENTITY_COORD(velocity[0], MONFL_CHANGED_VELOCITY)
|
||||
SENDENTITY_COORD(velocity[1], MONFL_CHANGED_VELOCITY)
|
||||
|
@ -1706,7 +1706,7 @@ NSMonster::ReceiveEntity(float flNew, float flChanged)
|
|||
READENTITY_FLOAT(skin, MONFL_CHANGED_SKINHEALTH)
|
||||
READENTITY_FLOAT(health, MONFL_CHANGED_SKINHEALTH)
|
||||
READENTITY_FLOAT(effects, MONFL_CHANGED_EFFECTS)
|
||||
READENTITY_BYTE(m_iBody, MONFL_CHANGED_BODY)
|
||||
READENTITY_SHORT(m_iBody, MONFL_CHANGED_BODY)
|
||||
READENTITY_FLOAT(scale, MONFL_CHANGED_SCALE)
|
||||
READENTITY_COORD(velocity[0], MONFL_CHANGED_VELOCITY)
|
||||
READENTITY_COORD(velocity[1], MONFL_CHANGED_VELOCITY)
|
||||
|
|
|
@ -152,6 +152,8 @@ public:
|
|||
/* set */
|
||||
/** Sets the bodygroup of the entity. */
|
||||
nonvirtual void SetBody(int);
|
||||
/** Sets the body inside of a specific group. */
|
||||
nonvirtual void SetBodyInGroup(int, int);
|
||||
/** Sets the render FX type of the entity. Check renderfx_t for details. */
|
||||
nonvirtual void SetRenderFX(float);
|
||||
/** Sets the render mode type of the entity. Check rendermode_t for details. */
|
||||
|
@ -172,6 +174,8 @@ public:
|
|||
nonvirtual void SetBoneControl5(float);
|
||||
/** Returns the bodygroup of the entity. */
|
||||
nonvirtual int GetBody(void);
|
||||
/** Returns the body within a given group. */
|
||||
nonvirtual int GetBodyInGroup(int);
|
||||
/** Returns the render mode of the entity. */
|
||||
nonvirtual float GetRenderMode(void);
|
||||
/** Returns the render FX of the entity. */
|
||||
|
|
|
@ -45,13 +45,16 @@ void NSRenderableEntity::RendererRestarted( void ) {
|
|||
|
||||
void NSRenderableEntity::_UpdateGeomset(void)
|
||||
{
|
||||
/* unpack our half bytes */
|
||||
int firstBody = (m_iBody & 0x0F);
|
||||
int secondBody = ((m_iBody >> 4) & 0x0F);
|
||||
int thirdBody = ((m_iBody >> 8) & 0x0F);
|
||||
int fourthBody = ((m_iBody >> 12) & 0x0F);
|
||||
|
||||
//print(sprintf("%i body 1: %i body 2: %i\n", m_iBody , firstBody, secondBody));
|
||||
//print(sprintf("%i body 0: %i body 1: %i body 2: %i body 3: %i\n", m_iBody , firstBody, secondBody, thirdBody, fourthBody));
|
||||
|
||||
setcustomskin(this, "",
|
||||
sprintf("geomset 0 %i\ngeomset 1 %i\ngeomset 2 %i\n", secondBody, firstBody, secondBody)
|
||||
sprintf("geomset 0 %i\ngeomset 1 %i\ngeomset 2 %i\ngeomset 3 %i\n", firstBody, secondBody, thirdBody, fourthBody)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
@ -196,7 +199,7 @@ NSRenderableEntity::SendEntity(entity ePEnt, float flChanged)
|
|||
SENDENTITY_FLOAT(frame1time, RDENT_CHANGED_FRAME)
|
||||
SENDENTITY_FLOAT(skin, RDENT_CHANGED_SKIN)
|
||||
SENDENTITY_FLOAT(effects, RDENT_CHANGED_EFFECTS)
|
||||
SENDENTITY_BYTE(m_iBody, RDENT_CHANGED_BODY)
|
||||
SENDENTITY_SHORT(m_iBody, RDENT_CHANGED_BODY)
|
||||
SENDENTITY_FLOAT(scale, RDENT_CHANGED_SCALE)
|
||||
SENDENTITY_COORD(velocity[0], RDENT_CHANGED_VELOCITY)
|
||||
SENDENTITY_COORD(velocity[1], RDENT_CHANGED_VELOCITY)
|
||||
|
@ -253,7 +256,7 @@ NSRenderableEntity::ReceiveEntity(float flNew, float flChanged)
|
|||
READENTITY_FLOAT(frame1time, RDENT_CHANGED_FRAME)
|
||||
READENTITY_FLOAT(skin, RDENT_CHANGED_SKIN)
|
||||
READENTITY_FLOAT(effects, RDENT_CHANGED_EFFECTS)
|
||||
READENTITY_BYTE(m_iBody, RDENT_CHANGED_BODY)
|
||||
READENTITY_SHORT(m_iBody, RDENT_CHANGED_BODY)
|
||||
READENTITY_FLOAT(scale, RDENT_CHANGED_SCALE)
|
||||
READENTITY_COORD(velocity[0], RDENT_CHANGED_VELOCITY)
|
||||
READENTITY_COORD(velocity[1], RDENT_CHANGED_VELOCITY)
|
||||
|
@ -584,11 +587,22 @@ NSRenderableEntity::SetBody(int newBody)
|
|||
{
|
||||
m_iBody = newBody;
|
||||
|
||||
breakpoint();
|
||||
|
||||
#ifdef CLIENT
|
||||
_UpdateGeomset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
NSRenderableEntity::SetBodyInGroup(int groupID, int bodyValue)
|
||||
{
|
||||
/* pack our half bytes */
|
||||
m_iBody |= (bodyValue << (4 * groupID));
|
||||
//print(sprintf("NEW BODY: %i %i %i\n", m_iBody, groupID, bodyValue));
|
||||
breakpoint();
|
||||
}
|
||||
|
||||
void
|
||||
NSRenderableEntity::SetRenderFX(float newFX)
|
||||
{
|
||||
|
@ -649,6 +663,12 @@ NSRenderableEntity::GetBody(void)
|
|||
return m_iBody;
|
||||
}
|
||||
|
||||
int
|
||||
NSRenderableEntity::GetBodyInGroup(int bodyGroup)
|
||||
{
|
||||
return m_iBody;
|
||||
}
|
||||
|
||||
float
|
||||
NSRenderableEntity::GetRenderMode(void)
|
||||
{
|
||||
|
@ -852,6 +872,18 @@ NSRenderableEntity::SpawnKey(string strKey, string strValue)
|
|||
case "body":
|
||||
m_iBody = stoi(strValue);
|
||||
break;
|
||||
case "body0":
|
||||
SetBodyInGroup(0, stoi(strValue));
|
||||
break;
|
||||
case "body1":
|
||||
SetBodyInGroup(1, stoi(strValue));
|
||||
break;
|
||||
case "body2":
|
||||
SetBodyInGroup(2, stoi(strValue));
|
||||
break;
|
||||
case "body3":
|
||||
SetBodyInGroup(3, stoi(strValue));
|
||||
break;
|
||||
case "modelscale":
|
||||
case "scale":
|
||||
scale = stof(strValue);
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
#ifdef SERVER
|
||||
private:
|
||||
int m_iSquadLeaderBody;
|
||||
string m_strSquadLeaderBody;
|
||||
bool m_bStartAsLeader;
|
||||
bool m_inSquad;
|
||||
NSSquadMonster m_eSquadLeader;
|
||||
|
|
|
@ -25,6 +25,8 @@ NSSquadMonster::NSSquadMonster(void)
|
|||
for (int i = 0; i < NSSQUADMONSTER_MAXMEMBERS; i++) {
|
||||
m_eSquadMembers[i] = __NULL__;
|
||||
}
|
||||
|
||||
m_strSquadLeaderBody = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -37,7 +39,7 @@ NSSquadMonster::SpawnKey(string strKey, string strValue)
|
|||
m_bStartAsLeader = ReadBool(strValue);
|
||||
break;
|
||||
case "squad_leader_body":
|
||||
m_iSquadLeaderBody = ReadInt(strValue);
|
||||
m_strSquadLeaderBody = ReadString(strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
@ -131,7 +133,19 @@ NSSquadMonster::AddToSquad(NSSquadMonster addMember)
|
|||
startMember = this;
|
||||
m_inSquad = true;
|
||||
print(sprintf("%s (%d) became squad leader\n", classname, num_for_edict(this)));
|
||||
SetBody(GetBody() | m_iSquadLeaderBody);
|
||||
//SetBody(GetBody() | m_iSquadLeaderBody);
|
||||
|
||||
/* apply the squad leader body */
|
||||
{
|
||||
int t = tokenizebyseparator(m_strSquadLeaderBody, ":");
|
||||
|
||||
if (t == 1) {
|
||||
SetBodyInGroup(0, stoi(argv(0)));
|
||||
} else if (t == 2) {
|
||||
SetBodyInGroup(stoi(argv(0)), stoi(argv(1)));
|
||||
}
|
||||
}
|
||||
|
||||
HasBecomeSquadLeader();
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ NSSurfacePropEntity::SendEntity(entity ePEnt, float flChanged)
|
|||
SENDENTITY_BYTE(frame, SRFENT_CHANGED_FRAME)
|
||||
SENDENTITY_FLOAT(skin, SRFENT_CHANGED_SKIN)
|
||||
SENDENTITY_FLOAT(effects, SRFENT_CHANGED_EFFECTS)
|
||||
SENDENTITY_BYTE(m_iBody, SRFENT_CHANGED_BODY)
|
||||
SENDENTITY_SHORT(m_iBody, SRFENT_CHANGED_BODY)
|
||||
SENDENTITY_FLOAT(scale, SRFENT_CHANGED_SCALE)
|
||||
SENDENTITY_COORD(velocity[0], SRFENT_CHANGED_VELOCITY)
|
||||
SENDENTITY_COORD(velocity[1], SRFENT_CHANGED_VELOCITY)
|
||||
|
@ -348,7 +348,7 @@ NSSurfacePropEntity::ReceiveEntity(float flNew, float flChanged)
|
|||
READENTITY_BYTE(frame, SRFENT_CHANGED_FRAME)
|
||||
READENTITY_FLOAT(skin, SRFENT_CHANGED_SKIN)
|
||||
READENTITY_FLOAT(effects, SRFENT_CHANGED_EFFECTS)
|
||||
READENTITY_BYTE(m_iBody, SRFENT_CHANGED_BODY)
|
||||
READENTITY_SHORT(m_iBody, SRFENT_CHANGED_BODY)
|
||||
READENTITY_FLOAT(scale, SRFENT_CHANGED_SCALE)
|
||||
READENTITY_COORD(velocity[0], SRFENT_CHANGED_VELOCITY)
|
||||
READENTITY_COORD(velocity[1], SRFENT_CHANGED_VELOCITY)
|
||||
|
|
|
@ -794,7 +794,7 @@ NSTalkMonster::SendEntity(entity ePEnt, float flChanged)
|
|||
SENDENTITY_FLOAT(skin, MONFL_CHANGED_SKINHEALTH)
|
||||
SENDENTITY_FLOAT(health, MONFL_CHANGED_SKINHEALTH)
|
||||
SENDENTITY_FLOAT(effects, MONFL_CHANGED_EFFECTS)
|
||||
SENDENTITY_BYTE(m_iBody, MONFL_CHANGED_BODY)
|
||||
SENDENTITY_SHORT(m_iBody, MONFL_CHANGED_BODY)
|
||||
SENDENTITY_FLOAT(scale, MONFL_CHANGED_SCALE)
|
||||
SENDENTITY_COORD(velocity[0], MONFL_CHANGED_VELOCITY)
|
||||
SENDENTITY_COORD(velocity[1], MONFL_CHANGED_VELOCITY)
|
||||
|
@ -991,7 +991,7 @@ NSTalkMonster::ReceiveEntity(float flNew, float flChanged)
|
|||
READENTITY_FLOAT(skin, MONFL_CHANGED_SKINHEALTH)
|
||||
READENTITY_FLOAT(health, MONFL_CHANGED_SKINHEALTH)
|
||||
READENTITY_FLOAT(effects, MONFL_CHANGED_EFFECTS)
|
||||
READENTITY_BYTE(m_iBody, MONFL_CHANGED_BODY)
|
||||
READENTITY_SHORT(m_iBody, MONFL_CHANGED_BODY)
|
||||
READENTITY_FLOAT(scale, MONFL_CHANGED_SCALE)
|
||||
READENTITY_COORD(velocity[0], MONFL_CHANGED_VELOCITY)
|
||||
READENTITY_COORD(velocity[1], MONFL_CHANGED_VELOCITY)
|
||||
|
|
Loading…
Reference in a new issue