Raised This Month: $ Target: $400
 0% 

Prop_dynamic and Collisions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 10-14-2009 , 02:05   Prop_dynamic and Collisions
Reply With Quote #1

Was having a hell of a time getting collsions from a prop_dynamic_override entity. Searched up and down the forums and nothing! I couldn't use prop_physics_override because I needed to attach this model to the player but still have it detect collsions. Without further ado here is the code hopefully it will help someone and prevent lot of grief in the future.

PHP Code:
public Action:Attach_Shield(client)
{
 new 
ent CreateEntityByName("prop_dynamic_override");
 if ( 
ent == -)
 {
  
ReplyToCommandclient"Failed to create a Shield!" );
  return 
Plugin_Handled;
 }
 
 
//Set the model, use your own model this won't work for you ;)
 
SetEntityModel(entMODEL_SHIELD01);
 
 
//make sure to do this before we actually spawn the P.O.S.
 
SetEntProp(entProp_Data"m_takedamage"2); 
 
 
DispatchSpawn(ent);
 
 new 
String:playerName[128];
 
Format(playerNamesizeof(playerName), "target%i"client);
 
DispatchKeyValue(client"targetname"playerName);
 
 
//Set the Shield's owner
 
SetEntPropEnt(entProp_Send"m_hOwnerEntity"client);
 
 
//Parent the shield to the player
 
SetVariantString(playerName);
 
AcceptEntityInput(ent"SetParent");
 
 
//Attach the shield to the 'flag'
 
SetVariantString("flag");
 
AcceptEntityInput(ent"SetParentAttachment");
 
 new 
iTeam GetClientTeam(client);
 
SetVariantInt(iTeam);
 
AcceptEntityInput(ent"TeamNum", -1, -10);
 
SetVariantInt(iTeam);
 
AcceptEntityInput(ent"SetTeam", -1, -10); 
 
//Yes! Again
 
SetEntProp(entProp_Data"m_takedamage"2); 
 
 
SetEntPropEnt(entProp_Data"m_hLastAttacker"client);
 
//Use the shields VPhysics for collisions
 
SetEntPropentProp_Data"m_nSolidType");
 
SetEntPropentProp_Send"m_nSolidType");
 
//Only detect bullet/damage collisions
 
SetEntProp(entProp_Data"m_CollisionGroup"2);
 
SetEntProp(entProp_Send"m_CollisionGroup"2);
 
 
//Set the shield's health
 
SetEntProp(entProp_Data"m_iMaxHealth"100);
 
SetEntProp(entProp_Data"m_iHealth"100);
 
 
//wait Wah? That doesn't make sense
//but it works!
 
AcceptEntityInputent"DisableCollision" );
 
AcceptEntityInputent"EnableCollision" );
 
 
HookSingleEntityOutput(ent"OnTakeDamage"shieldDamagefalse);
 
 return 
Plugin_Handled;
}
 
public 
shieldDamage (const String:output[], calleractivatorFloat:delay)
{
 
//your damage code goes here 

__________________

Last edited by FoxMulder; 10-14-2009 at 12:21.
FoxMulder is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 10-14-2009 , 04:56   Re: Prop_dynamic and Collisions
Reply With Quote #2

awesome. thanks a lot.
Thrawn2 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode