Jump to content

[LE] Mehrunes Razor script for a bow (not working)


Recommended Posts

Hi!

 

I just wanted to use the Mehrunes Razor insta-kill script for a custom bow.

There are 10 versions of the bow. Each version will have a different insta-kill chance

1) 0,5

2)1

3)1,5

etc

10) 5

 

What I did was to

- create 10 copies of the Mehrunes Razor Effect (I think it's called DA07MehrunesRazorEffect), each one with a different magic effect description

- create 10 copies of the Mehrunes Razor Enchantment (each of them will have its specific effect assigned, of course)

- create 10 altered versions of the original script and add them to the Magic Effects. Here comes the problem: I didn't edit anything relevant, just the %chance and the weapon name... But when I compile the scripts and when I add them to each Magic Effect, the scripts act like if they didn't have properties (there's a blue "X" symbol, and if I click on it no properties are assigned). How is this possible?

 

I will post the original script AND one of the altered scripts. I just don't understand what's wrong...

ScriptName DA07MehrunesRazorMagicEffectScript extends ActiveMagicEffect

Faction Property pDA07MehrunesRazorImmuneFaction auto
Weapon Property DA07MehrunesRazor Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

    ;Apply this effect if the target is not in the excluded faction
    If akTarget.IsInFaction(pDA07MehrunesRazorImmuneFaction) == 1
        Return
    Else
        ;1 percent chance to kill target
;         debug.trace(self + " hitting " + akTarget + " with Mehrunes' Razor")
        If (Utility.RandomInt() <= 1)
;             debug.trace(self + "Instant Kill effect applied on" + akTarget)
            If Game.GetPlayer().GetItemCount(DA07MehrunesRazor) >= 1
                akTarget.Kill(Game.GetPlayer())
            Else
                akTarget.Kill()
            EndIf
        EndIf
    EndIf

EndEvent

And here it is...my script, nearly the same one!

Scriptname AAADavideMitraMehRazorScriptBow01 extends activemagiceffect  
{Faction Property pDA07MehrunesRazorImmuneFaction auto
Weapon Property AAADavideMitraMetalCompoundBow01 Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

    ;Apply this effect if the target is not in the excluded faction
    If akTarget.IsInFaction(pDA07MehrunesRazorImmuneFaction) == 1
        Return
    Else
        ;0,5 percent chance to kill target
;         debug.trace(self + " hitting " + akTarget + " with Mehrunes' Razor")
        If (Utility.RandomInt() <= 0,5)
;             debug.trace(self + "Instant Kill effect applied on" + akTarget)
            If Game.GetPlayer().GetItemCount(AAADavideMitraMetalCompoundBow01) >= 1
                akTarget.Kill(Game.GetPlayer())
            Else
                akTarget.Kill()
            EndIf
        EndIf
    EndIf

EndEvent
}

I don't know why the Ck did automatically create those brackets { }

When I created the script, I just removed them, because they caused an error (as I understand, I can't use that symbol).

 

However, judging by the colors, I think the Ck recognizes the weapon ID Da07MehrunesRazor, but it does NOT recognize my bow ID. But why? It's spelled correctly.....

Edited by DavideMitra
Link to comment
Share on other sites

You wrote: "I don't know why the Ck did automatically create those brackets { }".

No idea why the CK should do that. Never seen before.

 

You don't need 10 different scripts. One is enough for the magiceffect, and probably ten different effects is also too much for the purpose.

I chnaged the script name, and took GetEquippedWeapon() instead of GetItemCount().

 

AAADavideMitraMehruneBowEffectScript

 

Scriptname AAADavideMitraMehruneBowEffectScript extends ActiveMagicEffect  
{purpose is..}    ; <- description of the effect

; https://forums.nexusmods.com/index.php?/topic/7470511-mehrunes-razor-script-for-a-bow-not-working/
; DavideMitra wrote: "I just wanted to use the Mehrunes Razor instant-kill script for a custom bow."
; 10 versions of the compound bow has been created.

  Faction PROPERTY pDA07MehrunesRazorImmuneFaction  auto

  Weapon PROPERTY myBow       auto        ; AAADavideMitraMetalCompoundBow01, AAADavideMitraMetalCompoundBow02, .. AAADavideMitraMetalCompoundBow10
  Float  PROPERTY fKillChance auto        ; 0.5, 1.0, .. , 5.0  in percentage (nearly)


; -- EVENTs --

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF akTarget.IsInFaction(pDA07MehrunesRazorImmuneFaction)
    self.Dispel()
    RETURN    ; - STOP -    target is in the excluded faction
ENDIF
;---------------------
    myF_TryToKill(akTarget)
ENDEVENT


; -- FUNCTION --

; https://www.creationkit.com/index.php?title=GetEquippedWeapon_-_Actor

;-------------------------------------
FUNCTION myF_TryToKill(Actor akTarget)
;-------------------------------------
    float f = Utility.RandomInt(0, 100) as Float

IF ((f + 0.5) > fKillChance)
;;;    self.Dispel()
    RETURN    ; - STOP -    keep target alive this time
ENDIF
;---------------------
;;    debug.trace(self + "Instant Kill effect applied on" + akTarget)
    actor player = Game.GetPlayer()

;;;    IF (player.GetItemCount(myBow as Form) > 0)
    IF (player.GetEquippedWeapon(False) == myBow)            ; see property on top
        ; shot by player with the special weapon
        akTarget.Kill(player)
    ELSE
        akTarget.Kill()
    ENDIF
ENDFUNCTION

 

 

Link to comment
Share on other sites

Thank you for your patience and for your efforts!

 

Ok...so...Since I'm a noob with scripts, I just wanted to make things easier. For now and only for now, I tried to create your script for a single version of the bow (the 0,5 one).

After some CK crashes (= I did write the script in the wrong manner), I managed to create the script, and even to compile it successfully.

However, I do always experience the same problem I had before: I add your script to one of my magic effects...but near the script name there's always that blue "X" symbol. It's like if the CK can't read the properties...it doesn't find them. That's really strange, because they have been written correctly...ok...the word "PROPERTY" is written with caps lock, but I don't think it really matters, because you did that too

 

However, here's the script... I did remove most explanations and links to make it shorter and easier to read/edit...but I renamed it after your nickname because I think you deserved it...even if something doesn't still work

 

Script name: aaaReDragon2013MehRazBowScript

Extends: ActiveMagicEffect

Faction PROPERTY pDA07MehrunesRazorImmuneFaction auto
Weapon PROPERTY AAADavideMitraMetalCompoundBow01 auto
Float  PROPERTY 0,5 auto

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF akTarget.IsInFaction(pDA07MehrunesRazorImmuneFaction)
    self.Dispel()
    RETURN
ENDIF
;---------------------
    myF_TryToKill(akTarget)
ENDEVENT

;-------------------------------------
FUNCTION myF_TryToKill(Actor akTarget)
;-------------------------------------
    float f = Utility.RandomInt(0, 100) as Float

IF ((f + 0.5) > 0,5)
;;;    self.Dispel()
    RETURN
ENDIF
;---------------------
;;    debug.trace(self + "Instant Kill effect applied on" + akTarget)
    actor player = Game.GetPlayer()

    IF (player.GetEquippedWeapon(False) == AAADavideMitraCompoundBow01)
        akTarget.Kill(player)
    ELSE
        akTarget.Kill()
    ENDIF
ENDFUNCTION
Edited by DavideMitra
Link to comment
Share on other sites

There is a different between

this

Float  PROPERTY 0,5 auto

IF ((f + 0.5) > 0,5)

;0,5 percent chance to kill target
;    debug.trace(self + " hitting " + akTarget + " with Mehrunes' Razor")
        If (Utility.RandomInt() <= 0,5)

and that

Float PROPERTY fChance = 0.5 auto

IF ((f + 0.5) > fChance)

;0,5 percent chance to kill target
;    debug.trace(self + " hitting " + akTarget + " with Mehrunes' Razor")
        If (Utility.RandomInt() <= 0.5)

Can you find that?

 

 

 

Do not use decimal point, instead use period here.

float needs 0.5 and not 0,5

 

 

 

 

aaaMehRazorBowScript

 

Scriptname aaaMehRazorBowScript extends ActiveMagicEffect

  Faction PROPERTY pDA07MehrunesRazorImmuneFaction auto
  Weapon PROPERTY AAADavideMitraMetalCompoundBow auto

  Float  PROPERTY fChance auto          ; [default=0.0], fill inside CK with 0.5, 1.0, 1.5, .. 5.0 depends on magic effect you like


; -- EVENT -- 

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF akTarget.IsInFaction(pDA07MehrunesRazorImmuneFaction)
    self.Dispel()
    RETURN
ENDIF
;---------------------
    myF_TryToKill(akTarget)
ENDEVENT

;-------------------------------------
FUNCTION myF_TryToKill(Actor akTarget)
;-------------------------------------
    float f = Utility.RandomInt(0, 100) as Float

IF ((f + 0.5) > fChance)
;;;    self.Dispel()
    RETURN
ENDIF
;---------------------
;;    debug.trace(self + "Instant Kill effect applied on" + akTarget)
    actor player = Game.GetPlayer()

    IF (player.GetEquippedWeapon(False) == AAADavideMitraCompoundBow)
        akTarget.Kill(player)
    ELSE
        akTarget.Kill()
    ENDIF
ENDFUNCTION

Edited by ReDragon2013
Link to comment
Share on other sites

Woops! Yes, there was a syntax error. My bad

I did replace both "," with "." and I did recompile the script.

 

....unfortunately, nothing works: the problem is the same. The property section in the CK is blank. I also tried to delete the properties from the script and to insert them manually from the CK. They can be inserted, but the script in-game won't work. I also tried higher kill chances like 20.0 ... I tried with a blood dragon, legendary difficulty. When it dies, it's because I did shoot at that thing for 20 minutes and it did have 1% remaining HP.

 

I don't really know what's wrong. Everything seems ok to me.

 

Other things I did try before writing you:

- I created the script from scratch (= without editing and recompiling it)

- I tried my luck with the old script (the first one I posted here). Even there, there was a syntax error (, instead of . ). I fixed it. Properties didn't appear. Tried to remove properties and insert them manually from the CK. Same thing.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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