Jump to content

Please help me get this simple script working


irswat

Recommended Posts

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 by ZurinArctus85
Link to comment
Share on other sites

  • Replies 135
  • Created
  • Last Reply

Top Posters In This Topic

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

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 by irswat
Link to comment
Share on other sites

  On 9/5/2016 at 2:30 PM, irswat said:

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:

 

  Reveal hidden contents

 

Link to comment
Share on other sites

I have great news! The kill counter and dynamic tempering is pretty much working.

  Reveal hidden contents



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 by irswat
Link to comment
Share on other sites

  On 9/4/2016 at 7:07 PM, IsharaMeradin said:

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

  On 9/4/2016 at 6:03 PM, irswat said:

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

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 by irswat
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...