Frictional Games Forum (read-only)

Full Version: Throw an exploding object?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Is it possible to make something explode (a damaging explosion) when it is thrown and hits something with enough force?

If not, is it possible to instead make it explode when it is thrown into a specific Script Area (as opposed to carried into)?
(03-17-2012, 08:56 PM)Damascus Wrote: [ -> ]Is it possible to make something explode (a damaging explosion) when it is thrown and hits something with enough force?

If not, is it possible to instead make it explode when it is thrown into a specific Script Area (as opposed to carried into)?
There is no things that explode put you can always script it Smile for example take a rock and throw it at some boxes, use SetPropHealth so they break and some particles and some prop force and sound then you're done Smile


You can play with areas and sounds:

void OnStart()
{
AddEntityCollideCallback("SCRIPT_AREA", "ITEM_TO_EXPLODE", "function_explode", true, 1);
}

void function_explode(string &in asChild, string &in asParent, int alState)
{
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0, false);
SetPropHealth("ITEM_TO_EXPLODE", 0.0f);
StartScreenShake(1.0f, 2.0f, 1.0f, 2.0f);
}
(03-17-2012, 09:22 PM)ClayPigeon Wrote: [ -> ]You can play with areas and sounds:

void OnStart()
{
AddEntityCollideCallback("SCRIPT_AREA", "ITEM_TO_EXPLODE", "function_explode", true, 1);
}
void function_explode(string &in asChild, string &in asParent, int alState)
{
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0, false);
SetPropHealth("ITEM_TO_EXPLODE", 0.0f);
StartScreenShake(1.0f, 2.0f, 1.0f, 2.0f);
}
With this script though it would also destroy the item if you just carry it into the script area, which I would like to avoid. I also suppose there's no way to create an explosion no matter what you throw the object against? Creating particle systems and sounds depend largely on stationary script areas, but if you guys know of any way I can make the explosion happen anywhere, I'd love the advice.
(03-17-2012, 09:36 PM)Damascus Wrote: [ -> ]
(03-17-2012, 09:22 PM)ClayPigeon Wrote: [ -> ]You can play with areas and sounds:

void OnStart()
{
AddEntityCollideCallback("SCRIPT_AREA", "ITEM_TO_EXPLODE", "function_explode", true, 1);
}
void function_explode(string &in asChild, string &in asParent, int alState)
{
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0, false);
SetPropHealth("ITEM_TO_EXPLODE", 0.0f);
StartScreenShake(1.0f, 2.0f, 1.0f, 2.0f);
}
With this script though it would also destroy the item if you just carry it into the script area, which I would like to avoid. I also suppose there's no way to create an explosion no matter what you throw the object against? Creating particle systems and sounds depend largely on stationary script areas, but if you guys know of any way I can make the explosion happen anywhere, I'd love the advice.
I thought the idea is that the object that is carried will be exploded after entering an area, so I assumed it needs to be destroyed after exploding...

Anyway I am clueless about the explosion effect itself... I am weak with particle systems.
Basically the effect I'm trying to achieve is a grenade like effect. you throw the object, and when it hits something, it explodes. You are supposed to throw it against a blocked door to destroy it.
I don't know if theres get speed function, example when its over 1.9 (2 is the throwing speed and 1.5 is the running speed.)
(03-17-2012, 10:05 PM)Damascus Wrote: [ -> ]Basically the effect I'm trying to achieve is a grenade like effect. you throw the object, and when it hits something, it explodes. You are supposed to throw it against a blocked door to destroy it.
I don't think it's possible to be able to throw the object anywhere and make it explode like a grenade, it must more or less be inside a script area

You may be able to configure the entity properties so that it takes damage from impacts (see bottles for how this is done). You can either try issuing a callback on "breaking" the object to create the explosion (see SetEntityCallbackFunc).

As for determining what objects are nearby when the object breaks: You can always create an entity based of block_box with a large spherical mesh for a body and set this mesh entity to be the target entity after the grenade object breaks. Every object that then collides with this mesh can then be effected by the explosion somehow (if you want to be really fancy and apply impulses you may want to consider setting up an octtree to determine relative positions of entities and then applying an impulse along the vector and diminishing the intensity by an inverse square). Particle effects can be defined in the entity settings in the model editor for onbreak too.
I studied the section you were talking about, and saw that there are options for creating particle effects, sounds, and thrown objects when something hits hard enough. I probably won't be able to deal damage with it, but can probably achieve the explosion effect.

However, after thinking hard about it, I think it might make the game far too frustrating if the player throws it against the wrong object and loses the item, no longer able to advance in the game. But then, if I make it only explode when thrown against the right object, I risk making it look unrealistic. What to do... what to do...
Pages: 1 2 3