Jump to content

I need help with a papyrus script


DasdaBP

Recommended Posts

Hey! I'm new to modding and I'm trying to figure out how to make a script so a weapon drains magicka while the player has it drawn. For that, I devised two scripts.

One script for a magic effect that drains the player's magicka over time when they have a weapon drawn. The effect is registered to listen for the ACTOR_ACTION_DRAW_START and ACTOR_ACTION_SHEATH_END actor actions, which correspond to when the player begins or ends drawing their weapon.

When the player begins drawing their weapon, the script stores the player's base magicka value and registers for updates every 2 seconds. The script then drains a percentage of the player's magicka every update until either the player's magicka reaches 0 or 30 updates have occurred. If the player sheaths their weapon, the script unregisters for updates and stops draining magicka.

And also a script for adding the mentioned magic effect once the player equips the weapon (and a little bit more).

Script for the magic effect: https://pastebin.com/9GiB2W11
Script for the weapon: https://pastebin.com/se3V55pB

I have done the whole "attach the magic effec to a spell, attach the spell to the weapon via a script thing" but it just doesnt work :(. The message that the Drain Magicka Effect was added does show up, but it never gets added. It doesnt show up in the active effects page nor does any actual effect on the player's magicka happen.

I really dont know what to do about this.

Link to comment
Share on other sites

Simplify your idea's implementation, I haven't looked at your scripts because what you want can be done with a way more easy approach without the need to pull every couple of seconds which makes it system's resource pull heavy.

1) Create an 'Ability' spell and add to it a 'Drain Magica' Magic Effect.


2) Create a 'Perk' and add to it the 'Ability Spell' you created in step '1', in the 'Spell To Apply' drop down menu.

Perk Flags = Playable - Hidden

NOTE: I think it's called 'Spell To Apply', I'm not sure cause I haven't runned CK for more than a year, more or less...


3) Add to your weapon a simple script to add and remove the 'Drain Magica Perk':



Perk Property MyPerk auto

Event OnEquipped(Actor akActor)
If ( akActor == Game.GetPlayer())
akActor.AddPerk(MyPerk)
EndIf
EndEvent

Event OnUnequipped(Actor akActor)
akActor.RemovePerk(MyPerk)
EndEvent



You are done.

Edited by maxarturo
Link to comment
Share on other sites

Hi, Maxarturo! Thank you for taking some time to reply the post :)

Unfortunately this idea wouldnt exactly solve my problem for a few reasons:

1. The reason I didnt use a currently existing "Drain Magicka" magic effect is because it is rather limited in the sense that it always drains the same amount of magicka as defined by the magnitude. In the custom "Drain Magicka" magic effect I wrote for the script, the amount of magicka drained depends on the player's base magicka quantity and his skill in conjuration. i.e the magic effect diminishes in magnitude the higher the players skill in Conjuration is (because the weapon that carries the effect is supposed to be some sort of conjured weapon).
2. I use the "Draw" and "Sheate" actor actions to register the magic effect so as to prevent it from happening as long as the player weapon is equipped (but not drawn or in use).

I do use the Events you mentioned in the weapon's script to add the spell that carries the magic effect tho :)

Thank you so much for your suggestion, maxarturo. Please, lmk if you can think of any other ways I can make this work.

Link to comment
Share on other sites

- Using the same logic as mentioned before, you can create different 'Drain Magica' Magic Effects with different damage output and insert them all in the same ability spell.

- Each 'Drain Magica' Magic Effect that will be inside the same ability spell will have its own set of conditions to obtain the data you want.

- According with the player's current actor value the corresponding 'Drain Magica' Magic Effect will fire.


You can use conditions such as, example:

# 1 Magic Effect

GetActorValue - Conjuration => 25

GetActorValue - Conjuration =< 50



# 2 Magic Effect

GetActorValue - Conjuration => 51

GetActorValue - Conjuration =< 75


And so on....



I don't remember them all by heart (and probably it ain't even named like that), but if you search them in the wiki / creationkit.com you will find the one you need for the job.




You can also using the same logic create different "perks' which each one will be carrying its own 'Drain Magicka Ability Spell'.

* Here you don't need to add conditions to the magic effects leaving inside the ability spell, as the suggestion above.


And then in the 'Equip Script' obtain the player's value you want when the weapon gets equipped and add the corresponding Perk that corresponds to the player's value.



2. I use the "Draw" and "Sheate" actor actions to register the magic effect so as to prevent it from happening as long as the player weapon is equipped (but not drawn or in use).


The events Event OnEquipped() and OnUnequipped() works exactly the same as registering for animation event 'Draw' and 'Shater'.

* This part is a little confusing, I think you were thinking something else and wrote something else.


Edited by maxarturo
Link to comment
Share on other sites

use playerREF for starters, it is a pointer to memory allocation of the player where Game GetPlayer and the name implies is a function to get the pointer to memory which then goes to the memory allocation of the player. Modern PC have a Heap of RAM , clinging to days of skyrim crashing because of it exceeding it RAM is over.. Or do PC in this universe and how code access the RAM work differently here ??

 

Just asking and trolling users that argue which is better BUT have no idea how it works hehehehehe... btw asking about the PC in this universe, which is better is no brainer.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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