Jump to content

Papyrus Scripting


Gorgopis

Recommended Posts

1 hour ago, xkkmEl said:

it would not have caught my parameter-order-confusion error.

ah good to know. so if we're using it for testing its fine, i'll be removing it anyway in the final version of the script.

 

now how do i create a buff that stacks up to 4 times visually ? and by visually i mean the icon of the buff on the right side of the screen (where buffs appear), goes up in count (from 1 to 4 or disappear when the player didn't power attack during the buff timer) ?

Link to comment
Share on other sites

4 hours ago, xkkmEl said:

buff/debuff your weapon enchantment.  We can tackle that next.

for this part, what i had in mind, was taking inspiration from a long existing mod on nexus called: infinity sword.

 

this mod makes it so that directional power attacks with the sword, will cast some form of fire ball, and the standing power attack cuases an explosion in place.

 

by reading though its script i found 2 interesting functions in it:

Function SuperPowerAtk(Actor akSource)
    Float Power = InfSwordPowerGlobal.GetValue()
        ;Debug.Trace(Power)
            if (Power >= 100)
                FlameWave.Cast(akSource)
                FlameWaveRelease.Play(akSource)
                InfSwordPowerGlobal.SetValue(0.0)
            else
                FlameBlastBall.Cast(akSource)
            EndIf
endFunction

Function SuperPowerBlast(Actor akSource)
    Float Power = InfSwordPowerGlobal.GetValue()
        ;Debug.Trace(Power)
            if (Power >= 100)
                InfSwordSooperBlast.Cast(akSource)
                InfSwordPowerGlobal.SetValue(0.0)
            else
                FlameBlastLocal.Cast(akSource)
            EndIf
endFunction

as far as i can understand, he set up a global count for the weapon's enchantment, and then if that global count goes to 100 or above the weapon is charged and therefore unleashes the power attacks. i want you to take a look at this and see how can i marry this script into what we've created here so far, and see if we can somehow introduce our buff that we created (1 to 4 stacks) and then tie the explosion to the next power attack done after the stacks created by doing 4 normal attacks consecutively, to this script ?

 

let me know what what ideas do you have for pulling this off. thanks 😉

Link to comment
Share on other sites

Hmm.... I don't know about tweaking the HUD active magic effect icons... Not the slightest idea on that.  I can have it show whichever standard icon you want, but I don't know about putting a number on it, or use a custom icon.

The code you shared indicates how additional effects are done in that mod.  It does not address explicitly how the "Power" global variable is managed.  This approach will also only work for the player (though you may be ok with this).

In what you'd said earlier, I understood you wanted extra buffs to take effect as you repeat hits on the same target.... which is why I've had you set things up to count hits per-target.  Perhaps I assumed wrong...

To distinguish different power attacks you'd need to listen for animation events; I know how to work with them, but have not researched which events to listen for and experience tells me to expect a need to experiment (though having that mod's source can certainly help narrow the search).  It may be easier to start with just hit counts, and then layer on top per-attack-style variations.

Also, you have not made explicit how you want to manage the debuffs... or rather how buffs timeout.  Right now, what I wrote places a magiceffect on the target with the 1st hit, and removes it 20s later.  During these 20s you can count hits, triggering buffs as needed, then everything resets.  That's probably not exactly what you want.  If you want (for example) the buffs and hit counts to continue until 20s go by without a hit on that target, add the following line at the end of the "OnHit" event (while you're at it, replace the 20.0 with whatever delay you have in mind):

	registerForSingleUpdate( 20.0)

In any case, I'll wait for a bit more info on you plans and dreams before suggesting more code.

Link to comment
Share on other sites

5 hours ago, xkkmEl said:

Hmm.... I don't know about tweaking the HUD active magic effect icons... Not the slightest idea on that.  I can have it show whichever standard icon you want, but I don't know about putting a number on it, or use a custom icon.

The code you shared indicates how additional effects are done in that mod.  It does not address explicitly how the "Power" global variable is managed.  This approach will also only work for the player (though you may be ok with this).

In what you'd said earlier, I understood you wanted extra buffs to take effect as you repeat hits on the same target.... which is why I've had you set things up to count hits per-target.  Perhaps I assumed wrong...

To distinguish different power attacks you'd need to listen for animation events; I know how to work with them, but have not researched which events to listen for and experience tells me to expect a need to experiment (though having that mod's source can certainly help narrow the search).  It may be easier to start with just hit counts, and then layer on top per-attack-style variations.

Also, you have not made explicit how you want to manage the debuffs... or rather how buffs timeout.  Right now, what I wrote places a magiceffect on the target with the 1st hit, and removes it 20s later.  During these 20s you can count hits, triggering buffs as needed, then everything resets.  That's probably not exactly what you want.  If you want (for example) the buffs and hit counts to continue until 20s go by without a hit on that target, add the following line at the end of the "OnHit" event (while you're at it, replace the 20.0 with whatever delay you have in mind):

	registerForSingleUpdate( 20.0)

In any case, I'll wait for a bit more info on you plans and dreams before suggesting more code.

ok so first of all, the mod that i posted its script, is called The Infinity Sword. you can see all of its scripts there. i don't know i can post its scripts on the forum, without my post being taken down.

 

now for the weapon enchantment:

it's pretty simple, so to avoid confusion, i'm gonna fully explain it (with as little word swarm as i can).

 

so this is what i want the enchantment to do:

1. upon successfully hitting a target with a normal attack, it applies 1 stack of a buff on player (not enemies),

2. at 4 stacks of the buff (4 successful normal attacks), it will transform into a new buff,

3. with the new buff, your next Standing power attack (the one where you just stand there with no directions and push the power attack button), will cause an explosion in the location of impact, regardless of whether it hit an opponent or not, and then 3 fireballs are sent in directions forward, left and right, the explosion is similar to the fire trap spell, and the fireballs are similar to the fireball spell.

4. each stack of the buff received from normal attacks will last 10 seconds, until it dissipates, when it does, the buff is entirely gone, and you have to start stacking buffs from the beginning.

5. after 4 stacks of the normal attack buffs where they will turn into a power attack buff, the buff will last 20 seconds until it dissipates or until you execute a power attack, after which the buff is gone.

 

 

ok so, the mod that i linked (and shown you its script), accomplishes the explosion and fireballs after performing a power attack, but the standing power attack causes the explosion, whereas directional power attacks cast fireballs. it is a very good foundation to build from for the main part of the enchantment, that's why i originally, only asked for the first part of the script here, which is creating a hit counter for normal attacks, building up to a power attack buff.

 

my personal bet was, if i can find a way to count normal attacks and apply stacks of a buff to the player, then i can simply change normal attack buff with the power attack buff, and then put a condition for on the power attack enchantment to cause the explosion and fireballs. so in essence, the enchantment has 2 phases.

 

i hope that answers everything, thanks for helping out. i'll await your response on how to go forward with this before making any further changes to the script. 😉

Link to comment
Share on other sites

This is what I suggest:

  1. Set up a quest with script to count hits by the player with the enchanted weapon; counter resets to zero after 10s without hits, if less than 4 hits were recorded; counter resets to zero after 20s without hits, if at least 4 hits were recorded.
  2. Use an enchantment on the weapon to detect hits by the player and increment the quest's hit counter, and refresh the 10s/20s timer.
  3. Trigger 1st set of buffs based on the quest's hit counter.
  4. Use the quest to listen for animation events on the player to detect power attacks (experimentation will be required; I have never tried to distinguish power attacks using animation events).
  5. Trigger power buff when animation event is detected, and expire the counter immediately thereby returning the hit counter to zero.

In this, a 5th hit 10s+ after the 4th (but less than 20s) will keep the counter going.  If you deem it important during the 10-20s period to act on the power buff but ignore the normal attack, it can be done but it will require more code (with corresponding debugging and testing).

Link to comment
Share on other sites

13 hours ago, xkkmEl said:

If you deem it important during the 10-20s period to act on the power buff but ignore the normal attack, it can be done but it will require more code (with corresponding debugging and testing).

i definitely would, because i want it to come out clean, no matter how much time it takes to create the enchantment. as long as it works perfectly.

 

as for your steps, i think i just need help with the 2 magic effects corresponding to hit detection/counting, and buffs. i simply don't know how i can even begin to start writing a code for that, maybe an event that calls in the function which will trigger the power attack buff, when the normal attack buff reaches stack #4 ?

 

if you can just help me out with the counter & buff scripts (already helped me with counter script), or rather just give me an idea on how to stack 1 buff, 4 times (for normal attacks), and then upon 4 normal attacks switch the buff, into a power attack buff, through script, i think i can take care of the rest of it for the explosion and fireballs, through a function that simply casts the corresponding spell that i would create for each of those effects.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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