Jump to content

Papyrus Magic Effect Scripting Help


RashYY

Recommended Posts

Hello all!

 

I am working on a mod that gives the player/weapon extra effects when they are under influence of different drugs. The idea was that once i get one effect working, the rest is copy/pasting so I'm only working on Buffout right now. So, assuming i want the player to have the effect of the first stage of Pain Train, while theyre holding the weapon the script is attached to, I have this little script written up:

Scriptname NameOftheScript extends ActiveMagicEffect
{Newest, will define player}

MagicEffect Property FortifyStrengthBuff auto const  ; used only when under influence of buff;
Perk Property PainTrain01 auto const

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Actor player = Game.GetPlayer()
		if player.HasMagicEffect(FortifyStrengthBuff) ; check if player uses buffout/buff variant;
			player.addperk(PainTrain01)
			Debug.Trace(akCaster + " Is Under Influence!")
		endif
	if player.HasMagiceffect(FortifyStrengthBuff) == false
		player.removeperk(PainTrain01)
		Debug.Trace(akCaster + " Is Sober!")
	endif	
EndEvent

Now, the script will compile, but ingame, taking buffout does nothing at all. I'm guessing Pain Train doesnt work when youre not in power armor, but i can't find any scripts or options to tweak. If only it were possible to apply Magic Effects to the player via script. Addspell doesn't do much either, as ive created spells using the other effects i want to add, but in the instance of jet it didnt do anything either. I've only tested once with the debug messages, but i dont seem to be able to use or find that info in the Papyrus log(after adding the .ini tweaks) either. I've been working on this for at least 12 hours now and I'm getting hopeless. Please, does anyone know what im doing wrong or how this would be done better? I know of the Potion approach, but im afraid that doesn't scale with the longer chem durations once you get the Chemist perk. The last problem is that i dont know if it would conflict with the player having the generic Pain Train perk, and this instance is the only one where I have a perk set up from the base game, as all the other effects i want to add are magic effects that i made and scripted myself(which work, ive tested!)

 

TL;DR

* why wont my script work?

* would the solution also work with adding magic effects like cripple and stagger?

* Would it conflict with the base game or any very obvious mods?

 

bonus question: if i add this script to any base game melee weapons for example, then how "safe" is this mod in terms of removability or conflicts?

Link to comment
Share on other sites

 

* why wont my script work?

while theyre holding the weapon the script is attached to, I have this little script written up:

It works like a switch, no use. Anyway, you shouldn't add/remove this or similar chart perks in such deliberate manner, unless there's a clear understanding of their functionality and interconnections.

 

When i needed independent PainTrain effect, i simply replicated the whole hierarchy of PerkPainTrainCloakSpell "PainTrain Cloak" [sPEL:00171784] - originally, all that is tied heavily to Power Armor usage. No need to tweak/ruin anything existing.

 

Not quite sure, why need scripts here at all, everything can be done by regular spell/ench/OMOD/mgef, only if not because "scripts are just cool". Attach an Ench by OMOD to any weapon, set up the Ench to emulate the Cloak and condition it to HasMagicEffect(whatever)==1 and HasPerk(PainTrain01)==0 - aaand game does all the work.

Or for more generic approach, a custom perk (or Ability directly) may be added to player and will coordinate bonus effects. I suppose, using a scripted manager will require events handling, that's interesting and possibly efficient, but won't be too simple.

Link to comment
Share on other sites

"condition it to HasMagicEffect(whatever)==1 and HasPerk(PainTrain01)==0 - aaand game does all the work."

What would HasPerk(PainTrain01)==0 mean in this case? Unless i don't grasp it yet, wouldnt that mean its only usable when the player doesnt have pain train already?

 

And thank you for your help, this is gonna make it soo much easier. I really thought I'd have to write a script xD


 

 

Edited by RashYY
Link to comment
Share on other sites

Many things can be done without custom scripts, untill you really come to a dead end.

 

Yes, to avoid them working simultaneously. Actually, top-level condition should be more complex in case of weapon-tied effect and Power Armor usage (for Armor-tied, which i made, there's no such need) - to detect vanilla effect activation (HasPerk(PainTrain01), HasPerk(PowerArmorPerk), IsSprinting), or possibly(?), checking for HasSpell(PerkPainTrainKnockbackSpell) could do it in a single step - need to try out, Cloak is a tricky thing (this might be interesting https://www.creationkit.com/index.php?title=Effect_Item , if customizing the hit spell).

Should remove all the references to PerkTrain and PowerArmorPerk, when replicating the effect.

 

As for the script, it must have OnEffectEnd block to work properly in this case, and still needs Spell-side conditioning to handle unpredictable changes in player's state. But for Perks in general, MGEF has a built-in PerkToApply field - twice dont-need-script : )

Edited by hereami
Link to comment
Share on other sites

Great! However the idea of the mod is to allow the player more effects under influence of drugs. So taking Psycho would, when using a melee weapon, activate the enchantment to allow the player to cripple limbs much more easily. That part's simple(although I havent got it to work yet lol). But it would also allow Buffout to apply a custom version of the "2076 world series baseball bat" enchantment that sends targets flying(the idea being you can, when using the power fist in conjunction with Buffout, disregard your own health and punch So Hard that they fly several meters away). Both of these are very simple, in theory. However, my idea was also to have Overdrive let you use the effects of the first perk of Pain Train. Without Power Armor. So, I'm very sorry if you already said this but im not yet familiar with all CK terminology, would it be possible to add PainTrainCloak when using Overdrive without having to use Power Armor?(because you mentioned it being Armor-tied)

 

Ps. Thank you so much for helping me navigate all this, I'm learning all this cool stuff so much quicker than if I'd solely focus on reinventing the wheel.

Link to comment
Share on other sites

All needed for easy start - to explore, how things are done in base game and understand, why they work. No, can't skip "reinventing the wheel" part, but is much easier, when following that existing invention logic. Again, would recommend XEdit - it shows the skeleton, while CK is mainly an overwhelming black box.

 

Can't use existing Ability (which is applied by the PainTrain01 perk) for that, because it's conditioned to work only while wearing Power Armor, must remake the effects chain and place suitable/ remove unneccessary conditions, where needed.

The new Ability(s)/Effect(s) can be attached to player/npc in different ways:

- permanently add as an Ability by AddSpell() or by AddPerk(), or by a quest alias - needs conditions for checking weapon's presence (GetEquipped) and Chem effects (GetEquipped or HasMagicEffect, HasMagicEffectKeyword); - good for generic purpose;

- add to existing Potion's effects list - needs conditions for weapon's presence; - may conflict with other mods;

- integrate (e.g. by PerkToApply or PA_StealthScript) into an existing Potions's particular Magic Effect - less prone to conflicts;

- a weapon's Enchantment (Constant/Self) - needs condtions for Chem effects; - good for unique or player's weapons and Legendary slot;

In general, like that.

 

Armor-tied meant, that all armor Enchantments are canceled automatically, when entering power armor, so that's simpler to control. But in other cases, it's good to avoid identical effects to run simultaneosly, thus need to detect whether PainTrain effect is active or not.

 

Heh, Power fist, i wonder, how they hadn't done it properly in game. It must push everything just by design, and without any chems, btw ; )

Link to comment
Share on other sites

That's very helpful, thank you! I might go for integrating into Buffout's own potion effect, as I like the idea of PainTrain being a non power fist required effect. How safe would this be for other people if i at some point for example posted it here on the nexus?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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