Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] Thanks for the help, but I was wondering, is it possible to do this clientside? On 6/8/06, Michael Kramer <[EMAIL PROTECTED]> wrote: > > -- > [ Picked text/plain from multipart/alternative ] > Alright, I have tested this and it works, Simply, in sdk_player.h (if you > did create mod from scratch) or hl2_player.h (if you did modify half-life > 2) > or hl2mp_player.h (if you did modify half-life 2 Deathmatch) you need to > add > the following: > > #define BOX_MODEL_NAME "models/props/barrelLid.mdl" > // > > > // > // > > > // > class CBox : public CBaseProp > { > public: > public: > DECLARE_CLASS( CBox, CBaseProp ); > typedef CBaseProp BaseClass; > > CBox(); > > //boolCreateVPhysics( void ); > voidSpawn( void ); > > virtual void Precache(); > > DECLARE_DATADESC(); > }; > > Then somewhere under class CSDKPlayer (or CHL2Player, or CHL2MPPlayer) add > > CBox *pBox; // This makes it a global variable so you can call it in both > the InitialSpawn, and on death. > > In sdk_player.cpp (or hl2_player.cpp or hl2mp_player.cpp) add the > following > somewhere near the top. > > BEGIN_DATADESC( CBox ) > > END_DATADESC() > > LINK_ENTITY_TO_CLASS( box, CBox ); > > > void CBox::Precache() > { > SetModel( BOX_MODEL_NAME ); > BaseClass::Precache(); > } > > CBox::CBox() > { > } > > > //- > // Purpose: > > //- > void CBox::Spawn( void ) > { > > Precache(); > SetModelName( MAKE_STRING( BOX_MODEL_NAME ) ); > > } > > > Then find the InitialSpawn() function and add the following: > > pBox = CREATE_ENTITY( CBox, "box" ); > > Vector origin = GetAbsOrigin(); > origin.z += 65; //Spawn above player, can be tweaked > > pBox->SetAbsOrigin(origin); > pBox->SetAbsAngles(GetAbsAngles()); > pBox->Spawn(); > pBox->SetParent(this); > > > Then, goto the Event_Killed( const CTakeDamageInfo &info ) > > and add UTIL_Remove(pBox); > > > That should be it, hope this helped. > -- > > ___ > To unsubscribe, edit your list preferences, or view the list archives, > please visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] Alright, I have tested this and it works, Simply, in sdk_player.h (if you did create mod from scratch) or hl2_player.h (if you did modify half-life 2) or hl2mp_player.h (if you did modify half-life 2 Deathmatch) you need to add the following: #define BOX_MODEL_NAME "models/props/barrelLid.mdl" // // // // class CBox : public CBaseProp { public: public: DECLARE_CLASS( CBox, CBaseProp ); typedef CBaseProp BaseClass; CBox(); //boolCreateVPhysics( void ); voidSpawn( void ); virtual void Precache(); DECLARE_DATADESC(); }; Then somewhere under class CSDKPlayer (or CHL2Player, or CHL2MPPlayer) add CBox *pBox; // This makes it a global variable so you can call it in both the InitialSpawn, and on death. In sdk_player.cpp (or hl2_player.cpp or hl2mp_player.cpp) add the following somewhere near the top. BEGIN_DATADESC( CBox ) END_DATADESC() LINK_ENTITY_TO_CLASS( box, CBox ); void CBox::Precache() { SetModel( BOX_MODEL_NAME ); BaseClass::Precache(); } CBox::CBox() { } //- // Purpose: //- void CBox::Spawn( void ) { Precache(); SetModelName( MAKE_STRING( BOX_MODEL_NAME ) ); } Then find the InitialSpawn() function and add the following: pBox = CREATE_ENTITY( CBox, "box" ); Vector origin = GetAbsOrigin(); origin.z += 65; //Spawn above player, can be tweaked pBox->SetAbsOrigin(origin); pBox->SetAbsAngles(GetAbsAngles()); pBox->Spawn(); pBox->SetParent(this); Then, goto the Event_Killed( const CTakeDamageInfo &info ) and add UTIL_Remove(pBox); That should be it, hope this helped. -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] Yes, sorry I forgot to add, //To parent it to the player (so that it moves with the player) pBox->SetParent(this); Im not 100% sure this will work, if it doesn't then in your original class change CPhysicsProp to CBaseProp, if that doesn't work change it to CDynamicProp. I can't test it right now, but tell me which one works. Thanks -=- -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
RE: [hlcoders] How to Create a Model Attached to the Player using only code.
Unless I'm grossly mistaken, this will spawn the box, but won't attach it to the player - I may be misreading the original request, but I thought it was more about spawning the box, attaching it to the player then detaching it when the player died. So Michaels code is a good start, but a bit more information is required to get the box moving with the player and falling away when the player dies. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Kramer Sent: 08 June 2006 05:01 To: hlcoders@list.valvesoftware.com Subject: Re: [hlcoders] How to Create a Model Attached to the Player using only code. -- [ Picked text/plain from multipart/alternative ] ahh, that formatted all weird, I will send it again: > Somewhere in player.cpp (or sdk_player.cpp, or hl2_player.cpp) you need to add a class like this: -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] Can we have someone put this up on the Wiki? On 6/8/06, Michael Kramer <[EMAIL PROTECTED]> wrote: > > -- > [ Picked text/plain from multipart/alternative ] > Sorry, it commented some of it, This should work now,: > > > Somewhere in player.cpp (or sdk_player.cpp, or hl2_player.cpp) you need to > add a class like this: > > #define BOX_MODEL_NAME "models/props/box.mdl" //replace with actual path > to > your .mdl of the model > > class CBox : public CPhysicsProp //Or just CBaseProp > { > public: > DECLARE_CLASS( CBox, CPhysicsProp ); > > typedef CPhysicsProp BaseClass; > CBox(); > > > bool CreateVPhysics( void ); > void Spawn( void ); > virtual void Precache(); > DECLARE_DATADESC(); > }; > > BEGIN_DATADESC( CBox ) > > END_DATADESC() > > LINK_ENTITY_TO_CLASS( box, CBox ); > > bool CBox::CreateVPhysics() > { > // Create the object in the physics system > IPhysicsObject *pPhysicsObject = VPhysicsInitNormal( SOLID_BBOX, 0,false > ); > > > // Make sure I get touch called for static geometry > if ( pPhysicsObject ) > { > > int flags = pPhysicsObject->GetCallbackFlags(); > flags |= CALLBACK_GLOBAL_TOUCH_STATIC; > > pPhysicsObject->SetCallbackFlags(flags); > > } > > > return true; > } > > void CBox::Precache() > { > SetModel( BOX_MODEL_NAME ); > BaseClass::Precache(); > } > > CBox::CBox() > > { > > } > > > //- > > // Purpose: > > > //- > > void CBox::Spawn( void ) > { > Precache(); > SetModelName( MAKE_STRING( BOX_MODEL_NAME ) ); > CreateVPhysics(); > } > > ///Then somehwere in either the player Spawn or Initial Spawn, add > something > like > > CBox *pBox = CREATE_ENTITY( CBox,"box" ); > > Vector origin = GetAbsOrigin(); //Get the players origin > origin.z += 50; //adjust accordingly, this makes it spawn above the player > > pBox->SetAbsOrigin( origin ); > pBox->SetAbsAngles( GetAbsAngles() ); > pBox->Spawn(); > -- > > ___ > To unsubscribe, edit your list preferences, or view the list archives, > please visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] Sorry, it commented some of it, This should work now,: Somewhere in player.cpp (or sdk_player.cpp, or hl2_player.cpp) you need to add a class like this: #define BOX_MODEL_NAME "models/props/box.mdl" //replace with actual path to your .mdl of the model class CBox : public CPhysicsProp //Or just CBaseProp { public: DECLARE_CLASS( CBox, CPhysicsProp ); typedef CPhysicsProp BaseClass; CBox(); bool CreateVPhysics( void ); void Spawn( void ); virtual void Precache(); DECLARE_DATADESC(); }; BEGIN_DATADESC( CBox ) END_DATADESC() LINK_ENTITY_TO_CLASS( box, CBox ); bool CBox::CreateVPhysics() { // Create the object in the physics system IPhysicsObject *pPhysicsObject = VPhysicsInitNormal( SOLID_BBOX, 0,false ); // Make sure I get touch called for static geometry if ( pPhysicsObject ) { int flags = pPhysicsObject->GetCallbackFlags(); flags |= CALLBACK_GLOBAL_TOUCH_STATIC; pPhysicsObject->SetCallbackFlags(flags); } return true; } void CBox::Precache() { SetModel( BOX_MODEL_NAME ); BaseClass::Precache(); } CBox::CBox() { } //- // Purpose: //- void CBox::Spawn( void ) { Precache(); SetModelName( MAKE_STRING( BOX_MODEL_NAME ) ); CreateVPhysics(); } ///Then somehwere in either the player Spawn or Initial Spawn, add something like CBox *pBox = CREATE_ENTITY( CBox,"box" ); Vector origin = GetAbsOrigin(); //Get the players origin origin.z += 50; //adjust accordingly, this makes it spawn above the player pBox->SetAbsOrigin( origin ); pBox->SetAbsAngles( GetAbsAngles() ); pBox->Spawn(); -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] ahh, that formatted all weird, I will send it again: > Somewhere in player.cpp (or sdk_player.cpp, or hl2_player.cpp) you need to add a class like this: #define BOX_MODEL_NAME "models/props/box.mdl" //replace with actual path to your .mdl of the model class CBox : public CPhysicsProp //Or just CBaseProp { public: DECLARE_CLASS( CBox, CPhysicsProp ); typedef CPhysicsProp BaseClass; CBox(); bool CreateVPhysics( void ); void Spawn( void ); virtual void Precache(); DECLARE_DATADESC(); }; BEGIN_DATADESC( CBox ) END_DATADESC() LINK_ENTITY_TO_CLASS( box, CBox ); bool CBox::CreateVPhysics() { // Create the object in the physics system IPhysicsObject *pPhysicsObject = VPhysicsInitNormal( SOLID_BBOX, 0,false ); // Make sure I get touch called for static geometry if ( pPhysicsObject ) { int flags = pPhysicsObject->GetCallbackFlags(); flags |= CALLBACK_GLOBAL_TOUCH_STATIC; pPhysicsObject->SetCallbackFlags(flags); } return true; } void CBox::Precache() { SetModel( BOX_MODEL_NAME ); BaseClass::Precache(); } CBox::CBox() { } //- // Purpose: //- void CBox::Spawn( void ) { Precache(); SetModelName( MAKE_STRING( BOX_MODEL_NAME ) ); CreateVPhysics(); } ///Then somehwere in either the player Spawn or Initial Spawn, add something like CBox *pBox = CREATE_ENTITY( CBox,"box" ); Vector origin = GetAbsOrigin(); //Get the players origin origin.z += 50; //adjust accordingly, this makes it spawn above the player pBox->SetAbsOrigin( origin ); pBox->SetAbsAngles( GetAbsAngles() ); pBox->Spawn(); -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] Alright this is what you need to have. Somewhere in player.cpp (or sdk_player.cpp, or hl2_player.cpp) you need to add a class like this: #define BOX_MODEL_NAME "models/props/box.mdl" //replace with actual path to your .mdl of the model class CBox : public CPhysicsProp //Or just CBaseProp { public: DECLARE_CLASS( CBox, CPhysicsProp ); typedef CPhysicsProp BaseClass; CBox(); bool CreateVPhysics( void ); void Spawn( void ); virtual void Precache(); DECLARE_DATADESC(); }; BEGIN_DATADESC( CBox ) END_DATADESC() LINK_ENTITY_TO_CLASS( box, CBox ); bool CBox::CreateVPhysics() { // Create the object in the physics system IPhysicsObject *pPhysicsObject = VPhysicsInitNormal( SOLID_BBOX, 0, false ); // Make sure I get touch called for static geometry if ( pPhysicsObject ) { int flags = pPhysicsObject->GetCallbackFlags(); flags |= CALLBACK_GLOBAL_TOUCH_STATIC; pPhysicsObject->SetCallbackFlags(flags); } return true; } void CBox::Precache() { SetModel( BOX_MODEL_NAME ); BaseClass::Precache(); } CBox::CBarrelLid() { } //- // Purpose: //- void CBox::Spawn( void ) { Precache(); SetModelName( MAKE_STRING( BOX_MODEL_NAME ) ); CreateVPhysics(); } ///Then somehwere in either the player Spawn or Initial Spawn, add something like CBox *pBox = CREATE_ENTITY( CBox, "box" ); Vector origin = GetAbsOrigin(); //Get the players origin origin.z += 50; //adjust accordingly, this makes it spawn above the player pBox->SetAbsOrigin( origin ); pBox->SetAbsAngles( GetAbsAngles() ); pBox->Spawn(); I hope this helps, On 6/7/06, Nick <[EMAIL PROTECTED]> wrote: > > -- > [ Picked text/plain from multipart/alternative ] > I have a problem, which I am sure has a simple solution, but I cannot find > it, and I have tried a great deal of things. > > > I want to create a model ( a box above a player's head), when a player > spawns, and I want to remove the model when the player dies. > > I have the model, and it works, but I cannot figure out how to place the > model when the player spawns, and remove it when the player dies. > > Please help, > > nick > -- > > ___ > To unsubscribe, edit your list preferences, or view the list archives, > please visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
[hlcoders] How to Create a Model Attached to the Player using only code.
-- [ Picked text/plain from multipart/alternative ] I have a problem, which I am sure has a simple solution, but I cannot find it, and I have tried a great deal of things. I want to create a model ( a box above a player's head), when a player spawns, and I want to remove the model when the player dies. I have the model, and it works, but I cannot figure out how to place the model when the player spawns, and remove it when the player dies. Please help, nick -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders