ZurinArctus85 Posted September 5, 2016 Share Posted September 5, 2016 (edited) Here's the original Duskfang script from Oblivion.Dawnfang scn DawnfangScript ;related to DuskfangScript short ShouldEquip ;This variable is a flag if the weapon was previously equipped for use when the weapons swap ;This block resets the global variable SESwordDawnfangKills and sets the should equip flag if the previous weapon was equipped begin OnAdd Player Set SESwordDawnfangKills to 0 if ( SESwordDuskfangEquip == 1 ) Set ShouldEquip to 1 Set SESwordDuskfangEquip to 0 endif end ;This block sets the equip flag upon equip of this weapon, the second block does the opposite begin OnEquip Player if ( SESwordDawnfangEquip < 1 ) Set SESwordDawnfangEquip to 1 endif end begin OnUnEquip Player if ( SESwordDawnfangEquip > 0 ) Set SESwordDawnfangEquip to 0 endif end ;This block auto-equips the weapon if the should equip flag was set to 1.. it equips the entire list, as we don't know which one the player has begin gamemode if ( ShouldEquip == 1 ) Player.EquipItem SE03Dawnfang01 Player.EquipItem SE03Dawnfang05 Player.EquipItem SE03Dawnfang10 Player.EquipItem SE03Dawnfang15 Player.EquipItem SE03Dawnfang20 Player.EquipItem SE03Dawnfang25 Player.EquipItem SE03Dawnfang30 Player.EquipItem SE03Dawnfang01A Player.EquipItem SE03Dawnfang05A Player.EquipItem SE03Dawnfang10A Player.EquipItem SE03Dawnfang15A Player.EquipItem SE03Dawnfang20A Player.EquipItem SE03Dawnfang25A Player.EquipItem SE03Dawnfang30A Set SESwordDawnfangEquip to 1 Set ShouldEquip to 0 endif end Duskfang scn DuskfangScript ;related to DawnfangScript short ShouldEquip ;This variable is a flag if the weapon was previously equipped for use when the weapons swap ;This block resets the global variable SESwordDawnfangKills and sets the should equip flag if the previous weapon was equipped begin OnAdd Player Set SESwordDuskfangKills to 0 if ( SESwordDawnfangEquip == 1 ) Set ShouldEquip to 1 Set SESwordDawnfangEquip to 0 endif end ;This block sets the equip flag upon equip of this weapon, the second block does the opposite begin OnEquip Player if ( SESwordDuskfangEquip < 1 ) Set SESwordDuskfangEquip to 1 endif end begin OnUnEquip Player if ( SESwordDuskfangEquip > 0 ) Set SESwordDuskfangEquip to 0 endif end ;This block auto-equips the weapon if the should equip flag was set to 1.. it equips the entire list, as we don't know which one the player has begin gamemode if ( ShouldEquip == 1 ) Player.EquipItem SE03Duskfang01 Player.EquipItem SE03Duskfang05 Player.EquipItem SE03Duskfang10 Player.EquipItem SE03Duskfang15 Player.EquipItem SE03Duskfang20 Player.EquipItem SE03Duskfang25 Player.EquipItem SE03Duskfang30 Player.EquipItem SE03Duskfang01A Player.EquipItem SE03Duskfang05A Player.EquipItem SE03Duskfang10A Player.EquipItem SE03Duskfang15A Player.EquipItem SE03Duskfang20A Player.EquipItem SE03Duskfang25A Player.EquipItem SE03Duskfang30A Set SESwordDuskfangEquip to 1 Set ShouldEquip to 0 endif end Edited September 5, 2016 by ZurinArctus85 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 5, 2016 Share Posted September 5, 2016 Unfortunately, that doesn't help as Papyrus is quite different. EquipItem in Papyrus will cause the item to be added to the player if the player doesn't already have it. As a result, if using a list similar to what is above, the player would end up with every instance of the weapon in their inventory. Not an ideal situation. Also, unless the OP comes back with an issue in the swapping portion, that part is working as far as I know. Link to comment Share on other sites More sharing options...
irswat Posted September 5, 2016 Author Share Posted September 5, 2016 (edited) The script is working AFAIK regarding equipping dawnfang at night, or duskfang during the day. I'm just trying to get this kill counter and dynamic tempering part working. I'm going to try increasing the duration of the kill counter duration effect as suggested by Frank and Ishara.FYI ZurinArctus modeled and rigged the weapon, and he did a great job. I'm just trying to help with the scripting part.FYI I have this thread kind of detailed because if someone needs help with similar stuff in the future they have all the information right here. I hate it when people ask for help, then they post "got it working," or "fixed" but they don't tell you what they did to fix the problem. Edited September 5, 2016 by irswat Link to comment Share on other sites More sharing options...
irswat Posted September 5, 2016 Author Share Posted September 5, 2016 re: the original scriptnot sure if there are for loops in papyrus, but it would seem easier to work with a formlist or array within a for loop instead of manually listing all the different iterations of each blade. Link to comment Share on other sites More sharing options...
irswat Posted September 5, 2016 Author Share Posted September 5, 2016 KILLCOUNTER IS WORKING~ Had to increase the duration of the active magic effect to 2 s in the enchantment properties! Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 5, 2016 Share Posted September 5, 2016 re: the original script not sure if there are for loops in papyrus, but it would seem easier to work with a formlist or array within a for loop instead of manually listing all the different iterations of each blade.You can use a while loop. Here is an example: I use this function in a mod that has multiple containers with each container having its own formlist of items that have been stored (i.e. registered). The purpose of the function is to return items to the containers after they have been transferred to the player for usages such as crafting or selling. In this particular example there are two formlists: abim_IMS_ModContainers and abim_IMS_MasterItemList. The first is a list of all the containers in the mod, the second is a list of the formlists associated with each container. Their indexes must match up, i.e. index 0 = alchemy container and alchemy item list. Function ReturnItems() ;sends items back to containers based on lists built as items are added Debug.Notification("Sorting supplies, please be patient.") int mcs = abim_IMS_ModContainers.GetSize() - 1 While mcs >= 0 FormList MasterList = (abim_IMS_MasterItemList.GetAt(mcs) as FormList) int q = PlayerRef.GetItemCount(MasterList) PlayerRef.RemoveItem(MasterList,q,true,(abim_IMS_ModContainers.GetAt(mcs) as ObjectReference)) mcs -= 1 EndWhile Debug.Notification("Sorting finished.") EndFunction   Link to comment Share on other sites More sharing options...
irswat Posted September 5, 2016 Author Share Posted September 5, 2016 (edited) I have great news! The kill counter and dynamic tempering is pretty much working.  ;KillCount function with help from FamilyFrank Function IncrementKillCount(Bool bIdentity) Debug.Notification("Dawnfang and dustfang kill counter initiated") If bIdentity ; its dawnfang DawnfangFragCount.Mod(1) GetKillLevel(bIdentity) Else ; its duskfang DuskfangFragCount.Mod(1) GetKillLevel(bIdentity) Endif EndFunction ;This gets the associated tempering level of the blase. One level per twelve kills, up to 144 Function GetKillLevel(Bool bIdentity) if PlayerRef.GetEquippedWeapon()==tsasciduskblade EquipHand=1 ;right hand KillLevel=(DuskfangFragCount.GetValue()/12) DuskfangKillCount=(DuskfangFragCount.GetValue()) Debug.Notification("Duskfang kill count:" + DuskfangKillCount + "Duskfang kill level:" + KillLevel) if (KillLevel==KillLevel As Int) && (DuskfangKillCount<=72) tempering=KillLevel*0.1 TemperWeapon(tempering,tsasciduskblade,bIdentity,EquipHand) endif elseif PlayerRef.GetEquippedWeapon(true)==tsasciduskblade EquipHand=2 ;left hand KillLevel=(DuskfangFragCount.GetValue()/12) DuskfangKillCount=DuskfangFragCount.GetValue() Debug.Notification("Duskfang kill count:" + DuskfangKillCount + "Duskfang kill level:" + KillLevel) if (KillLevel==KillLevel As Int) && (DuskfangKillCount<=72) tempering=KillLevel*0.1 TemperWeapon(tempering,tsasciduskblade,bIdentity,EquipHand) endif elseif PlayerRef.GetEquippedWeapon()==adventurerdawnfang EquipHand=1 ;right hand KillLevel=(DawnfangFragCount.GetValue()/12) DawnfangKillCount=DawnfangFragCount.GetValue() Debug.Notification("Dawnfang kill count:" + DawnfangKillCount + "Dawnfang kill level:" + KillLevel) if (KillLevel==KillLevel As Int) && (DawnfangKillCount<=72) tempering=KillLevel*0.1 TemperWeapon(tempering,adventurerdawnfang,bIdentity,EquipHand) endif elseif PlayerRef.GetEquippedWeapon(true)==adventurerdawnfang EquipHand=2 ;left hand KillLevel=(DawnfangFragCount.GetValue()/12) DawnfangKillCount=DawnfangFragCount.GetValue() Debug.Notification("Dawnfang kill count:" + DawnfangKillCount + "Dawnfang kill level:" + KillLevel) if (KillLevel==KillLevel As Int) && (DawnfangKillCount<=72) tempering=KillLevel*0.1 TemperWeapon(tempering,adventurerdawnfang,bIdentity,EquipHand) endif endif EndFunction ;function modified from http://www.creationkit.com/index.php?title=SetItemHealthPercent_-_ObjectReference Function TemperWeapon(float btempering, Form weaponRef, bool WeapRef, int EH) weaponRef.SetItemHealthPercent(1 +btempering) Debug.Notification(weaponRef.GetName() + " tempering level" + (1 + btempering)) if (btempering==0.1) TemperedLevel="Fine " elseif (btempering==0.2) TemperedLevel="Superior " elseif (btempering==0.3) TemperedLevel="Exquisite " elseif (btempering==0.4) TemperedLevel="Flawless " elseif (btempering==0.5) TemperedLevel="Epic " elseif (btempering==0.6) TemperedLevel="Legendary " endif if (WeapRef==1) ;1=dawnfang 2=duskfang PlayerRef.RemoveItem(adventurerdawnfang) PlayerRef.AddItem(weaponRef,1,false) PlayerRef.EquipItemEx(weaponRef,EH,false,true) Debug.Notification(TemperedLevel + weaponRef.GetName() + " has been added!") else PlayerRef.RemoveItem(tsasciduskblade) PlayerRef.AddItem(weaponRef,1,false) PlayerRef.EquipItemEx(weaponRef,EH,false,true) Debug.Notification(TemperedLevel + weaponRef.GetName() + " has been added!") endif  Only problem is for some reason in the last function TemperWeapon the variable weaponRef is not working. I know it's not the prettiest but I will work on optimizations once the functionality is there. Edited September 5, 2016 by irswat Link to comment Share on other sites More sharing options...
palingard Posted September 5, 2016 Share Posted September 5, 2016 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. It is used in Follower Live Package. In there, the author calls DropObject() to drop the item to the floor. It returns an objectreference that can be used to adjust the ItemHealthPercent, effectively tempering the item. Then the function can call the appropriate activate function to put it back in the actor's inventory. You can also call additem passing the objectreference to move it quietly into the appropriate inventory. Link to comment Share on other sites More sharing options...
palingard Posted September 5, 2016 Share Posted September 5, 2016 Is there a function GetIsInt that returns whether a variable is an integer or not? will this work:  ;function with help from FamilyFrank Function IncrementKillCount(Bool bIdentity) If bIdentity ; its dawnfang DawnfangFragCount.Mod(1) KillLevel=(DawnfangFragCount.GetValue()/12) if (KillLevel==KillLevel.GetValue() As Int) tempering=KillLevel*0.1 TemperWeapon(tempering,adventurerdawnfang) endif Else ; its duskfang DuskfangFragCount.Mod(1) KillLevel=(DuskfangFragCount.GetValue()/12) if (KillLevel==KillLevel.GetValue() As Int) tempering=KillLevel*0.1 TemperWeapon(tempering,tsasciduskblade) endif Endif EndFunction ;function taken from http://www.creationkit.com/index.php?title=SetItemHealthPercent_-_ObjectReference Function TemperWeapon(float btempering, Form weaponRef) weaponref.SetItemHealthPercent(1 +btempering) EndFunction The hope is that there are 6 levels of tempering for each weapon, so 72 kills to make each weapon legendary. SetItemHealthPercent() is an ObjectReference Function and as was already mentioned, it cannot be executed on an item within inventory. The only way I have seen this work is to drop the item using DropObject(), which returns the associated objectreference, once tempered, I use additem to move it back to the inventory. Prior to that I tried casting the form as an objectreference, but that did not work. Link to comment Share on other sites More sharing options...
irswat Posted September 5, 2016 Author Share Posted September 5, 2016 (edited) I was going to placetheitem at a marker in sky haven temple, SetItemHealthPercent, then move the item to the players inventory. I feel like it would be more immersive and lore friendly. That would also work I assume?thanks for your help! Edited September 5, 2016 by irswat Link to comment Share on other sites More sharing options...
Recommended Posts