Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Multiple Scripting Questions


The Vyper
 Share

Recommended Posts

There are several things I want to accomplish and they require scripting that I don't know how to write. As such, I would greatly appreciate any help.

Issue 1:

I want to create an item that completely restores the Player's health the same way welkynd stones restore the Player's magicka. I thought calling Player.ResetHealth would do this, but it seems to have no effect. I could script the item to add an ability spell with a massive amount of Restore Health, but I would also have to script that spell to remove itself. Doing that would also put a restoration icon in the upper right corner of the screen and I'd like to avoid that. Is there any other way to completely restore the Player's health when an item is equipped?

Issue 2:

I'm working on a divine sword that (among other things) will grant the Player certain Greater Power spells when it is equipped and remove them when unequipped. The problem with that is that the Player can equip the sword, cast the Greater Power, unequip and re-equip the sword and immediately cast the Greater Power again. I need a way to prevent the Greater Power from being cast more than once a day even if it's removed from and then re-added to the Player's spellbook during that time. I assume I could add a script to the spell that sets a global variable to 1 and make a quest script to set it to 0 once 24 hours have passed. The problem is, I don't know what the quest script should look like. I also have no idea how to get the spell script to prevent the spell from being cast while the associated global variable is set to 1.

I had another question, but I can't think of it just now (don't you just love it when that happens? :P). If/when I do, I'll add it to this post.

I would prefer to avoid using OBSE since some players avoid mods that require it and I want these to have as wide an appeal as possible.

Link to comment
Share on other sites

There are several things I want to accomplish and they require scripting that I don't know how to write. As such, I would greatly appreciate any help.

Issue 1:

I want to create an item that completely restores the Player's health the same way welkynd stones restore the Player's magicka. I thought calling Player.ResetHealth would do this, but it seems to have no effect. I could script the item to add an ability spell with a massive amount of Restore Health, but I would also have to script that spell to remove itself. Doing that would also put a restoration icon in the upper right corner of the screen and I'd like to avoid that. Is there any other way to completely restore the Player's health when an item is equipped?

I would prefer to avoid using OBSE since some players avoid mods that require it and I want these to have as wide an appeal as possible.

As for Issue #2, I'm not sure, so I'll leave that out.

For Issue #1, you might be able to use GetBaseActorValue (I think this is the correct function) Check it out in the CS Wiki

With this you are calling for an actors Base Value... in your case Health... GetBaseActorValue Health is calling for the players unmodded health, This does not take in affect anything that modifies the health. So if a player has 200 Health and they have a ring that gives 500 health, that would be 400 health. When a scripts calls GetBaseActorValue Health, it will only see the 200 Health and nothing else.

Along with GetBaseActorValue, you will need to use Player.ResetHealth also (if i remember correctly)!

For a full script I'm not quite sure off the top of my head. I *think* that I have a script similar to this in my mod right now. I would check but it is generating Path Grids and landscape stuff. Once it finishes I'll check. I'm not sure if I will be able to get it tonight though.

I'll continue checking in here to see if you've received help yet. :pints:

Link to comment
Share on other sites

Okay Vyper,

This script was to move the player to any area/location if the players health is 20% or lower. I changed it to get you started, so it may or may not work for you right off the bat. You might have to change it all up for your needs.


SCN RestorePlayersHealthScript


float CurrentBaseHealth

float CurrentHealth

short RestoreHealth



Begin GameMode


		If RestoreHealth == 0

			Set CurrentBaseHealth to Player.GetBaseActorValue Health

			Set CurrentHealth to Player.GetAV Health

			If CurrentHealth < ( CurrentBaseHealth * .20 ) ; .20 is equivalent to 20% health, for this, I have it set as, If Health is less than 20% health, then heal the player to full)

				set RestoreHealth to 1

				Player.ResetHealth

			EndIf

		EndIf


End

Hopefully this is close to or it's what your looking for. Good Luck :pints:

Link to comment
Share on other sites

Okay Vyper,

This script was to move the player to any area/location if the players health is 20% or lower. I changed it to get you started, so it may or may not work for you right off the bat. You might have to change it all up for your needs.


SCN RestorePlayersHealthScript


float CurrentBaseHealth

float CurrentHealth

short RestoreHealth



Begin GameMode


		If RestoreHealth == 0

			Set CurrentBaseHealth to Player.GetBaseActorValue Health

			Set CurrentHealth to Player.GetAV Health

			If CurrentHealth < ( CurrentBaseHealth * .20 ) ; .20 is equivalent to 20% health, for this, I have it set as, If Health is less than 20% health, then heal the player to full)

				set RestoreHealth to 1

				Player.ResetHealth

			EndIf

		EndIf


End

Hopefully this is close to or it's what your looking for. Good Luck :pints:

Thanks DsoS! :cookie4u: After a bit of tweaking, I got it working. :thumbup:

Anybody have any ideas about this one?

Issue 2:

I'm working on a divine sword that (among other things) will grant the Player certain Greater Power spells when it is equipped and remove them when unequipped. The problem with that is that the Player can equip the sword, cast the Greater Power, unequip and re-equip the sword and immediately cast the Greater Power again. I need a way to prevent the Greater Power from being cast more than once a day even if it's removed from and then re-added to the Player's spellbook during that time. I assume I could add a script to the spell that sets a global variable to 1 and make a quest script to set it to 0 once 24 hours have passed. The problem is, I don't know what the quest script should look like. I also have no idea how to get the spell script to prevent the spell from being cast while the associated global variable is set to 1.

Link to comment
Share on other sites

Thanks DsoS! :cookie4u: After a bit of tweaking, I got it working. :thumbup:

I'm glad it worked out. I was worried that it wouldn't and me look like a fool XD

Issue 2:

I'm working on a divine sword that (among other things) will grant the Player certain Greater Power spells when it is equipped and remove them when unequipped. The problem with that is that the Player can equip the sword, cast the Greater Power, unequip and re-equip the sword and immediately cast the Greater Power again. I need a way to prevent the Greater Power from being cast more than once a day even if it's removed from and then re-added to the Player's spellbook during that time. I assume I could add a script to the spell that sets a global variable to 1 and make a quest script to set it to 0 once 24 hours have passed. The problem is, I don't know what the quest script should look like. I also have no idea how to get the spell script to prevent the spell from being cast while the associated global variable is set to 1.

I was looking scripts for something for me, and I happened up on the "AltarofAkatosh" script.

In it has the following:


if GetDayofWeek == DayofLastUse

			MessageBox "You've already been blessed this day."

		else

			MessageBox "You make Father Akatosh proud!"

			Cast AltarAkatosh Player

			Set DayofLastUse to GetDayofWeek

		endif

I would look at the full script and see what they are doing. I can not remember if these work on a daily basis or just once a week. But if you can modify it to your needs, it might work out. The Full script:

if GetDayofWeek == DayofLastUse

			MessageBox "You've already used your spell this day." ;This isn't required, but I kept it here cause its in the original script

			Player.RemoveSpell YOURSPELLHERE

		else

			MessageBox "Something Here, if you want it" ;This isn't required, but I kept it here cause its in the original script

			Player.AddSpell YOURSPELLHERE

			Set DayofLastUse to GetDayofWeek

		endif

Will this one work? I wouldn't know. It would require a little bit more scripting than what I placed above.

I would check out THIS and THIS (if you haven't already :) )

Hopefully this will help out a little bit too. I might be missing some information in here somewhere. Anyone have anything to add to this, or corrections on my stuff?


ScriptName AltarofAkatosh


short doonce

short DayofLastUse

ref target


Begin OnActivate


if IsActionRef player == 1


	If Player.GetCrimeGold > 0 || GetPCInfamy > GetPCFame

		MessageBox "Seek not the Dragon's blessing, sinner!"

	elseif FameAkatosh == 0

		MessageBox "Make a pilgrimage to a Wayshrine of Akatosh, and henceforth receive a blessing at Akatosh's holy altars."

	elseif FameAkatosh > 0

		if GetDayofWeek == DayofLastUse

			MessageBox "You've already been blessed this day."

		else

			MessageBox "You make Father Akatosh proud!"

			Cast AltarAkatosh Player

			Set DayofLastUse to GetDayofWeek

		endif

	endif


else


	set target to GetActionRef

	Cast AltarAkatosh target


endif


end


begin gamemode


if doonce == 0											;days are numbered 0-6 - prevents first visit on 0 day and being told you've used it today

	set DayofLastUse to 10

	set doonce to 1

endif


end

What you might be able to do is something like this:
Link to comment
Share on other sites

Thanks DsoS! :cookie4u: After a bit of tweaking, I got it working. :thumbup:

:wallbash: Well, I thought I had it worked out, but I don't. I can't figure out a way to account for fortified health that's still not at max.

I was looking scripts for something for me, and I happened up on the "AltarofAkatosh" script.

In it has the following:

*snip*

Will this one work?

Not really. The biggest problem I have is figuring out how to prevent the spell from being cast after it has been removed and re-added within 24 hours. I need something like:


If GlobalVariableID == 1

 Prevent pell cast 

Link to comment
Share on other sites

:wallbash: Well, I thought I had it worked out, but I don't. I can't figure out a way to account for fortified health that's still not at max.

I don't think there is a way to account for fortified health. WillieSea might know. But I'm not sure on that.

Not really. The biggest problem I have is figuring out how to prevent the spell from being cast after it has been removed and re-added within 24 hours. I need something like:


If GlobalVariableID == 1

 Prevent pell cast 

well crap. I'm out of idea's on it. I'm not the best at scripting myself. WillieSea helps me with alot of my scripts along with half-a-dozen other members here.

I wish you the best of luck with this :pints:

Link to comment
Share on other sites

I don't think there is a way to account for fortified health. WillieSea might know. But I'm not sure on that.

Yikes! Well, that might put a serious crimp on my mod idea. I'll ask Willie and Sea (pun intended :P) what he thinks.

well crap. I'm out of idea's on it. I'm not the best at scripting myself. WillieSea helps me with alot of my scripts along with half-a-dozen other members here.

I wish you the best of luck with this :pints:

Khettienna posted a really good idea over on the BGS forums. Instead of preventing a second cast on the same day, she suggested preventing the spell from being added twice on the same day. Simple, but effective. I'll test the idea out first on my Birthsign Jewelry mod (as an update) to see if I can get it working.

Link to comment
Share on other sites

Yikes! Well, that might put a serious crimp on my mod idea. I'll ask Willie and Sea (pun intended :P) what he thinks.

I only know about 'ResetHealth' and it has always worked fine for me. But that is only your 'base' health, not any fortified health. A healing spell would be necessary for that.

You might be able to use HasMagicEffect. But that would not tell you how much the fortify was for. And it would not let you restore that health anyway. So I think the healing spell is the best bet if you really want the effect.

Link to comment
Share on other sites

I only know about 'ResetHealth' and it has always worked fine for me. But that is only your 'base' health, not any fortified health. A healing spell would be necessary for that.

You might be able to use HasMagicEffect. But that would not tell you how much the fortify was for. And it would not let you restore that health anyway. So I think the healing spell is the best bet if you really want the effect.

Thanks! :D I'll try that out and see how it goes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...