Jump to content

Quick Questions, Quick Answers


Mattiewagg

Recommended Posts

I'm trying to finish an enchantment that will, once finished and working, give experience to the player's lowest skill each time you hit an enemy with a weapon with the enchantment. I have a script typed up and ready to attach to the enchantment, but I'm not sure it will function as intended in its current state, so I have to ask... What is the easiest way to have a script do something each time you hit someone with an enchanted weapon, with the script being attached to the enchantment's effect?

 

 

Here's the script I currently have:

 

scriptName DarkxSkillAdvEnchScript extends ActiveMagicEffect

String[] Property sSkills auto
float fXP

Event OnEffectStart(Actor akTarget, Actor akCaster)
	int iSkillToAdv = checkSkills()
	string sSkill = sSkills[iSkillToAdv]
	fXP = calcXp()
	Game.AdvanceSkill(sSkill, fXP)
EndEvent

int Function checkSkills(int iVar = 0)
	int iLowestSkillLvl = 100
	int iSkillLvl = 0
	int iCurSkill = 0
	int iSkill = 0
	while(iCurSkill <= 17)
		iSkillLvl = Game.GetPlayer().GetBaseActorValue(sSkills[iCurSkill])
		if(iSkillLvl < iLowestSkillLvl)
			iLowestSkillLvl = iSkillLvl
			iSkill = iCurSkill
		endIf
		iCurSkill += 1
	endWhile
	return iSkill
EndFunction

float Function calcXp(float eXp = 0.0)
	if(Game.GetPlayer().GetEquippedWeapon())
		eXp = Game.GetPlayer().GetEquippedWeapon().GetBaseDamage()
	elseIf(Game.GetPlayer().GetEquippedWeapon(true))
		eXp = Game.GetPlayer().GetEquippedWeapon(true).GetBaseDamage()
	else
		eXp = 0
	endIf
	return ((eXp * eXp)*0.01)
EndFunction

 

As I mentioned, I'm not sure if it'll work as intended... I'm currently going on less than 3 hrs. of sleep in the past 48 hrs., so I'm about to pass out but figured I would ask before I go to sleep so that I can hopefully have an answer when I awaken. That way I can make whatever adjustment(s) that might be needed when I'm back in working condition.

 

 

Link to comment
Share on other sites

  • Replies 2.6k
  • Created
  • Last Reply

Top Posters In This Topic

I'd like to make weapons "no recharge". That is to say, I'd like to be able to make a Fire Damage Enchantment that the player can place on their favorite weapon, but that NEVER RUNS OUT of charges, and doesn't have to be recharged via soul gems and whatnot.

 

Ideally, I'd like to make it to where NO weapon ever needs recharging (except maybe staves since they're weird anyway.)

 

After all, your armour enchantments never have to be recharged, even if you get hit a zillion times in one fight. So why should your weapon have to be recharged even if you use it a zillion times?

 

1) Do I just make (for instance) "AllaNoChargeFire" enchantment, and uncheck the "Auto-Calc" box, and set the charge to 0 ...? or does the charge need to be set high, or something?

 

or,

 

2) Can this be done as a hidden perk, for lack of a better way to put it? Not something added to a perk tree, but something like the "Shout" perk, that exists as soon as the player exists? If so, how the heck do I go about that?

 

And, final note, I CANNOT use video tutorials or yootoob tutorials, for a variety of reasons.

 

Thanks for any advice or help!

Edited by Allannaa
Link to comment
Share on other sites

@DarkXenoth: I don't see any obvious problems. To be clear, this is the magic effect that gets applied to the enemy being hit, right?

 

You may want to put conditions on the magic effect (i.e. the form, not the script) so that the player can't level by attacking harmless critters. Or not. Depends on what you're going for.

Link to comment
Share on other sites

 

I'd like to make weapons "no recharge". That is to say, I'd like to be able to make a Fire Damage Enchantment that the player can place on their favorite weapon, but that NEVER RUNS OUT of charges, and doesn't have to be recharged via soul gems and whatnot.

 

Ideally, I'd like to make it to where NO weapon ever needs recharging (except maybe staves since they're weird anyway.)

 

After all, your armour enchantments never have to be recharged, even if you get hit a zillion times in one fight. So why should your weapon have to be recharged even if you use it a zillion times?

 

1) Do I just make (for instance) "AllaNoChargeFire" enchantment, and uncheck the "Auto-Calc" box, and set the charge to 0 ...? or does the charge need to be set high, or something?

 

or,

 

2) Can this be done as a hidden perk, for lack of a better way to put it? Not something added to a perk tree, but something like the "Shout" perk, that exists as soon as the player exists? If so, how the heck do I go about that?

 

And, final note, I CANNOT use video tutorials or yootoob tutorials, for a variety of reasons.

 

Thanks for any advice or help!

 

One way to do it would be to edit the Magic Effects used by the enchantment(s) that you want to have infinite charges; making them have 0.0 Base Cost. This would result in the enchantments using 0 charge. Of course, I have no idea what that might do when you go to use an enchanter to apply such an enchantment to an item... It might work fine, and you'd just have to limit yourself on how powerful you think the enchantment should be; or it might crash the game. My thinking behind this warning is - if you're putting an enchantment on a weapon, I'm pretty sure the system limits it based on the enchantment's charge cost (i.e. with no charge cost, you might be able to set an enchantment to do 10000 fire damage; or it might crash trying to figure out the max damage).

 

@DarkXenoth: I don't see any obvious problems. To be clear, this is the magic effect that gets applied to the enemy being hit, right?

 

You may want to put conditions on the magic effect (i.e. the form, not the script) so that the player can't level by attacking harmless critters. Or not. Depends on what you're going for.

It is attached to the Magic Effect that the Enchantment uses, yes... So the OnEffectStart event would be triggered each time I hit an enemy?

 

 

Link to comment
Share on other sites

Hello


I have an odd question regarding the internal work of papyrus. I am wondering where the codes in papyrus are actually executed? Are they executed by CPU or GPU or case-dependent. The reason I ask is that I often notice the poor utilization of system resource by skyrim engine; I can have script-lag even when my cpu is at 10% and GPU is at 50% usage etc.



I understand that papyrus will delay the unprocessed scripts to the next second if they are not processed within 1.2 ms. However, I just could not comprehend why I could get script-lag while my graphic is smooth and my cpu usage is below 15%.



My guess is that some events and partial code execution are done by GPU and I believe they should be reasonably fast. So I am wondering If there are certain functions that are extremely taxing on the cpu part?


Link to comment
Share on other sites

Papyrus doesn't run through the GPU at all. It just doesn't get as high a priority as the graphics engine, physics engine, and so on. Skyrim isn't going to break its back to run Papyrus scripts.

 

I don't know what sort of lag you're talking about -- is everything lagging, or is one specific thing lagging? In the former case, you may have expensive or poorly-optimized scripts running in the background.

Link to comment
Share on other sites

 

Hello

I have an odd question regarding the internal work of papyrus. I am wondering where the codes in papyrus are actually executed? Are they executed by CPU or GPU or case-dependent. The reason I ask is that I often notice the poor utilization of system resource by skyrim engine; I can have script-lag even when my cpu is at 10% and GPU is at 50% usage etc.

I understand that papyrus will delay the unprocessed scripts to the next second if they are not processed within 1.2 ms. However, I just could not comprehend why I could get script-lag while my graphic is smooth and my cpu usage is below 15%.

My guess is that some events and partial code execution are done by GPU and I believe they should be reasonably fast. So I am wondering If there are certain functions that are extremely taxing on the cpu part?

 

I'm not sure that's really a quick question, but I'll try to give a relatively quick answer. You are headed down the wrong path with that thinking. The 1.2 ms is how much time scripts can have each frame not each second. That limit is actually in place to ensure Papyrus doesn't consume too much of the CPU time each frame because the CPU also has to deal with AI, magic effects, and everything else that involves condition functions along with general game oversight. At the ideal 60 FPS, that's slightly more than 1/16th of the time and the CPU has plenty of other things to do and that's Papyrus's fair share of the total.

 

Papyrus is an event-driven, threaded language which is something very rare. Almost no one actually has real experience writing in such a language. So people writing scripts without considering or understanding what that means are the primary cause of lag (along with many people running more mods than their system can handle). Read the Threading Notes page and notice just how often objects get locked and unlocked. Also consider that almost all of the functions require one frame to complete. Script performance is tied to the graphic performance through frame rate but not because of any direct use of the GPU by the scripting system.

Link to comment
Share on other sites

Hi DavidJCobb thanks for the reply; heartening to see you again.

 

The script-lag I am talking about is something I have experienced when I had a heavy mod-list. The script-lag was everywhere; for example I had hunterborn/RND/ultimate deadly encounter/Perma/worlds dawn etc running together before and the script lag was overwhelming. The game did not stutter but papyrus simply can't keep up.

 

I understand that I would get script-lag when I have script-heavy mods but the fact that my cpu usage is below 15% when I am experiencing these lags were just beyond me. Even if skyrim is old or doesn't take advantage of multi-thread, 15% just seemed unreasonable. So I am sure I am missing some knowledge about the scripting engine.

 

The reason I am asking all of these is because I am making a mod myself right now and I want to minimize any possible burden on the scripting-part of skyrim engine.

Link to comment
Share on other sites

Hello need help from skyproc patcher users

I want to access the actual record of an outfit given only the FormID of the outfit. Since there is no direct method to get the record I have to iterate though all the outfit. But It seems that I could not get the record when given the formID for god only knows reasons. Here is my code

 

 

 

public OTFT GetOTFTRecordFromFormID (OTFT [ ] OTFTPool, FormID OTFTID) {

int counter=-1;

for (OTFT tempotft: OTFTPool) {

 

if (tempotft.getForm( ).equals(OTFTID)) {

counter=i;
break;
}
}

OTFT MyOutFit = OTFTPool[counter];
return MyOutFit;
}

 

 

 

 

It is a very straight-forward code and similar code worked before but for some reason my counter is always -1; This makes no sense since I expect an outfit formID should always exist in the total collection of outfit formIDs.

 

I did something similar to iterate through the races before and it worked perfectly. Is there something different about OTFT class?

 

FYI I converted the OTFT Grup to an array with the code

 

OTFT[ ] OTFTArray = merger.getOutfits().getRecords().toArray(new OTFT[merger.getOutfits().size()])

 

If this could be the problem.

Edited by qiusheng33
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...