• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

What is wrong with my mod?

Noisy Pants

Refugee
I made a mod that I named, "Electric Eel Trap", it works great except for a small problem - if you shocked then you'll continue going around with the shock sound/visual animation on your character till you exit the game. The continued sound/visual shock animation does not have a negative impact on the character past a certain point. I don't recall this problem in Alpha 18 so I'm not sure where to start looking for issues.

<config>
<append xpath="/blocks">

<block name="Electric Eel Trap">
<property name="CreativeMode" value="Player"/>
<property name="CustomIcon" value="Electric Eel Trap"/>
<property name="Class" value="Liquidv2"/>
<property name="Material" value="Mwater"/>
<property name="Shape" value="Water"/>
<property name="Mesh" value="water"/>
<property name="Model" value="water_full"/>
<property name="Texture" value="223"/>
<property name="Map.Color" value="0,0,0"/>
<property name="Map.Color" value="0,0,0"/>
<property name="BuffsWhenWalkedOn" value="buffShocked"/>
<property name="BuffChance" value="1"/>
<property name="DescriptionKey" value="Shocks, slows, and deals damage to entities that come in contact with the trap."/>
<property name="Path" value="solid"/>
<property name="Group" value="Tools/Traps,Science"/>
<property name="SortOrder1" value="70g0"/>
<property name="FilterTags" value="fdecor,felectrical,ftraps"/>
</block>

</append>
</config>


I don't know if this information helps any yet in the logs this information shows up quite a few times:
 

NullReferenceException: Object reference not set to an instance of an object
  at ItemActionAttack.Hit (World _world, WorldRayHitInfo hitInfo, System.Int32 _attackerEntityId, EnumDamageTypes _damageType, System.Single _blockDamage, System.Single _entityDamage, System.Single _staminaDamageMultiplier, System.Single _weaponCondition, System.Single _criticalHitChance, System.Single _dismemberChance, System.Single _dismemberBonusOLD, System.String _attackingDeviceMadeOf, DamageMultiplier _damageMultiplier, System.Collections.Generic.List`1[T] _buffActions, ItemActionAttack+AttackHitInfo _attackDetails, System.Int32 actionExp, System.Single actionExpBonus, ItemActionAttack rangeCheckedAction, System.Collections.Generic.Dictionary`2[TKey,TValue] _toolBonuses, ItemActionAttack+EnumAttackMode _attackMode, System.Boolean _bAllowHarvestingParticles, System.Boolean _bIsGrazingHit, System.Boolean _isElectricTrapAttack, System.Collections.Generic.Dictionary`2[TKey,TValue] _hitSoundOverrides, System.Int32 ownedEntityId, ItemValue damagingItemValue) [0x00806] in <bb2961016a004bd4bf77288a67df32f1>:0
  at AutoTurretFireController.Fire () [0x001ea] in <bb2961016a004bd4bf77288a67df32f1>:0
  at AutoTurretFireController.Update () [0x0046c] in <bb2961016a004bd4bf77288a67df32f1>:0
 
(Filename: <bb2961016a004bd4bf77288a67df32f1> Line: 0)


electriceeltrap.jpg

 
Last edited by a moderator:
Um, I thought this was a one off type of thing, but now I am not so sure . . .

Last night playing co-op with my wife I accidentally tried to wrench a working vending machine, as expected it shocked me and I stopped being a dumbdumbhead. What was unexpected is that when I finally got back to our base 20-30 minutes later, she was like "What is that sound?" and that when we realized that the shock effect was still going off. I had to log out to make it go away.

More testing to see if it is a bug, perhaps?

 
I think it is necessary to add the effect group line at the beginning of the shocked effect and close it with the same effet group.

 
Not much to go on, you're showing an excerpt from the log, but it's hard to track down if we don't see the whole code. Speaking of the code, I'm not a buff expert, but you should probably check your buff and make sure it's starting and finishing properly.

Also this thread should go into Discussions and requests.
mr.devolver - My apologies, I'll remember to place it correctly next time. As for the, "not much to go on", the only thing the log shows regarding the trap is what I shared (many times over); would it help if I shared the whole log? I use the game's shock buff, although it may not be a bad idea to make a custom shock buff - if I could figure out to make a effective shock buff.

everyone one - feel free to tinker with my mod: https://drive.google.com/file/d/1XSqEpv3j1LO7NM2jEQMotGMA1OELOaYj/view?usp=sharing
 

electriceeltrapmod.JPG

 
hard to parse code on the phone, but when something adds a buff to an entity, usually there is a duration passed to the buff code. For example, you could call the healing buff but if you don't say how much, it does nothing. If you are calling the buffshocked buff, make sure you send it what it needs or it won't work.

You can look at the stun baton for reference 

 
hard to parse code on the phone, but when something adds a buff to an entity, usually there is a duration passed to the buff code. For example, you could call the healing buff but if you don't say how much, it does nothing. If you are calling the buffshocked buff, make sure you send it what it needs or it won't work.

You can look at the stun baton for reference 
<effect_group name="apply damage buff, meleeWpnBatonT1JunkBaton">
<requirement name="CVarCompare" cvar="stunBatonCharge" operation="GTE" value="40"/>
<triggered_effect trigger="onSelfEquipStart" action="AddPart" part="Sparks" prefab="ItemModEffects/baton_electricityPrefab" parentTransform="Handle" localPos="0,0,0" localRot="0,0,0"/>

<triggered_effect trigger="onSelfPrimaryActionRayHit" action="Ragdoll" target="other" duration="2.5" force="200">
<requirement name="HasBuff" buff="buffmodMeleeStunBatonRepulsor"/>
<requirement name="!HasBuff" buff="buffDrugNerdTats"/>
<requirement name="!EntityTagCompare" target="other" tags="trader"/>
</triggered_effect>
<triggered_effect trigger="onSelfSecondaryActionRayHit" action="Ragdoll" target="other" duration="2.5" force="200">
<requirement name="HasBuff" buff="buffmodMeleeStunBatonRepulsor"/>
<requirement name="!HasBuff" buff="buffDrugNerdTats"/>
<requirement name="!EntityTagCompare" target="other" tags="trader"/>
</triggered_effect>

<triggered_effect trigger="onSelfPrimaryActionRayHit" action="Ragdoll" target="otherAOE" range="1.1" target_tags="zombie,animal" duration="2.5" force="200">
<requirement name="HasBuff" buff="buffmodMeleeStunBatonRepulsor"/>
<requirement name="HasBuff" buff="buffDrugNerdTats"/>
</triggered_effect>
<triggered_effect trigger="onSelfSecondaryActionRayHit" action="Ragdoll" target="otherAOE" range="1.1" target_tags="zombie,animal" duration="2.5" force="200">
<requirement name="HasBuff" buff="buffmodMeleeStunBatonRepulsor"/>
<requirement name="HasBuff" buff="buffDrugNerdTats"/>
</triggered_effect>

<triggered_effect trigger="onSelfPrimaryActionRayHit" action="AddBuff" target="other" buff="buffShocked"/>
<triggered_effect trigger="onSelfSecondaryActionRayHit" action="AddBuff" target="other" buff="buffShocked"/>

<triggered_effect trigger="onSelfPrimaryActionRayHit" action="AddBuff" target="otherAOE" range="1.1" target_tags="zombie,animal" buff="buffShocked">
<requirement name="HasBuff" buff="buffDrugNerdTats"/>
</triggered_effect>
<triggered_effect trigger="onSelfSecondaryActionRayHit" action="AddBuff" target="otherAOE" range="1.3" target_tags="zombie,animal" buff="buffShocked">
<requirement name="HasBuff" buff="buffDrugNerdTats"/>
</triggered_effect>

<triggered_effect trigger="onSelfPrimaryActionRayHit" action="RemovePart" part="Sparks"/>
<triggered_effect trigger="onSelfSecondaryActionRayHit" action="RemovePart" part="Sparks"/>

<triggered_effect trigger="onSelfPrimaryActionRayHit" action="ModifyCVar" cvar="stunBatonCharge" operation="set" value="0"/>
<triggered_effect trigger="onSelfSecondaryActionRayHit" action="ModifyCVar" cvar="stunBatonCharge" operation="set" value="0"/>
</effect_group>


I'm not certain what data I should be looking for, perhaps modding the buffs.xml would be the path to take?
 

Code:
<buff name="buffShocked" description_key="buffShockedDesc" tooltip_key="buffShockedTooltip" icon="ui_game_symbol_electric_power" name_key="buffShockedName" icon_color="255,0,0">
		<damage_type value="electrical"/>
		<stack_type value="replace"/>
		<duration value="4.5"/>
		<effect_group>
			<passive_effect name="BuffBlink" operation="base_set" value="2" duration="0,3" tags="buffShocked"/>

			<passive_effect name="HealthChangeOT" operation="base_add" value="-6"/>
			<passive_effect name="RunSpeed" operation="perc_subtract" value="0.9,0" duration="0,4.3"/>
			<passive_effect name="WalkSpeed" operation="perc_subtract" value="0.9,0" duration="0,4.3"/>
			<passive_effect name="CrouchSpeed" operation="perc_subtract" value="0.9,0" duration="0,4.3"/>
			<passive_effect name="JumpStrength" operation="perc_subtract" value="0.9,0" duration="0,4.3"/>

			<triggered_effect trigger="onSelfBuffStart" action="AttachParticleEffectToEntity" particle="p_electric_shock" parent_transform="Spine1" local_offset="0,-.2,0"/>
			<triggered_effect trigger="onSelfEnteredGame" 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"/>

			<triggered_effect trigger="onSelfBuffStart" action="PlaySound" sound="electric_fence_impact"/>
			<triggered_effect trigger="onSelfBuffRemove" action="FadeOutSound" sound="electric_fence_impact"/>
			<triggered_effect trigger="onSelfLeaveGame" action="StopSound" sound="electric_fence_impact"/>
		</effect_group>
	</buff>

	<buff name="buffBurningZombie" hidden="true">
		<damage_type value="heat"/>
		<stack_type value="ignore"/><duration value="0.1"/>
		<effect_group>
			<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="10"/>
			<triggered_effect trigger="onSelfBuffStart" action="AddBuff" buff="buffBurningElement"/>
		</effect_group>
	</buff>

	<buff name="buffBurningElement" hidden="true">
		<damage_type value="heat"/>
		<stack_type value="replace"/><duration value="0"/>
		<effect_group>
			<requirement name="CVarCompare" cvar="$buffBurningElementDuration" operation="LTE" value="10"/>
				<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="10"/>
				<triggered_effect trigger="onSelfBuffStack" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="10"/>
		</effect_group>
		<effect_group>
			<passive_effect name="BuffBlink" operation="base_set" value="2" duration="0,3" tags="buffBurningElement"/>

			<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="add" value="-1"/>
			<triggered_effect trigger="onSelfBuffUpdate" action="RemoveBuff" buff="buffBurningElement">
				<requirement name="CVarCompare" cvar="$buffBurningElementDuration" operation="LTE" value="0"/>
			</triggered_effect>
			<triggered_effect trigger="onSelfBuffRemove" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="0"/>
		</effect_group>

		<effect_group>
			<triggered_effect trigger="onSelfBuffStart" action="AddBuff" buff="buffIsOnFire"/>

			<passive_effect name="HealthChangeOT" operation="base_subtract" value="1.5"/>
			<passive_effect name="WaterChangeOT" operation="base_subtract" value="2"/>
			<passive_effect name="HypothermalResist" operation="base_add" value="30"/>
			<passive_effect name="HyperthermalResist" operation="base_add" value="-10"/>
		</effect_group>
	</buff>
 
Back
Top