View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002897 | The Dark Mod | Script/Def | public | 27.10.2011 21:03 | 21.09.2014 14:57 |
Reporter | Assigned To | SteveL | |||
Priority | low | Severity | minor | Reproducibility | N/A |
Status | resolved | Resolution | fixed | ||
Product Version | TDM 1.06 | ||||
Fixed in Version | TDM 2.03 | ||||
Summary | 0002897: add addImpulse() script event | ||||
Description | This was posted from my question thread, Tels asked me to file a tracker entry so it doesn't get forgotten. You could also simply give a movable chair a velocity via a script function: // Sets the current linear velocity of this entity in units per second. The linear velocity of // a physics object is a vector that defines the translation of the center of mass in units per second. scriptEvent void setLinearVelocity( vector velocity ); // Sets the current angular velocity of this entity. The angular velocity of // a physics object is a vector that passes through the center of mass. The // direction of this vector defines the axis of rotation and the magnitude // defines the rate of rotation about the axis in radians per second. scriptEvent void setAngularVelocity( vector velocity ); If you make that a small amount and let the script continously add it for say 20 frames, the moveable will speed up and then fly away: float i = 0; vector velocity = (0,0,0); while (i < 20) { i += 1; $mychair.SetLinearVelocity( velocity); velocity_x += 0.1; velocity_y += 0.1; velocity_yz+= 0.05; } Although it looks like that is difficult to control. (Adding a small impulse instead of setting the vector would definitely be a better script event but we don'thave that yet. | ||||
Tags | No tags attached. | ||||
Attached Files | tels_patch_h_applyImpulse_2014-09-15.txt (3,397 bytes)
Index: game/Entity.cpp =================================================================== --- game/Entity.cpp (revision 6103) +++ game/Entity.cpp (working copy) @@ -125,6 +125,14 @@ "direction of this vector defines the axis of rotation and the magnitude\n" \ "defines the rate of rotation about the axis in radians per second."); +// tels #2897 +const idEventDef EV_ApplyImpulse( "applyImpulse", EventArgs( + 'e', "source", "Pass $null_entity or the entity that applies the impulse", + 'd', "bodyid", "For articulated figures, ID of the body, 0 for the first (main) body. Otherwise use 0.", + 'v',"point", "Point on the body where the impulse is applied to", + 'v',"impulse","Vector of the impulse" + ), EV_RETURNS_VOID, "Applies an impulse to the entity. Example: entity.applyImpulse($player1, 0, entity.getOrigin(), '0 0 2');" ); + // greebo: Accessor events for the clipmask/contents flags const idEventDef EV_SetContents( "setContents", EventArgs('f', "contents", ""), EV_RETURNS_VOID, "Sets the contents of the physics object."); const idEventDef EV_GetContents( "getContents", EventArgs(), 'f', "Returns the contents of the physics object." ); @@ -538,6 +546,7 @@ EVENT( EV_SetLinearVelocity, idEntity::Event_SetLinearVelocity ) EVENT( EV_GetAngularVelocity, idEntity::Event_GetAngularVelocity ) EVENT( EV_SetAngularVelocity, idEntity::Event_SetAngularVelocity ) + EVENT( EV_ApplyImpulse, idEntity::Event_ApplyImpulse ) EVENT( EV_SetContents, idEntity::Event_SetContents ) EVENT( EV_GetContents, idEntity::Event_GetContents ) @@ -7704,6 +7713,17 @@ /* ================ +idEntity::Event_ApplyImpulse + +Tels #2897 +================ +*/ +void idEntity::Event_ApplyImpulse( idEntity *ent, const int id, const idVec3 &point, const idVec3 &impulse ) { + ApplyImpulse( ent, id, point, impulse ); +} + +/* +================ idEntity::Event_SetSize ================ */ Index: game/Entity.h =================================================================== --- game/Entity.h (revision 6103) +++ game/Entity.h (working copy) @@ -84,6 +84,7 @@ extern const idEventDef EV_SetOwner; extern const idEventDef EV_GetAngles; extern const idEventDef EV_SetAngles; +extern const idEventDef EV_ApplyImpulse; extern const idEventDef EV_SetLinearVelocity; extern const idEventDef EV_SetAngularVelocity; extern const idEventDef EV_SetSkin; @@ -526,8 +527,8 @@ // Tels: If LOD is enabled on this entity, call ThinkAboutLOD, computing new LOD level and new // alpha value, then do the right things like Hide/Show, SetAlpha, switch models/skin etc. - // We pass in a pointer to the data (so the LODE can use shared data) as well as the distance, - // so the lode can pre-compute the distance. + // We pass in a pointer to the data (so LOD can use shared data) as well as the distance, + // so the distance can be pre-computed. // SteveL #3770: Params removed. They are now determined in SwitchLOD itself to avoid code repetition // as multiple classes now use LOD. virtual bool SwitchLOD(); @@ -1587,6 +1588,7 @@ void Event_GetLinearVelocity( void ); void Event_SetAngularVelocity( const idVec3 &velocity ); void Event_GetAngularVelocity( void ); + void Event_ApplyImpulse( idEntity *ent, const int id, const idVec3 &point, const idVec3 &impulse ); void Event_SetContents(const int contents); void Event_GetContents(); | ||||
Attached a testmap and a patch that should solve this issue. Open questions: What is the body id, and should it be exposed to the scripting side? And should it be better documented? |
|
Patch updated, the event now gets passed in the source (optional) of the impulse, and simply calls "ApplyImpulse()", so different subclasses of entity can do their own thing. | |
committed rv 6110. Thanks for the fun test map :) | |
Date Modified | Username | Field | Change |
---|---|---|---|
27.10.2011 21:03 |
|
New Issue | |
27.10.2011 21:04 |
|
Summary | Shooting moveable chair: poltergeist style => Shoot/move a moveable chair aka poltergeist style. |
27.10.2011 21:14 | tels | Priority | normal => low |
27.10.2011 21:14 | tels | Summary | Shoot/move a moveable chair aka poltergeist style. => add addImpulse() script event |
28.10.2011 09:18 | greebo | Project | DarkRadiant => The Dark Mod |
28.10.2011 09:18 | greebo | Category | Scripting => General |
28.10.2011 09:55 | tels | Severity | normal => minor |
28.10.2011 09:55 | tels | Reproducibility | have not tried => N/A |
28.10.2011 09:55 | tels | Category | General => Script/Def |
28.10.2011 09:55 | tels | OS | Windows => |
28.10.2011 09:55 | tels | OS Version | 7 sp1 => |
28.10.2011 09:55 | tels | Platform | Win32 => |
28.10.2011 09:55 | tels | Product Version | 1.6.1 => TDM 1.06 |
15.09.2014 10:17 | tels | Assigned To | => tels |
15.09.2014 10:17 | tels | Status | new => assigned |
15.09.2014 10:17 | tels | Assigned To | tels => SteveL |
15.09.2014 12:04 | tels | File Added: apply_impulse.pk4 | |
15.09.2014 12:04 | tels | File Added: tels_patch_h_applyImpulse_2014-09-15.txt | |
15.09.2014 12:05 | tels | Note Added: 0007008 | |
15.09.2014 17:48 | SteveL | Status | assigned => acknowledged |
15.09.2014 19:57 | tels | File Deleted: tels_patch_h_applyImpulse_2014-09-15.txt | |
15.09.2014 19:57 | tels | File Deleted: apply_impulse.pk4 | |
15.09.2014 19:57 | tels | File Added: tels_patch_h_applyImpulse_2014-09-15.txt | |
15.09.2014 19:57 | tels | File Added: apply_impulse.pk4 | |
15.09.2014 19:58 | tels | Note Added: 0007011 | |
21.09.2014 14:57 | SteveL | Note Added: 0007025 | |
21.09.2014 14:57 | SteveL | Status | acknowledged => resolved |
21.09.2014 14:57 | SteveL | Fixed in Version | => TDM 2.03 |
21.09.2014 14:57 | SteveL | Resolution | open => fixed |