Jump to content

Please help me get this simple script working


irswat

Recommended Posts

Is there a function GetIsInt that returns whether a variable is an integer or not?

Not that I am aware of.

If it is a variable that is already on your script, then you should know whether it is an int or float. If you're wondering about global variables, they can all be treated as floats even if they have an int value (cause the game treats all global variables as floats).

Link to comment
Share on other sites

  • Replies 135
  • Created
  • Last Reply

Top Posters In This Topic

sorry, I updated the previous post.

For every twelve kills each sword will temper one level, up to 6 levels (72 kills/legendary). This is the context I need such a function:

KillLevel=(DuskfangFragCount.GetValue()/12)
if (KillLevel==KillLevel.GetValue() As Int)
	tempering=KillLevel*0.1
	TemperWeapon(tempering,tsasciduskblade)
endif
Edited by irswat
Link to comment
Share on other sites

I would guess that it would. But I'm a bit confused by SetItemHealthPercent. I've not ever seen it used in a mod before and it states that it does not work on items in a container. Well, the player inventory is also a container so... the only time it might work is when the item is lying on the ground? But that doesn't seem to be ideal. Might be worth asking at the SKSE thread for the correct usage.

Link to comment
Share on other sites

An alternative to the tempering could be boosting the enchantments, just have two effects with conditions so the weak is used when killcount hast reached the threshold and from then the strong is used, you could have multiple stages too.

Link to comment
Share on other sites

still having problems getting this killcounter working. Here:

I have attached this script to the two magic effects. Checked dawnfang to true, and duskfang is unchecked as false in CK.

 

Scriptname FangKillCounter extends activemagiceffect
;script by FamilyFrank - much thanks and God bless!
DawnDuskTimerScript Property DawnDuskTimer Auto ; This property type must be exactly the scriptname of the quest below! And must then be filled in ck with said quest.
Bool Property Identity Auto; fill in ck: True for Dawnfang and False for Duskfang

Event OnDeath(Actor akKiller)
If akKiller == Game.getPlayer()
DawnDuskTimer.IncrementKillCount(Identity) ;call the function on the quest and pass identity so the quest knows.
Endif
EndEvent

 


When I try to compile this I get the following error:

 

Compiling "FangKillCounter"...
C:\Games\steamapps\common\skyrim\Data\Scripts\Source\FangKillCounter.psc(3,29): cannot name a variable or property the same as a known type or script
C:\Games\steamapps\common\skyrim\Data\Scripts\Source\FangKillCounter.psc(8,16): IncrementKillCount is not a function or does not exist
C:\Games\steamapps\common\skyrim\Data\Scripts\Source\FangKillCounter.psc(8,16): cannot call the member function IncrementKillCount alone or on a type, must call it on a variable
No output generated for FangKillCounter, compilation failed.

 

 

This is the quest script. The name of the quest is DawnDuskTimer:

 

Scriptname DawnDuskTimerScript extends Quest
{Prevents dawnfang and duskfang from being equipped at wrong times}

Weapon property adventurerdawnfang auto
Weapon property tsasciduskblade auto

ObjectReference property weaponRef auto

GlobalVariable property DawnfangFragCount Auto
GlobalVariable property DuskfangFragCount Auto
GlobalVariable property GameHour auto
;GlobalVariable property KillLevel auto

Actor Property PlayerRef Auto

float TimeUntilUpdate
float currenthealth
float tempering
float KillLevel
float DawnfangKillCount
float DuskfangKillCount

int EquipHand=0 ;1=right 2=left

Event OnInit()

    Debug.Notification("Dawnfang and dustfang timer initiated")
    float TimeofDay=GameHour.GetValue() ;thanks to tonycubed2 for this
        
    if (TimeofDay>=6.0 && TimeofDay<18.0)
        TimeUntilUpdate=18.0-TimeofDay
    elseif (TimeofDay>=18.0 && TimeofDay<=24.0)
        TimeUntilUpdate=24.0-TimeofDay
    elseif (TimeofDay<6.0)
        TimeUntilUpdate=6.0-TimeofDay
    endif
    if ((TimeuntilUpdate<=1.0) || TimeofDay==6.0 || TimeofDay==18.0)
        RegisterForSingleUpdateGameTime(1)
    endif
    ;Debug.Notification("Quest:Gametime until update" + TimeUntilUpdate)
    ;TimeUntilUpdate=(TimeUntilUpdate/timescale.GetValue())
    ;Debug.Notification("Realtime until update" + TimeUntilUpdate)
    RegisterForSingleUpdateGameTime(TimeUntilUpdate)
    
EndEVENT

EVENT OnUpdateGameTime()
    
    float TimeofDay=GameHour.GetValue() ;thanks to tonycubed2 for this
    PlayerRef=Game.GetPlayer()
        ;optimizations by IsharaMeriden - much thanks
        if (TimeofDay>=6.0 && TimeofDay<18.0)
            if PlayerRef.GetEquippedWeapon()==tsasciduskblade
                EquipHand=1 ;right hand
                WeaponSwap(tsasciduskblade,adventurerdawnfang,EquipHand)
            elseif PlayerRef.GetEquippedWeapon(true)==tsasciduskblade
                EquipHand=2 ;left hand
                WeaponSwap(tsasciduskblade,adventurerdawnfang,EquipHand)
            elseif PlayerRef.GetItemCount(tsasciduskblade)==1
                PlayerRef.RemoveItem(tsasciduskblade)
                PlayerRef.AddItem(adventurerdawnfang,1,false)
            endif
        elseif ((TimeofDay>=18.0 && TimeofDay<24.0)||(TimeofDay<6))
            if PlayerRef.GetEquippedWeapon()==adventurerdawnfang
                EquipHand=1 ;right hand
                WeaponSwap(adventurerdawnfang,tsasciduskblade,EquipHand)
            elseif PlayerRef.GetEquippedWeapon(true)==adventurerdawnfang
                EquipHand=2 ;left hand
                WeaponSwap(adventurerdawnfang,tsasciduskblade,EquipHand)
            elseif PlayerRef.GetItemCount(adventurerdawnfang)==1
                PlayerRef.RemoveItem(adventurerdawnfang)
                PlayerRef.AddItem(tsasciduskblade,1,false)
            endif
        endif
    
    
    if (TimeofDay>=6.0 && TimeofDay<18.0)
        TimeUntilUpdate=18.0-TimeofDay
    elseif (TimeofDay>=18.0 && TimeofDay<=24.0)
        TimeUntilUpdate=24.0-TimeofDay
    elseif (TimeofDay<6.0)
        TimeUntilUpdate=6.0-TimeofDay
    endif
    if TimeuntilUpdate<=0.0
        RegisterForSingleUpdateGameTime(1)
    endif
    ;Debug.Notification("Quest Update: Gametime until update" + TimeUntilUpdate)
    ;TimeUntilUpdate=(TimeUntilUpdate/timescale.GetValue())
    ;Debug.Notification("Realtime until update" + TimeUntilUpdate)
    RegisterForSingleUpdateGameTime(TimeUntilUpdate)
endEVENT

;function with help from FamilyFrank
Function IncrementKillCount(Bool bIdentity)
Debug.Notification("Dawnfang and dustfang killcounter initiated")
If bIdentity ; its dawnfang
    DawnfangFragCount.Mod(1)
    KillLevel=(DawnfangFragCount.GetValue()/12)
    Debug.Notification("Dawnfang kill count:" + DawnfangKillCount + "Dawnfang kill level:" + KillLevel)
    if (KillLevel==KillLevel As Int)
        tempering=KillLevel*0.1
        TemperWeapon(tempering,adventurerdawnfang,bIdentity)
    endif
Else ; its duskfang
    DuskfangFragCount.Mod(1)
    KillLevel=(DuskfangFragCount.GetValue()/12)
    Debug.Notification("Duskfang kill count:" + DuskfangKillCount + "Duskfang kill level:" + KillLevel)
    if (KillLevel==KillLevel As Int)
        tempering=KillLevel*0.1
        TemperWeapon(tempering,tsasciduskblade,bIdentity)
    endif
Endif
EndFunction

;weapon swap function by IsharaMeriden - much thanks
Function WeaponSwap(Form OldWeapon, Form NewWeapon, Int EH)
    PlayerRef.UnequipItem(OldWeapon,true,true)
    PlayerRef.RemoveItem(OldWeapon)
    PlayerRef.AddItem(NewWeapon,1,false)
    PlayerRef.EquipItemEx(NewWeapon,EH,false,true)
    ;Debug.Notification(NewWeapon.GetName()+" has emerged") ;GetName requires SKSE!
EndFunction

;function modified from http://www.creationkit.com/index.php?title=SetItemHealthPercent_-_ObjectReference
Function TemperWeapon(float btempering, Form weaponRef, bool WeapRef)
    weaponRef.SetItemHealthPercent(1 +btempering)
    Debug.Notification(weaponRef.GetName() + "tempering level" + (1+btempering))
    if (WeapRef==1) ;1=dawnfang 2=duskfang
        PlayerRef.RemoveItem(adventurerdawnfang)
    else
        PlayerRef.RemoveItem(tsasciduskblade)
    endif
    PlayerRef.AddItem(weaponRef,1,false)
    PlayerRef.EquipItemEx(weaponRef,1,false,true)
    Debug.Notification("tempered" + weaponRef.GetName() + "has been added!")
EndFunction

 


Edited by irswat
Link to comment
Share on other sites

DawnDuskTimerScript Property DawnDuskTimer Auto ; This property type must be exactly the scriptname of the quest below! And must then be filled in ck with said quest.

The comment line you put in there is perhaps misleading you a little bit.

 

The first part is the script you want to reference. The second part is the variable name you want to use. Because it is the same name as a quest, the compiler is flipping out.

I bet if you changed it to:

DawnDuskTimerScript Property DDT Auto

it would compile (after of course changing all the other spots in the script where you call the DawnDuskTimerScript via the variable.)

Link to comment
Share on other sites

thanks I'll give that a try.

that worked! thanks!

When I fill the two GlobalVariables in CK, because they are counters is filling them with none the same as initializing them as 0? autofill doesn't seem to detect anything for them.

Edited by irswat
Link to comment
Share on other sites

The active magic effect that is attached to the enchantment that is attached to the weapon has a script called FangKillCounter. This script is never being executed and I'm not sure why.

 

Scriptname FangKillCounter extends ActiveMagicEffect  
;script by FamilyFrank - much thanks and God bless!

DawnDuskTimerScript Property DDT Auto ;DawnDuskTimerScript is the name of the quest script

Bool Property Identity Auto
 
Event OnDeath(Actor akKiller)
 If akKiller == Game.getPlayer()
  Debug.Notification("Dawnfang and dustfang called")
  DDT.IncrementKillCount(Identity) ;DDT is the name of the Quest
 Endif
EndEvent

 



Active Magic Effect


http://i68.tinypic.com/167qb03.jpg

 

Edited by irswat
Link to comment
Share on other sites

You have to create the global forms in order to assign them to the property. In the CK go to Misc > Globals then add however many new globals you need.

 

As far as that script not running, I can't say for sure. If you aren't testing on a new game that hasn't seen any bit of this mod before, that could explain it. It could be that the effect is not sticking around long enough for it to recognize the event.

 

Soul trap, why not take a look at how that works since it performs actions when the actor dies. It uses MagicSoulTrapFXScript. You may not need to do exactly the same thing, but might give you some ideas.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...