Jump to content

Working with poison


senterpat

Recommended Posts

Hello, I'm currently working on a project to make poisons a bit more viable as a gameplay option, but I've run into a brick wall.

 

I am trying to make poisons last for consecutive hits on weapons, I know the general process I plan to use, but my testing has led to two issues I cannot find a resolution for, one I can live with, the other is kind of essential to this aspect of the mod.

 

Problem 1:

I cannot find any sort of function to track whether or not the players weapon is currently poisoned. I have tried with:

GetEquipped, IsSpellTarget, GetIsPoisoned, IsEquipped, GetIsUsedItem.

All of these return 0 unless the player has the poison cast on him using CIOS, in which case it acts as tho the player was hit with poison.

 

Problem 2:

This one is less important, and I can live with it in the mod. Whenever I use EquipObject to equip a poison, it works as it should, however it also brings up the "Would you like to poison the *****" message everytime. A method to bypass this would be nice.

Link to comment
Share on other sites

The poison system is all very hardcoded I believe. In Oblivion, and even Skyrim, it's pretty hit and miss trying to detect when they're used, etc so you probably won't have much luck with existing functions.

 

There are still some other ways to implement your changes though. Perhaps you could make poisons not-poisons and then attach a script effect to them, so that when they're used it sets an OnHit event handler with the player as a "second" filter. This could apply a magic effect to any target the player attacks, and you could add extra conditions in the handler script so it only works for melee weapons and/or only the weapon you had equipped when you used the poison. It could then remove itself after a set number of hits. Maybe auxiliary variables from JIP NVSE would be a good way to track remaining hits on a per-form basis? Probably some other details to work out but it's the bare bones of idea, anyway.

Link to comment
Share on other sites

I tried using OnHit, but it didn't trigger the effect when attacked. The script I tested it with is pretty simple:

 

Begin OnHit

Set TargetRef to GetOwnerLastTarget

TargetRef.CIOS TestPoisonEffect

End

 

I have no experience with event handlers, I looked it up, but am a bit confused. So I attach a script to the base effect for new ingestible that reads:

 

Begin ScriptEffectStart

player.SetEventHander OnHit

End

?

 

Then a quest with another OnHit block where it casts the poison?

 

Tracking the players poisoned weapons should be easy enough, using globals and setting a max of 10 poisoned weapons at a time.

Link to comment
Share on other sites

The NVSE Command Docs and the CS Wiki are probably the best two sources for event handler information. The GECK Wiki has some but it's not very complete.

 

An event handler is a script which runs in response to an event sent by NVSE, which is a response to something occurring in-game. The scripts are UDFs (CS Wiki, GECK Wiki) - the links can probably explain better than I can. You UDF could be something like:

scn PoisonEvOnHit

ref rTarget
ref rAttacker

int iUses
ref rWeapon

begin Function { rTarget, rAttacker }

	let rWeapon := rAttacker.GetEquippedObject 5

	if (RefMapGetType "PoisonUses" rWeapon)			;has entry in refmap

		let iUses := RefMapGetFlt "PoisonUses" rWeapon	;get remaining poison uses

		rTarget.CIOS TestPoisonEffect
		let iUses -= 1					;decrement uses

		if (iUses)
			RefMapSetFlt "PoisonUses" iUses rWeapon	;update remaining uses in refmap
		else
			RefMapErase "PoisonUses" rWeapon	;out of uses so delete from refmap
		endif

	endif

end

Then the poison effect should be something like:

scn PoisonEffectSCRIPT

begin ScriptEffectStart

	ref rWeapon

	let rWeapon := PlayerREF.GetEquippedObject 5

	if (GetWeaponSkill rWeaopon == 38) || (GetWeaponSkill rWeapon == 45)	;weapon is melee or unarmed so can be poisoned
		RefMapSetFlt "PosionUses" 5 rWeapon				;gives the weapon form 5 poison uses
		SetEventHandler "OnHit" PoisonEvOnHit "second"::PlayerREF	;only calls the handler when the player hits someone
	else
		PlayerREF.AddItem Poison 1 1					;return the poison as it wasn't used
		MessageEx "Your current weapon cannot be poisoned."
	endif

end
Edited by PushTheWinButton
Link to comment
Share on other sites

I'm a bit out of my depth here, so I appreciate your patience :p

 

I tested out the scripts, it didnt work, so I threw in some PrintC commands to see where it was going wrong. The effect works fine, as does the initial part of the PoisonEvOnHit script. The line that seems to stop the script is

 

if (RefMapGetType "PoisonUses" rWeapon)

 

after that none of the printc commands print out. I looked up RefMapArrayGetType, and from what I can gather the syntax is fine, any idea why it's not working?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...