Jump to content

Duskfang/Dawnfang Script Help


KeatonMask

Recommended Posts

I'm trying to port my favorite weapon from Oblivion--Dawnfang/Duskfang--into Skyrim. The mesh and texture port occurred without a hitch; I am, however, experiencing some difficulties perhaps beyond my scripting expertise (This would be only my third script ever.), and I seek the communities assistance. Keeping with my lazy copy-and-paste tactics, I took the scripts from a posted mod (http://skyrim.nexusmods.com/mods/10550), scanned them over, and then created the objects that were, as far as I could tell, the only ones not already in the ObjectReference: DawnfangKC and DuskfangKC--which I created as global variables, short, value 0, non-constant. Here's what I have for DawnfangScript (and, as it only involves substituting instances of "Dawnfang" for "Duskfang," DuskfangScript):

 

Scriptname DawnfangScript extends ObjectReference  
{The script controlling Dawnfangs behavior}

Actor User
GlobalVariable Property DawnfangKC Auto
GlobalVariable Property DuskfangKC Auto

Weapon property Duskfang auto
Weapon property DuskfangS auto

Float FUNCTION getCurrentHourOfDay() 

float temp = Utility.GetCurrentGameTime() * 24 

return ((temp as int) % 24) + (temp - (temp as int)) 

ENDFUNCTION

event onequipped(Actor akActor)
User = akActor
if User == Game.getplayer()
	RegisterForUpdateGameTime(1)
	DuskfangKC.setValue(0)
endif
endEvent

event OnUpdateGameTime()
if getCurrentHourOfDay() < 6
	if getCurrentHourOfDay() > 18
		if DawnfangKC.GetValue() >= 12
			User.EquipItem(DuskfangS, false, true)
		else
			User.EquipItem(Duskfang, false, true)
		endif
		Delete()
		unregisterForUpdateGameTime()
	endif
endif
endEvent

event OnUnEquipped(Actor akActor)
UnregisterForUpdateGameTime()
endEvent

 

And here's what I have for DawnfangKC (and DuskfangKC):

 

Scriptname DawnfangKCheck extends activemagiceffect  

GlobalVariable Property DawnfangKC Auto

event onEffectFinish(Actor akTarget, Actor akCaster)
if akTarget.isDead()
	if akCaster == akTarget.GetKiller()
		DawnfangKC.setValue(DawnfangKC.getValue()+1)
	endif
endif
endevent

 

I have identified two problems: (1) there is no way to determine the current Kill Count, as no messages have been implemented, and (2) the sword does not transform upon change from day to night. Any help and/or suggestions toward the end of getting the magnificent weapon into Skyrim would be much appreciated.

Edited by KeatonMask
Link to comment
Share on other sites

The best I can figure is that some issue is arising out of the RegisterForUpdateGameTime, as it only occurs once each hour and only while the sword is equipped; however, I have tried waiting, sword in hand, for days but to no avail: I see no transformation.
Link to comment
Share on other sites

I set up a Debug.Notification like so:

 

Scriptname DawnfangScript extends ObjectReference  
{The script controlling Dawnfangs behavior}

Actor User
GlobalVariable Property DawnfangKC Auto
GlobalVariable Property DuskfangKC Auto

Weapon property Duskfang auto
Weapon property DuskfangS auto

Float FUNCTION getCurrentHourOfDay() 

float temp = Utility.GetCurrentGameTime() * 24 

return ((temp as int) % 24) + (temp - (temp as int)) 

ENDFUNCTION

event onequipped(Actor akActor)
User = akActor
if User == Game.getplayer()
	RegisterForUpdateGameTime(1)
	DuskfangKC.setValue(0)
endif
endEvent

event OnUpdateGameTime()
Debug.Notification(getCurrentHourOfDay())
if getCurrentHourOfDay() < 6
	if getCurrentHourOfDay() > 18
		if DawnfangKC.GetValue() >= 12
			User.EquipItem(DuskfangS, false, false)
		else
			User.EquipItem(Duskfang, false, false)
		endif
		Delete()
		unregisterForUpdateGameTime()
	endif
endif
endEvent

event OnUnEquipped(Actor akActor)
UnregisterForUpdateGameTime()
endEvent

 

And I didn't see any messages. It would seem that, for reasons unfathomable to me, the event OnUpdateGameTime is not occurring.

Edited by KeatonMask
Link to comment
Share on other sites

  • 4 months later...

Well, I've been working on those scripts and I've had a few minor successes, but the main issue you outlined still plagues me... I cannot fathom why that event is not calling.

I did, however, get the killcount messages working correctly (and it even says "life" for 1 kill and "lives" for multiple), and it says it's been "sated" after 12 kills (and stops giving messages for further kills that day).

But I did encounter an issue with how the killcount script's conditions are written: the script only checks if the target is dead and if you were the killer. Which is great, except beating a dead body fulfills those conditions. Also, it's not triggered when the killing blow has a killcam, for some reason. I looked at the soul gem script for help, but it seems to use a quest event, which I didn't want to delve into.

Anyway, let me know if you figure out why the OnUpdateGameTime() event isn't being called.

 

EDIT: Nevermind, I fixed the beating-dead-bodies issue by adding a condition in the magic effect window checking the subject was alive at the moment of the hit. It still doesn't work for killcam-kills, though.

Still working on the other problem.

 

EDIT2: I suspect it's not working because RegisterForUpdateGameTime is not a member of ObjectReference. But I've seen other scripts that extend ObjectReference and use this event...

Edited by Teh Masterer
Link to comment
Share on other sites

Come on, there must be an experienced scripter here somewhere that can tell me why this event - OnUpdateGameTime() - refuses to be called. It's frustrating me to no end... There is simply no reason I can see that it shouldn't work. It compiles fine, but either the Register function is not working properly or the event is just broken.
Link to comment
Share on other sites

New update on the problem: Looking through the Papyrus logs, I noticed the following:

 

[12/04/2012 - 11:07:00PM] error: Unable to call RegisterForUpdateGameTime - no native object bound to the script object, or object is of incorrect type
stack:
[item 32 in container  (00000014)].DawnfangScript.RegisterForUpdateGameTime() - "<native>" Line ?
[item 32 in container  (00000014)].DawnfangScript.OnEquipped() - "DawnfangScript.psc" Line 28

 

Using the info on the wiki page for Papyrus logs, I conclude that the FormID keeps changing for some reason, or that my savegame is dodgy.

A bit of background info: Every time I test the mod, I load the same save and then quit, so that save is always running the mod for the first time. It's hardly a clean save (with the 100 or so mods I have running), but also I've tested the mod using a brand new game (with "coc whiterun" from the main menu) with no success.

 

In the same .esp (and the same savegame/testing conditions), I created and tested an activator in the game world that gives messages every few seconds with the OnUpdateGameTime() event, so I know the event itself is working - it must be something specific to the Dawnfang sword in my inventory.

 

So I'm not sure what to make of it. Any advice, guys?

Maybe the FormID of items in the player's inventory changes depending on whether its the third or first-person model (or not equipped at all)?

Alternatively, maybe Weapon types cannot be registered for updates?

Or maybe the FormID can't be found because the mod was originally in a different load order?

 

EDIT: If I type in "sv" with Dawnfang selected in the game console, it initially says the name of the attached script and variable values, as expected. But after equipping it, "sv" reports that it's registered for game updates but has no attached scripts, leading me to believe that the FormID is in fact changing somehow.

 

But I really don't know, I'm just shooting ideas into the dark, here.

Edited by Teh Masterer
Link to comment
Share on other sites

  • Recently Browsing   0 members

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