How to make a bomb can damage its thrower?

16-bit Fighter

Active member
When an enemy throws something which can damage the other enemies, it's not the case for the thrower. How to make it possible please?
 
this is a parenting/owning thing. You can make the entity become "orphan" (and thus, not have a parent) to make it interact with whoever threw it.
Would you need a script for that?
 
Can we see your bomb text?
Sure, here it is:
name dynamite
type enemy
health 1
speedf 1
jumpheight 3.5
gfxshadow 1
shadow 1
toflip 1
candamage player npc obstacle
nolife 0
remove 1
jugglepoints 5


animationscript data/scripts/grabscript_complete.c


anim idle
loop 1
delay 2
offset 11 19
bbox 3 3 16 16
burn 3 3 16 16 10 1 1 0 5 15 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna101.png
frame data/chars/rad/dynamite/dyna102.png
frame data/chars/rad/dynamite/dyna103.png
frame data/chars/rad/dynamite/dyna104.png

anim death
loop 0
delay 99
offset 74 102
frame data/chars/misc/empty.gif
@cmd killentity getlocalvar("self")
frame data/chars/misc/empty.gif

anim attack2
loop 0
delay 5
offset 26 63
@cmd gravity 0
@cmd candamage "type_player" "type_npc" "type_enemy" "type_obstacle"
frame data/chars/rad/dynamite/dyna203.png
burn 14 40 30 20 10 1 1 0 5 17 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna204.png
sound data/sounds/boom.wav
burn 1 20 50 40 10 1 1 0 5 17 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna205.png
burn 1 6 50 40 0 1 1 0 5 17 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna206.png
frame data/chars/rad/dynamite/dyna207.png
burn 0 0 0 0
frame data/chars/rad/dynamite/dyna208.png
frame data/chars/rad/dynamite/dyna209.png
frame data/chars/rad/dynamite/dyna210.png
frame data/chars/rad/dynamite/dyna211.png
frame data/chars/rad/dynamite/dyna212.png
@cmd killentity getlocalvar("self")
frame data/chars/misc/empty.gif

anim attack1
loop 0
delay 7
offset 26 63
bbox 14 40 20 12
@cmd candamage "type_player" "type_npc" "type_enemy" "type_obstacle"
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna202.png
delay 5
frame data/chars/rad/dynamite/dyna203.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna203.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna203.png
frame data/chars/rad/dynamite/dyna203.png
frame data/chars/rad/dynamite/dyna201.png
frame data/chars/rad/dynamite/dyna203.png
frame data/chars/rad/dynamite/dyna202.png
frame data/chars/rad/dynamite/dyna203.png
burn 14 40 30 20 10 1 1 0 5 17 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna204.png
sound data/sounds/boom.wav
burn 1 20 50 40 10 1 1 0 5 17 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna205.png
burn 1 6 50 40 10 1 1 0 5 17 //
dropv 4 2 0
frame data/chars/rad/dynamite/dyna206.png
frame data/chars/rad/dynamite/dyna207.png
burn 0 0 0 0
frame data/chars/rad/dynamite/dyna208.png
frame data/chars/rad/dynamite/dyna209.png
frame data/chars/rad/dynamite/dyna210.png
frame data/chars/rad/dynamite/dyna211.png
frame data/chars/rad/dynamite/dyna212.png
@cmd killentity getlocalvar("self")
frame data/chars/misc/empty.gif

anim pain
loop 0
delay 99
loop 1 1 1
offset 74 102
frame data/chars/misc/empty.gif
@cmd killentity getlocalvar("self")
frame data/chars/misc/empty.gif
 
Look carrefully, it's already the case in there. ;)


That only affects the enemies other than the thrower/parent.
Code:
@cmd candamage "type_player" "type_npc" "type_enemy" "type_obstacle"

Why you used this and it's not on the enemy header?
sorry I just try to better understand the purpose

Code:
candamage player npc obstacle
 
You have a two pronged issue here. First, it doesn't matter what candamage settings you give a projectile. When thrown using the native projectile system it is overridden using the thrower's candamage settings. Next, projectiles (including bombs) are designed to never hit their owner, no matter what the candamage settings are. This makes logical sense when you think about it, because when a projectile is first thrown, its hitbox is usually touching the thrower's body box.

When a projectile spawns, the engine populates the projectile's owner property with the entity that threw it. Hit detection logic looks for the owner property on the entity that is hitting, and if it's populated, compares owner to the target entity. If they match, the hit is canceled.

To work around these, you need to use script to set up the candamage after projectile spawns, and also clear the projectile's owner property.

C:
void acting_entity = getlocalvar("self");
int can_damage = openborconstant("TYPE_PLAYER") | openborconstant("TYPE_ENEMY") | openborconstant("TYPE_NPC") | openborconstant("TYPE_OBSTACLE");

changeentityproperty(acting_entity, "owner", NULL());
changeentityproperty(acting_entity, "candamage", can_damage);

Note clearing the owner property does have a side effect. The owner property is also how the engine knows who to give credit to when the projectile hits something. So if you want to get points for the bomb hitting enemies and have them show up in the HUD, you'll need to handle those manually with script as well.

HTH,
DC
 
Code:
@cmd candamage "type_player" "type_npc" "type_enemy" "type_obstacle"

Why you used this and it's not on the enemy header?
sorry I just try to better understand the purpose

Code:
candamage player npc obstacle
It's on purpose. When the enemy throws the dynamite stick it can't damage the other enemies, as if these ones avoid the danger. But when it exploses nobody near the blow can be safe. Maybe it's a stange logic. ATM I've decided that.
Besides that I wonder if it's realistic that a dynamite stick can explose by hitting something or someone. But I guess yes since TNT is an unstable explosive. That said I'm way far from being an expert of weapon. ^^'

@DCurrent
Thank you very much for the script and all the explanations!
Actually if I want the bomb can damage the thrower it's because between the moment when the dynamite stick touch the ground and it exploses, there's a certain time.
 
Back
Top Bottom