Jump to content

Need a script? Maybe I can help.


fg109

Recommended Posts

  • Replies 272
  • Created
  • Last Reply

Top Posters In This Topic

Howdy,

 

It's woverdude from the Way of the Monk mod. So, here's the thing. I have a script that I want to have run whenever the player is hit. The script moves around various global variables as a way of leveling or progressing the Unarmored skill. But I need it to only work when the player does not have anything equipped with the "ArmorHeavy" and "ArmorLight" keywords so that it only levels when they are unarmored. Here's the script:

 

 

 

Scriptname UnarmoredLevelingScript extends ObjectReference

{Levels your Unarmored as you take hits.}

 

GlobalVariable Property Use auto

GlobalVariable Property Mod auto

GlobalVariable Property Level auto

GlobalVariable Property PointsAvailable auto

GlobalVariable Property PointsEarned auto

GlobalVariable Property PointsSpent auto

 

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \

bool abBashAttack, bool abHitBlocked)

Use.SetValue(Use.GetValue()+Mod.Getvalue())

if Use.GetValue() >= 20

Use.SetValue(Use.GetValue() - 20)

Level.Setvalue(Level.Getvalue()+1)

Debug.Notification("Your Unarmored level has been raised to " + Level.GetValue())

Mod.SetValue(Mod.GetValue() - 0.01)

PointsAvailable.SetValue(Level.GetValue()/5 - PointsSpent.GetValue())

PointsEarned.SetValue(PointsSpent.GetValue() + PointsAvailable.GetValue())

endif

EndEvent

 

 

 

Do you think that you can help?

Link to comment
Share on other sites

@SetterHead

 

Your mod idea doesn't actually require any scripts. Or at most, it would require a simple script to check the stage of a quest (used to keep track of when exactly a fort/outpost is considered cleared) and then either enable or disable an Xmarker. The Xmarker would be the enable parent of all the NPCs (and perhaps banners) in the fort/outpost.

 

 

@Woverdude

 

Is that a script you're going to put on the player? I think it's better to have the script on a reference alias or magic effect that's then put on the player.

 

Anyway, this is an object reference script:

 

Scriptname UnarmoredLevelingScript extends ObjectReference
{Levels your Unarmored as you take hits.}

GlobalVariable Property Use auto
GlobalVariable Property Mod auto
GlobalVariable Property Level auto
GlobalVariable Property PointsAvailable auto
GlobalVariable Property PointsEarned auto
GlobalVariable Property PointsSpent auto
Keyword Property ArmorHeavy Auto
Keyword Property ArmorLight Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
if ((Self as Actor).WornHasKeyword(ArmorHeavy) || (Self as Actor).WornHasKeyword(ArmorLight))
	Return
endif
Use.SetValue(Use.GetValue()+Mod.Getvalue())
if Use.GetValue() >= 20
	Use.SetValue(Use.GetValue() - 20)
	Level.Setvalue(Level.Getvalue()+1)
	Debug.Notification("Your Unarmored level has been raised to " + Level.GetValue())
	Mod.SetValue(Mod.GetValue() - 0.01)
	PointsAvailable.SetValue(Level.GetValue()/5 - PointsSpent.GetValue())
	PointsEarned.SetValue(PointsSpent.GetValue() + PointsAvailable.GetValue())
endif
EndEvent

 

 

Reference alias script:

 

Scriptname UnarmoredLevelingScript extends ReferenceAlias
{Levels your Unarmored as you take hits.}

GlobalVariable Property Use auto
GlobalVariable Property Mod auto
GlobalVariable Property Level auto
GlobalVariable Property PointsAvailable auto
GlobalVariable Property PointsEarned auto
GlobalVariable Property PointsSpent auto
Keyword Property ArmorHeavy Auto
Keyword Property ArmorLight Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
if (GetActorReference().WornHasKeyword(ArmorHeavy) || GetActorReference().WornHasKeyword(ArmorLight))
	Return
endif
Use.SetValue(Use.GetValue()+Mod.Getvalue())
if Use.GetValue() >= 20
	Use.SetValue(Use.GetValue() - 20)
	Level.Setvalue(Level.Getvalue()+1)
	Debug.Notification("Your Unarmored level has been raised to " + Level.GetValue())
	Mod.SetValue(Mod.GetValue() - 0.01)
	PointsAvailable.SetValue(Level.GetValue()/5 - PointsSpent.GetValue())
	PointsEarned.SetValue(PointsSpent.GetValue() + PointsAvailable.GetValue())
endif
EndEvent

 

 

Not much of a difference.

 

 

@cobrasa9987

 

Sorry, I don't think your request is possible with the default scripting commands. Maybe someone who uses Script Dragon can make it, but otherwise you would have to wait for SKSE (the version with scripting functions is still in closed beta).

Link to comment
Share on other sites

Hello there!

 

I'm making a hunger mod and I'm a little stuck. I'm trying to make food "heal" a global hunger variable, but I can't figure it out.

 

Is there any way to have the magnitude of a particular magic effect be used inside a script attached to it? When I go into each food item's "potion" editor, I can add the effect, but that doesn't let me vary the amount of hunger restored from each food item. If not with magnitude, is there any other way to do this?

 

I also thought about grouping items that restore the same amount using keywords? Not that I know how to access the keywords any better than getting the magnitude, lol

 

The whole hunger mod would be extremely easy if the CK let us add/modify actor values. Then I might even be able to make other characters susceptible to hunger as well. Is there a script extender/other editor that can manipulate AV's?

Link to comment
Share on other sites

@IluisIndustries

 

I don't know of any way to add in new actor values, but I can think of a way to make it seem like there's an actor value like that.

 

 

Scriptname HungerAbilityScript extends ActiveMagicEffect

Faction Property HungerFaction Auto
Int Property UpdateInterval Auto
Formlist Property FoodsHighList Auto
Formlist Property FoodsMidList Auto
Formlist Property FoodsLowList Auto
Keyword Property VendorItemFood Auto
Actor Myself

Event OnEffectStart(Actor akTarget, Actor akCaster)
Myself = akTarget
;if NPC is not in the hunger faction, add him/her in
if (Myself.GetFactionRank(HungerFaction) < 0)
	Myself.SetFactionRank(HungerFaction, 0)
endif
;increment "hunger variable" every UpdateInterval seconds
RegisterForUpdate(UpdateInterval)
EndEvent

Event OnUpdate()
if (Myself.GetFactionRank(HungerFaction) < 100)
	;increment the "hunger variable" by 1
	Myself.ModFactionRank(HungerFaction, 1)
else
	;die of hunger
	Myself.Kill()
endif
EndEvent

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
if (FoodsHighList.HasForm(akBaseObject))
	;we just ate something from FoodsHighList
	Myself.ModFactionRank(HungerFaction, -5)
elseif (FoodsMidList.HasForm(akBaseObject))
	;we just ate something from FoodsMidList
	Myself.ModFactionRank(HungerFaction, -3)
elseif (FoodsLowList.HasForm(akBaseObject))
	;we just ate something from the FoodsLowList
	Myself.ModFactionRank(HungerFaction, -1)
elseif (akBaseObject.HasKeyword(VendorItemFood))
	;a food not in one of the lists (mod added?)
	if (akBaseObject.GetGoldValue() < 3)
		Myself.ModFactionRank(HungerFaction, -1)
	elseif (akBaseObject.GetGoldValue() < 5)
		Myself.ModFactionRank(HungerFaction, -3)
	else
		Myself.ModFactionRank(HungerFaction, -5)
	endif
endif
if (Myself.GetFactionRank(HungerFaction) < 0)
	;completely full
	Myself.SetFactionRank(HungerFaction, 0)
endif
EndEvent

 

 

You can give the ability to just the player, or check this to dynamically apply it to all actors. I've also heard that SkyProc can create patches to apply things to all NPCs, but I've never used it (and truthfully I have no idea how to even begin).

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...