@@ -87,8 +87,11 @@ static void computeBounds(int entity, float mins[3], float maxs[3]) {
87
87
Entity_GetMinSize (entity , mins );
88
88
Entity_GetMaxSize (entity , maxs );
89
89
AddVectors (mins ,maxs ,mins );
90
- ScaleVector (mins ,0.5 ); //mins = now COM
91
-
90
+ ScaleVector (mins ,0.5 ); //mins = now Center
91
+ //now rotate with the prop
92
+ float r [3 ];
93
+ Entity_GetAbsAngles (entity , r );
94
+ Math_RotateVector (mins , r , mins );
92
95
//create equidistant box to keep origin of prop in world
93
96
AddVectors (mins ,v ,maxs );
94
97
SubtractVectors (mins ,v ,mins );
@@ -102,7 +105,6 @@ static int pew(int client, float targetPoint[3], float scanDistance) {
102
105
float eyePos [3 ], eyeAngles [3 ], fwrd [3 ];
103
106
GetClientEyePosition (client , eyePos );
104
107
GetClientEyeAngles (client , eyeAngles );
105
- // GetAngleVectors(eyeAngles, fwrd, NULL_VECTOR, NULL_VECTOR);
106
108
Handle trace = TR_TraceRayFilterEx (eyePos , eyeAngles , MASK_SOLID , RayType_Infinite , grabFilter , client );
107
109
int cursor = INVALID_ENT_REFERENCE ;
108
110
if (TR_DidHit (trace )) {
@@ -128,30 +130,14 @@ static int pew(int client, float targetPoint[3], float scanDistance) {
128
130
return cursor ;
129
131
}
130
132
131
- //public bool seeCenterFilter(int entity, int contentsMask, int prop) {
132
- // return !entity || (entity > MaxClients && entity != prop);
133
- //}
134
- //
135
- //static bool checkPropCenterVisible(int client, int prop) {
136
- // //require los to COM to be unobstructed
137
- // float vec1[3], vec2[3];
138
- // Entity_GetMinSize(prop, vec1);
139
- // Entity_GetMaxSize(prop, vec2);
140
- // AddVectors(vec1, vec2, vec1);
141
- // ScaleVector(vec1, 0.5);
142
- // GetClientEyePosition(client, vec2);
143
- // TR_TraceRayFilter(vec1, vec2, MASK_SOLID, RayType_EndPoint, seeCenterFilter, prop);
144
- // return !TR_DidHit();
145
- //}
146
-
147
133
static bool movementCollides (int client , float endpos [3 ], bool onlyTarget ) {
148
134
//check if prop would collide at target position
149
135
float offset [3 ], from [3 ], to [3 ], mins [3 ], maxs [3 ];
150
136
int grabbed = EntRefToEntIndex (GravHand [client ].grabbedEnt );
151
137
if (grabbed == INVALID_ENT_REFERENCE ) ThrowError (" %L is not currently grabbing anything" , client );
152
138
//get movement
153
139
SubtractVectors (endpos , GravHand [client ].lastValid , offset );
154
- Entity_GetAbsOrigin (grabbed , from );
140
+ GetEntPropVector (grabbed , Prop_Data , " m_vecAbsOrigin " , from );
155
141
AddVectors (from , offset , to );
156
142
if (onlyTarget ) {
157
143
from [0 ]= to [0 ]- 0.1 ;
@@ -160,9 +146,8 @@ static bool movementCollides(int client, float endpos[3], bool onlyTarget) {
160
146
}
161
147
computeBounds (grabbed , mins , maxs );
162
148
//trace it
163
- Handle trace = TR_TraceHullFilterEx (from , to , mins , maxs , MASK_SOLID , grabFilter , client );
164
- bool result = TR_DidHit (trace );
165
- delete trace ;
149
+ TR_TraceHullFilter (from , to , mins , maxs , MASK_SOLID , grabFilter , client );
150
+ bool result = TR_DidHit ();
166
151
return result ;
167
152
}
168
153
@@ -171,8 +156,6 @@ static bool movementCollides(int client, float endpos[3], bool onlyTarget) {
171
156
* have to check if gravity hands are out.
172
157
*/
173
158
bool clientCmdHoldProp (int client , int &buttons , float velocity [3 ], float angles [3 ]) {
174
- // float yawAngle[3];
175
- // yawAngle[1] = angles[1];
176
159
if ((buttons & IN_ATTACK2 ) && ! GravHand [client ].forceDropProp ) {
177
160
if (GetEntPropFloat (client , Prop_Send , " m_flNextAttack" ) - GetGameTime () < 0.1 ) {
178
161
SetEntPropFloat (client , Prop_Send , " m_flNextAttack" , GetGameTime () + 0.5 );
@@ -198,7 +181,6 @@ bool clientCmdHoldProp(int client, int &buttons, float velocity[3], float angles
198
181
}
199
182
return true ;
200
183
} else if (! (buttons & IN_ATTACK2 )) {
201
- // SetEntPropFloat(client, Prop_Send, "m_flFirstPrimaryAttack", GetGameTime()+0.5);
202
184
SetEntPropFloat (client , Prop_Send , " m_flNextAttack" , GetGameTime ());
203
185
buttons &=~ IN_ATTACK2 ;
204
186
}
@@ -301,9 +283,10 @@ static bool TryPickupCursorEnt(int client, float yawAngle[3]) {
301
283
TeleportEntity (cursorEnt , NULL_VECTOR , NULL_VECTOR , killVelocity );
302
284
//grab entity
303
285
GravHand [client ].grabbedEnt = EntIndexToEntRef (cursorEnt );
304
- float vec [3 ];
286
+ float vec [3 ], vec2 [ 3 ] ;
305
287
GetClientEyePosition (client , vec );
306
- GravHand [client ].grabDistance = Entity_GetDistanceOrigin (rotProxy , vec );
288
+ GetEntPropVector (rotProxy , Prop_Data , " m_vecAbsOrigin" , vec2 );
289
+ GravHand [client ].grabDistance = GetVectorDistance (vec2 , vec );
307
290
//parent to make rotating easier
308
291
SetVariantString (" !activator" );
309
292
AcceptEntityInput (cursorEnt , " SetParent" , rotProxy );
@@ -392,7 +375,7 @@ bool ForceDropItem(int client, bool punt=false, const float dvelocity[3]=NULL_VE
392
375
int entity ;
393
376
if ((entity = EntRefToEntIndex (GravHand [client ].grabbedEnt ))!= INVALID_ENT_REFERENCE ) {
394
377
float vec [3 ], origin [3 ];
395
- Entity_GetAbsOrigin (entity , origin );
378
+ GetEntPropVector (entity , Prop_Data , " m_vecAbsOrigin " , origin );
396
379
AcceptEntityInput (entity , " ClearParent" );
397
380
//fling
398
381
bool didPunt ;
@@ -401,7 +384,6 @@ bool ForceDropItem(int client, bool punt=false, const float dvelocity[3]=NULL_VE
401
384
GetAngleVectors (dvangles , vec , NULL_VECTOR , NULL_VECTOR );
402
385
ScaleVector (vec , gGraviHandsPuntForce * 100.0 / Phys_GetMass (entity ));
403
386
// AddVectors(vec, fwd, vec);
404
- // PrintToServer("Punting Prop with Mass %f", Phys_GetMass(entity));
405
387
didPunt = true ;
406
388
} else if (! movementCollides (client , vec , false )) { //throw with swing
407
389
SubtractVectors (vec , GravHand [client ].previousEnd , vec );
@@ -411,8 +393,8 @@ bool ForceDropItem(int client, bool punt=false, const float dvelocity[3]=NULL_VE
411
393
}
412
394
if (! IsNullVector (dvelocity )) AddVectors (vec , dvelocity , vec );
413
395
float zeros [3 ];
414
- TeleportEntity (entity , origin , NULL_VECTOR , zeros ); //rest entity
415
- Phys_AddVelocity (entity , vec , zeros );//use vphysics to accelerate, is more stable
396
+ TeleportEntity (entity , origin , NULL_VECTOR , zeros ); //reset entity
397
+ Phys_SetVelocity (entity , vec , zeros , true );//use vphysics to accelerate, is more stable
416
398
417
399
//fire output that the ent was dropped
418
400
{ char classname [64 ];
@@ -430,7 +412,7 @@ bool ForceDropItem(int client, bool punt=false, const float dvelocity[3]=NULL_VE
430
412
didStuff = true ;
431
413
}
432
414
if ((entity = EntRefToEntIndex (GravHand [client ].rotProxyEnt ))!= INVALID_ENT_REFERENCE ) {
433
- RequestFrame ( killEntity , entity );
415
+ AcceptEntityInput ( entity , " Kill " );
434
416
GravHand [client ].rotProxyEnt = INVALID_ENT_REFERENCE ;
435
417
didStuff = true ;
436
418
}
@@ -472,11 +454,6 @@ void PlayActionSound(int client, int sound) {
472
454
}
473
455
}
474
456
475
- static void killEntity (int entity ) {
476
- if (IsValidEntity (entity ))
477
- AcceptEntityInput (entity , " Kill" );
478
- }
479
-
480
457
bool FixPhysPropAttacker (int victim , int & attacker , int & inflictor , int & damagetype ) {
481
458
if (attacker == inflictor && victim != attacker && ! IsValidClient (attacker )) {
482
459
char classname [64 ];
0 commit comments