Jump to content

Trying to create an explosion on melee hit


Recommended Posts

Hey guys, I'm trying to get into modding and I'm at a task that I cant figure out.

So my goal with this task is to see if I can make a melee attack cause an explosion. I'm experimenting with the leather knuckles to see if I could pull this off.

 

I'm able to get a sound effect to play on hit, but the explosion part isnt working (the FX isnt working either but that parts just a quick experiment i pasted in). I'm using ammoArrowExplosive, ammoRocketFrag, and thrownAmmoPipeBomb as a reference for explosions. I'm also taking a look at Bow items and Rocketlauncher items to see how the go about handling explosives ammo. I've tried a few different methods, none seem to work. Another idea I had was to give knuckles the ammoArrowExplosive tag, and make it wo power attacks shoot an explosive arrow. But before I go about trying that out, I figured I'd make a post about my task so see what Im doing wrong.

 

<testing_sandbox>
    <!-- Attempting Explosion on Melee Hit -->
    <append xpath="/items/item[@name='meleeWpnKnucklesT0LeatherKnuckles']">
        <effect_group name="Power Attack">
          <!-- Sound on Hit testing (Working) -->
          <triggered_effect trigger="onSelfSecondaryActionRayHit" action="PlaySound" sound="stunbaton_hit5"/>

          <!-- Explosion on Hit (NOT working) -->
          <property name="Explosion.ParticleIndex" value="11"/>
          <property name="Explosion.RadiusBlocks" value="3"/>
          <property name="Explosion.RadiusEntities" value="4"/>
          <property name="Explosion.DamageBonus.stone" value=".3"/>
          <property name="Explosion.DamageBonus.metal" value=".1"/>
          <property name="Explosion.DamageBonus.earth" value="0"/>
          <property name="Explosion.DamageBonus.wood" value=".5"/>
          <property name="Explosion.DamageBonus.water" value="0"/>
          <property name="Explosion.BlockDamage" value="50"/>
          <property name="Explosion.EntityDamage" value="15"/>

          <!-- FX on Hit (NOT working) -->
          <property name="Particles_muzzle_fire" value="rocketLauncherFire"/>
          <property name="Particles_muzzle_smoke" value="nozzlesmoke_m136"/>
	</effect_group>
    </append>
</testing_sandbox>

 

Link to post
Share on other sites
Posted (edited)

So I tried a few things and im at a wall. I even tried looking at "zombieDemolition"  in the entityclasses.xml to see how it handles explosion, and my conclusion is that while I am seeing this line of code:

 

<property name="Explosion.ParticleIndex" value="11"/>
<property name="Explosion.RadiusBlocks" value="3"/>
<property name="Explosion.RadiusEntities" value="4"/>
<property name="Explosion.DamageBonus.stone" value=".3"/>
<property name="Explosion.DamageBonus.metal" value=".1"/>
<property name="Explosion.DamageBonus.earth" value="0"/>
<property name="Explosion.DamageBonus.wood" value=".5"/>
<property name="Explosion.DamageBonus.water" value="0"/>

<property name="Explosion.BlockDamage" value="50"/>
<property name="Explosion.EntityDamage" value="15"/>

 

to things, those things need to have code for handling the creation of an explosion. So for example, im trying to edit Leather Knuckles (meleeWpnKnucklesT0LeatherKnuckles) to cause an explosion on hit, and the code above sets value/info for the explosion, however the game's code has no function(?) for creating an explosion with Leather Knuckles, so I'd need a way to actually create the explosion (which I cant seem to find a way).

I wish I could use "triggered_effect" to do something like this:

<triggered_effect trigger="CreateExplosion">
  <property name="Explosion.ParticleIndex" value="11"/>
  <property name="Explosion.RadiusBlocks" value="3"/>
  <property name="Explosion.RadiusEntities" value="4"/>
  <property name="Explosion.DamageBonus.stone" value=".3"/>
  <property name="Explosion.DamageBonus.metal" value=".1"/>
  <property name="Explosion.DamageBonus.earth" value="0"/>
  <property name="Explosion.DamageBonus.wood" value=".5"/>
  <property name="Explosion.DamageBonus.water" value="0"/>

  <property name="Explosion.BlockDamage" value="50"/>
  <property name="Explosion.EntityDamage" value="15"/>
</triggered_effect>

 

 

Please let me know if I am somewhat correct, or completely wrong and there is a way to achieve my goal of explosions on melee hit, thanks!

Edited by Bladestorm Games (see edit history)
Link to post
Share on other sites

In essence, an explosion is just aoe damage with a particle effect.. Both of which are doable via buffs (or triggered effects). In code, it would be considered a hacky way to do things, but in gameplay it would look as if you caused an explosion when you attack... What I would do is create a particle (or use one in game, though i dont think you can use the normal explosion particles as they are an index), then add a triggered effect to the weapon in question. This would use the onselfattackedother trigger to apply a buff to target=selfAOE. This buff would deal the damage. Then, i'd also make another buff that would trigger the particle to be displayed on the target hit. Same concept.. onselfattackedother, add buff target=other, this buff would just display a particle.

Again, very hacky, but it would work...

  • Like 1
Link to post
Share on other sites

Thank you! I was able to get it to somewhat work, here is what I did:

 

Item: Leather Knuckles

<melee_explosion_test>
	<append xpath="/items/item[@name='meleeWpnKnucklesT0LeatherKnuckles']/effect_group[@name='Power Attack']">
		<triggered_effect trigger="onSelfAttackedOther" action="AddBuff" target="selfAOE" range="14" target_tags="zombie,animal" buff="buffApplyAoEDamage"/>
		<triggered_effect trigger="onSelfSecondaryActionRayHit" action="PlaySound" sound="explosion2"/>
	</append>
</melee_explosion_test>

 

 

New Buff: 

<melee_explosion_test>
	<append xpath="/buffs">
		<buff name="buffApplyAoEDamage" name_key="buffApplyAoEDamage">
			<stack_type value="effect"/>
			<duration value="1"/>
			<effect_group>
				<triggered_effect trigger="onSelfBuffStart" action="ModifyStats" stat="Health" operation="subtract" value="50"/>
			</effect_group>
		</buff>
	</append>
</melee_explosion_test>

 

 

I'm still trying to fix a few issues:

1) I have it set to Power Attack, but the effect seems to apply to regular (left mouse button) attack.

2) Getting kills with the AoE grants no XP.

3) Still looking at how/what particle to perform for the explosion FX.

Link to post
Share on other sites
4 hours ago, Bladestorm Games said:

I'm still trying to fix a few issues:

1) I have it set to Power Attack, but the effect seems to apply to regular (left mouse button) attack.

2) Getting kills with the AoE grants no XP.

3) Still looking at how/what particle to perform for the explosion FX.

 

1. Actually you don't have it set to Power Attack. Look at the trigger - it's "onSelfAttackedOther" not "onSelfSecondaryActionRayHit". So you're triggering the effect whenever you attack an "other".

2. That's tricky, since explosion damage in general doesn't grant you XP. (I don't think so anyway...)

3. I'd look at "buffShocked" - the buff applied to the stun baton - as an example. No idea what the "explosion" particle effect is, but you could probably just copy-and-paste the stun baton and replace the particle effect, at least as a starting point.

 

Also: For most weapons that apply status effects on multiple enemies (like stun batons) you actually want the target to be "otherAOE". 

Edited by khzmusik (see edit history)
  • Like 1
Link to post
Share on other sites

Thanks guys! I've made the update from "onSelfAttackedOther" to "onSelfSecondaryActionRayHit", and it works properly (normal attack doesn't proc the AoE stuff now)

 

Also, yeah I was looking at buffShocked earlier and did pretty much what you said, so now the custom buff looks like:

<append xpath="/buffs">
		<buff name="buffApplyAoEDamage" name_key="buffApplyAoEDamage">
			<stack_type value="effect"/>
			<duration value="1"/>
			
			<effect_group>
				<!-- Apply Damage -->
				<triggered_effect trigger="onSelfBuffStart" action="ModifyStats" stat="Health" operation="subtract" value="50"/>
				
				<!-- Apply FX -->
				<triggered_effect trigger="onSelfBuffStart" action="AttachParticleEffectToEntity" particle="p_electric_shock" parent_transform="Spine1" local_offset="0,-.2,0"/>
				<triggered_effect trigger="onSelfDied" action="RemoveParticleEffectFromEntity" particle="p_electric_shock"/>
				<triggered_effect trigger="onSelfBuffFinish" action="RemoveParticleEffectFromEntity" particle="p_electric_shock"/>
				<triggered_effect trigger="onSelfBuffRemove" action="RemoveParticleEffectFromEntity" particle="p_electric_shock"/>
				<triggered_effect trigger="onSelfBuffRemove" action="ModifyCVar" cvar="ETrapHit" operation="set" value="0"/>
				<triggered_effect trigger="onSelfLeaveGame" action="RemoveParticleEffectFromEntity" particle="p_electric_shock"/>
		</effect_group>
	</buff>
</append>

 

Oh also khzmusik, you said in general explosion damage (kills?) dont grant XP, but I've gotten XP from Rocket Frags and Explosive Arrow and Pipebombs, so explosion damage / kill should be granting exp? (Perhaps someway for the buff to check if the entity's "health <= 0", then grant enemy's exp to player(s), after the damage calculation)

 

Final note is that, if I find a way to make the Explosion FX, I'll be moving it out from the buff section, as it would be strange if the AoE hits, say 3 targets, and explosions apply at each of the 3 target's location. 

 

Thanks for the tips & help!

Link to post
Share on other sites
5 hours ago, Bladestorm Games said:

Oh also khzmusik, you said in general explosion damage (kills?) dont grant XP, but I've gotten XP from Rocket Frags and Explosive Arrow and Pipebombs, so explosion damage / kill should be granting exp? (Perhaps someway for the buff to check if the entity's "health <= 0", then grant enemy's exp to player(s), after the damage calculation)

 

Final note is that, if I find a way to make the Explosion FX, I'll be moving it out from the buff section, as it would be strange if the AoE hits, say 3 targets, and explosions apply at each of the 3 target's location. 

 

Thanks for the tips & help!

 

Oh, duh, of course. I was thinking of land mines, but that makes sense because that's trap damage. I'm not sure why the added explosion damage means you aren't getting XP on a melee weapon.

 

Also, I thought that you wanted the explosions to apply for each of the 3 targets. If you want the explosion particle effect to only be triggered on the enemy you hit, but the explosion damage to be applied to an AOE, that's doable but a bit trickier. I'm not sure you should do this though - you probably want the explosion effect as a visual indicator that the explosion did damage to particular entities. Your call though.

 

EDIT: Also you probably want something other than "onSelfSecondaryActionRayHit" but I'm not sure what that would be. Since TFP went to hitting multiple targets in one swing ("ray"), I don't know if they even differentiate between the "primary" target and others that you hit in the same swing.

Edited by khzmusik (see edit history)
  • Like 1
Link to post
Share on other sites

I guess I should clarify my design goal. So I was hoping that I could make a mod where Leather Knuckles (or any fist weapon) would create an explosion on Power Attack (explosion meaning like Explosive Arrow's explosion, the FX and the area damage, where damage effects enemies and blocks).

 

It is probably possible to add a bit more to the current code to make AoE damage effect both enemies and blocks. I was also thinking of making the fist weapon have a hidden ammo slot with the ammo used being Explosive Arrow ammo, but trying to make it so with 0 arrows it still shoots an explosive arrow on Power Attack. But that seems even more complicated to get working than the current code. I wish there was a way to "create" explosions used by things like Rockets, Explosive Arrows, Pipebomb, etc, and assign values to the explosion (Range, Entity Damage, Block Damage, Explosion FX Size, etc).

I think for now I'll leave the "Explosion on Melee Hit" goal, as I am working on some other ideas (I've made it where the 2-handed Sledges (stone, iron, steel) perform an AoE Power Attack that knocks enemies in an area down, while playing an earthquake-like sound (sound being "stonedestroy3"), which turned out really cool & fun.)

Again thanks to all who have chimed in on this task, I learned a lot from you guys!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...