Raised This Month: $51 Target: $400
 12% 

Make grenade shootable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
grankee
Member
Join Date: Jun 2008
Old 11-19-2015 , 13:18   Make grenade shootable
Reply With Quote #1

Hello. I try to make grenade shootable. Only what I can do is make grenade sensitive for damage but can't take damage from bullets. For ex. if decoy or molotov blow close to grenade it will blow but whenever i try to shoot it nothing happen.

I tried whatever I found, maybe some of funcions I used unnecessarily but tried whatever.

Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <smlib>

public Plugin:myinfo = 
{
	name = "New Plugin",
	author = "Unknown",
	description = "<- Description ->",
	version = "1.0",
	url = "<- URL ->"
}

public OnPluginStart()
{
	
	//RegConsoleCmd("buton",FindButton,"znajduje button",0)
}
/*public Action:FindButton(client,args)
{
	
	new ent=FindEntityByClassname(-1,"func_button")
	PrintToConsole(client,"button numer : %d",ent)
	
}*/
//public Action:HookFunc(Handle:Timer)




public OnEntityCreated(entity,const String:Classname[])
{	
	//PrintToChatAll("glowne Entity:%s",Classname);
	if(StrContains(Classname,"hegrenade_projectile")!=-1)
	{
		PrintToChatAll("Entity:%s",Classname);
		SDKHook(entity,SDKHook_SpawnPost,spawned_grenade)
	}

} //
public Action:spawned_grenade(entity)
{
	CreateTimer(0.1,BlockGrenade,entity)
	
	//RemoveEdict(entity)
	PrintToChatAll("Spawned hegrenade");
	return Plugin_Continue;
}
public Action:BlockGrenade(Handle:Timer,any:entity)
{
	SetEntProp(entity, Prop_Data, "m_nNextThinkTick", -1);
	/*new Float:position[3];
	GetEntPropVector(entity, Prop_Send, "m_vecOrigin", position);
	PrintToChatAll("Pozycja: %f %f %f",position[0],position[1],position[2])*/
	//new dmg=GetEntProp(entity, Prop_Data, "m_takedamage");
	new Float:abs[3],Float:abs2[3]
	/*Entity_GetMinSize(entity,abs)
	PrintToChatAll("minsize: %f %f %f",abs[0],abs[1],abs[2])
	Entity_GetMaxSize(entity,abs)
	PrintToChatAll("maxsize: %f %f %f",abs[0],abs[1],abs[2])*/
	abs[0]=-15.0
	abs[1]=-15.0
	abs[2]=-15.0
	abs2[0]=15.0
	abs2[1]=15.0
	abs2[2]=15.0
	Entity_SetMinMaxSize(entity,abs,abs2)
	PrintToChatAll("Movetype=%d |takedmg:%d | colgroup:%d | solidtype:%d | maxhealth:%d | helath:%d",
		GetEntityMoveType(entity),
		GetEntProp(entity,Prop_Data,"m_takedamage"),
		GetEntProp(entity,Prop_Data,"m_CollisionGroup"),
		GetEntProp(entity,Prop_Data,"m_nSolidType"),
		GetEntProp(entity,Prop_Data,"m_iMaxHealth"),
		GetEntProp(entity,Prop_Data,"m_iHealth")
		);
	SetEntProp(entity, Prop_Data, "m_takedamage",2);
	SetEntProp(entity, Prop_Data, "m_CollisionGroup", 3);
	SetEntProp(entity, Prop_Send, "m_CollisionGroup", 3);
	SetEntProp( entity, Prop_Data, "m_nSolidType", 6 );
	SetEntProp( entity, Prop_Send, "m_nSolidType", 6 );
	SetEntProp(entity, Prop_Data, "m_iMaxHealth", 2);
	SetEntProp(entity, Prop_Data, "m_iHealth", 1);
	SetEntPropFloat(entity,Prop_Data,"m_flDamage",200.0)

}
grankee is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-19-2015 , 13:41   Re: Make grenade shootable
Reply With Quote #2

I think you need to find out a hook or native that allows you to get the damage type when the nade gets damaged.
Then check if its a weapon and manually take care of the grenade exploding.
I don't know how exactly to do this though unfortunately.
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
grankee
Member
Join Date: Jun 2008
Old 11-19-2015 , 17:28   Re: Make grenade shootable
Reply With Quote #3

Problem is not force grenade to blow, problem is detect that grenade was shooted, because grenade is like...untouchable for weapon bullets, but any other damage is taken by it ex. molotov fire, decoy explode...

I check properties of weapon_grenade (this one is shootable, effect is jump randomly) and has
Code:
SetEntityMoveType(entity,MOVETYPE_FLYGRAVITY)
	SetEntProp(entity, Prop_Data, "m_takedamage",1);
	SetEntProp(entity, Prop_Data, "m_CollisionGroup", 11);
	SetEntProp(entity, Prop_Send, "m_CollisionGroup", 11);
        //last two are 0 for weapon_hegrenade but I have to change
	SetEntProp(entity, Prop_Data, "m_iMaxHealth", 2);
	SetEntProp(entity, Prop_Data, "m_iHealth", 1);
but do nothing for me when I set for hegrenade_projectile
grankee is offline
grankee
Member
Join Date: Jun 2008
Old 11-20-2015 , 19:33   Re: Make grenade shootable
Reply With Quote #4

Ok I used weapon_grenade (i can hook throw and just replace by drop weapon_grenade-thats simple), this class is shootable, but now i have another problem, i tried to change size but doesn't work, i need to make a larger area for grenade to be shooted, not much but bigger, in future I want to replace model for mine and will be larger. Am I right if change model won't change shootable area of entity?
Also change model won't change touchable area? That's my another problem.

I tried to create entity on my grenade origin as a trigger and make it larger, then when I'll touch my trigger i can hook and call my entity to do some action but I have a problem, my entity is not touchable...when i go into it touch hook is not called.

Code:
new iHegrenade=Entity_Create("prop_physics_override")
	PrintToChatAll("hegren zrobiony: %d",iHegrenade)
	new Float:vecOrigin[3]
	Entity_GetAbsOrigin(iWeaponId,vecOrigin)
	Entity_SetAbsOrigin(iHegrenade,vecOrigin)//set origin to the same like grenade
	new Float:abs[3],Float:abs2[3]
	abs[0]=-40.0
	abs[1]=-40.0
	abs[2]=-4.0
	abs2[0]=40.0
	abs2[1]=40.0
	abs2[2]=40.0
	Entity_SetMinMaxSize(iHegrenade,abs,abs2)
	SetEntityMoveType(iHegrenade,MOVETYPE_FLYGRAVITY)
	SetEntProp(iHegrenade, Prop_Data, "m_nSolidType", SOLID_BBOX);
	SetEntProp(iHegrenade, Prop_Send, "m_nSolidType", SOLID_BBOX);
	SetEntProp(iHegrenade, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_WEAPON);
	SetEntProp(iHegrenade, Prop_Send, "m_CollisionGroup", COLLISION_GROUP_WEAPON);
	SetEntProp(iHegrenade,Prop_Data,"m_usSolidFlags",136)
	SetEntPropEnt(iHegrenade,Prop_Data,"m_hOwnerEntity",iWeaponId)
	DispatchSpawn(iHegrenade)
	SDKHook(iHegrenade,SDKHook_Touch,GrenadeTriggerTouched)
grankee is offline
MegasToRM
Member
Join Date: May 2012
Location: Serbia
Old 11-21-2015 , 12:39   Re: Make grenade shootable
Reply With Quote #5

Quote:
Originally Posted by grankee View Post
Ok I used weapon_grenade (i can hook throw and just replace by drop weapon_grenade-thats simple), this class is shootable, but now i have another problem, i tried to change size but doesn't work, i need to make a larger area for grenade to be shooted, not much but bigger, in future I want to replace model for mine and will be larger. Am I right if change model won't change shootable area of entity?
Also change model won't change touchable area? That's my another problem.

I tried to create entity on my grenade origin as a trigger and make it larger, then when I'll touch my trigger i can hook and call my entity to do some action but I have a problem, my entity is not touchable...when i go into it touch hook is not called.

Code:
new iHegrenade=Entity_Create("prop_physics_override")
	PrintToChatAll("hegren zrobiony: %d",iHegrenade)
	new Float:vecOrigin[3]
	Entity_GetAbsOrigin(iWeaponId,vecOrigin)
	Entity_SetAbsOrigin(iHegrenade,vecOrigin)//set origin to the same like grenade
	new Float:abs[3],Float:abs2[3]
	abs[0]=-40.0
	abs[1]=-40.0
	abs[2]=-4.0
	abs2[0]=40.0
	abs2[1]=40.0
	abs2[2]=40.0
	Entity_SetMinMaxSize(iHegrenade,abs,abs2)
	SetEntityMoveType(iHegrenade,MOVETYPE_FLYGRAVITY)
	SetEntProp(iHegrenade, Prop_Data, "m_nSolidType", SOLID_BBOX);
	SetEntProp(iHegrenade, Prop_Send, "m_nSolidType", SOLID_BBOX);
	SetEntProp(iHegrenade, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_WEAPON);
	SetEntProp(iHegrenade, Prop_Send, "m_CollisionGroup", COLLISION_GROUP_WEAPON);
	SetEntProp(iHegrenade,Prop_Data,"m_usSolidFlags",136)
	SetEntPropEnt(iHegrenade,Prop_Data,"m_hOwnerEntity",iWeaponId)
	DispatchSpawn(iHegrenade)
	SDKHook(iHegrenade,SDKHook_Touch,GrenadeTriggerTouched)
I'm not an expert in this area, but maybe you could create an entity that would mimic grenade's properties?
In AMXX, I'd create an entity and make it damageable, and when it's damaged, I'd create an explosion (create a blast msg and deal damage to nearby players).
I'm not 100% sure, but I guess it can be done here too.
MegasToRM is offline
Send a message via MSN to MegasToRM Send a message via Skype™ to MegasToRM
grankee
Member
Join Date: Jun 2008
Old 11-21-2015 , 14:45   Re: Make grenade shootable
Reply With Quote #6

Ok what i need to do is bouncy betty.
My idea is, when player cilck fire button I'll drop grenade (already done).
now if player shoot it must explode, but shootable area is exactly within grenade model. I didn't check what's gonna happen if I'll change model because I don't have ready model yet, but I think it change nothing...

Another problem is make a motion sensor in 6m area around betty. Of course i can check in prethink distance between betty and all enemies but it is not optimal solution. My idea is breate an entitym on my grenade with correct size and hook touch between player and this trigger (as to touch grenade requires step on it, i need makle it more sensitive from longer distance) and then blow grenade (grenade explosion is not a problem too).
grankee is offline
MegasToRM
Member
Join Date: May 2012
Location: Serbia
Old 11-21-2015 , 15:06   Re: Make grenade shootable
Reply With Quote #7

Quote:
Originally Posted by grankee View Post
Ok what i need to do is bouncy betty.
My idea is, when player cilck fire button I'll drop grenade (already done).
now if player shoot it must explode, but shootable area is exactly within grenade model. I didn't check what's gonna happen if I'll change model because I don't have ready model yet, but I think it change nothing...

Another problem is make a motion sensor in 6m area around betty. Of course i can check in prethink distance between betty and all enemies but it is not optimal solution. My idea is breate an entitym on my grenade with correct size and hook touch between player and this trigger (as to touch grenade requires step on it, i need makle it more sensitive from longer distance) and then blow grenade (grenade explosion is not a problem too).
Why not create an entity on grenade drop?
I mean, create an entity with that size, and hook its touch, and after that invoke grenade explosion?
Also, isn't there any entity think option(for scanning the area for players), or some sort of min/max size(for touch trigger option), like in amxmodx?

If you would try that, you can use this:
http://websvn.dataviruset.com/filede...es.inc&peg=165
There are Entity_SetMinSize/Entity_SetMaxSize stocks so I guess that could help, but beware, if you change entity's height, model may look like it's floating in the air, because I think entity origin is in the middle of its box.

Last edited by MegasToRM; 11-21-2015 at 15:06.
MegasToRM is offline
Send a message via MSN to MegasToRM Send a message via Skype™ to MegasToRM
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-21-2015 , 17:43   Re: Make grenade shootable
Reply With Quote #8

I'm thinking wrap a trigger_multiple around it and use good old parenting.

Yes you have the corners trigger but it would close enough if you get the size and rotation angles right.

Thats how I make my throwing knives work.
__________________
Neuro Toxin is offline
grankee
Member
Join Date: Jun 2008
Old 11-21-2015 , 18:12   Re: Make grenade shootable
Reply With Quote #9

Ok so what i know at the moment is: only model of entity is touchable. When I set model for my entity it started to be touchable and touch hook started to fire function. I'll try work with this and update info here for futhure, maybe somebody will try do this so I'll try give solution on this topic.


@Neuro Toxin:
Could you provide good working method do create trigger_multiple and make it work, please?

Last edited by grankee; 11-21-2015 at 18:14.
grankee is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-21-2015 , 18:26   Re: Make grenade shootable
Reply With Quote #10

Um. You need to test if a trigger multiple can be fired from a bullet. Maybe func_breakable would be more appropriate.

You would spawn the entity. Teleport it to the location and angles of the grenade. Set its mins/maxs. And of course, parent it.

With this being said. Try what your doing first.

Edit:

https://forums.alliedmods.net/showthread.php?p=1992342

You can use this plugin to learn. Rip root_!!!!!!!
__________________

Last edited by Neuro Toxin; 11-21-2015 at 18:27.
Neuro Toxin 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 07:49.


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