3 little questions

Post » Sun Nov 18, 2012 5:28 am

Hello. I am a rather noob at Papyrus. Sadly, there are lots of things i don't understand yet. I am familiar with Java, so the scripting itself is not too much of a problem, however i have run into 3 problems.


1: I want something to happen if the players health drops under 30%. How do i do that? My problem with this are two things: getHealthPercentage does not work, how can i get the percentage of the casters health? Second how can i have the spell keep an eye on the players health? If functions only work once, i would need it to permanently check the health while the spell is active.In the worst case i only need the function to check the players health and the player needs to cast the spell when he has under 30% health, that would be inconvenient though.

2: Rather the same as 1, just that here i don't want to check the players health, but want something to be triggered when the player kills a (friendly) NPC. I suppose it would work the same, the only thing i don't know the function for checking the player killing a (friendly) NPC.

3: I noticed a lot of my ideas, like 1 and 2 fail on the fact that i am missing a function to check it, most commands like Dispel and Cast i know from other scripts, is there a way to check what functions a Object(for example "caster" ) can do? Like Caster.getLevel() , Caster.Addspell and so on. Can i somewhere check what a object can do? I got these infos from the Creation Kit Wiki and other Scripts, but the more advanced my projects get, the less the infos are sufficient.


PS: Is there a console command to let me read a globalvariable in-game?
User avatar
candice keenan
 
Posts: 3510
Joined: Tue Dec 05, 2006 10:43 pm

Post » Sun Nov 18, 2012 6:21 am

1. Have a look at the http://www.creationkit.com/RegisterForUpdate_-_Form function (and its variants http://www.creationkit.com/RegisterForSingleUpdate_-_Form, http://www.creationkit.com/RegisterForUpdateGameTime_-_Form, http://www.creationkit.com/RegisterForSingleUpdateGameTime_-_Form) and the http://www.creationkit.com/OnUpdate_-_Form event (http://www.creationkit.com/OnUpdateGameTime_-_Form). You could cast the spell and have it run your script on the player. When it detects that the player's health is under 30% you can use the http://www.creationkit.com/Cast_-_Spell function to cast another spell. I'll have a look at GetHealthPercentage when I have a chance.

2. I'm guessing it would involve checking which faction(s) the NPC belongs to.

You can use the GetGlobalValue GlobVarNameHere in the in-game console. http://www.uesp.net/wiki/Skyrim:Console a list of available commands.
User avatar
Ross
 
Posts: 3384
Joined: Thu Aug 10, 2006 7:22 pm

Post » Sat Nov 17, 2012 11:52 pm

Thanks. I think i got what i need for the percentage. It's not GetHealthPercentage, but it has GetActorValuePercentage(Health). So i will use this instead. I will take a look at the update, so that should be worked out. I will also see what i can do abot 2. Thanks for the help. If someone has any ideas for problem 2 please post them here.

EDIT:

Yep a GetActorValuePercentage("Health") with a OnUpdate Event worked for my first problem.

Now i just need a answer to question 2: How can i get it to trigger when the player kills a innocent?
User avatar
Claudz
 
Posts: 3484
Joined: Thu Sep 07, 2006 5:33 am

Post » Sun Nov 18, 2012 6:04 am

Having a look at the http://elderscrolls.wikia.com/wiki/Ebony_Blade_(Skyrim) and how it works might prove useful.
User avatar
Amy Cooper
 
Posts: 3400
Joined: Thu Feb 01, 2007 2:38 am

Post » Sun Nov 18, 2012 1:26 pm

just a word of advice, do not EVER under any circumstance use registerforupdate(). mod authors (who are making mods that have a possibility of being uninstalled from the save game without forcing the user to start a new game) have absolutely no business using this function call, instead use registerforsingleupdate() and repeat with a condition guard if necessary.

the reason for this is that registerforupdate requires a 100% mandatory uninstall process or else the save game could be corrupted if the user simply pulls the plug on the mod with the update loop running. and let's be realistic here, what are the chances the user will actually bother doing the uninstall procedure when they decide to uninstall it. even long after the mod has been removed, the save game will continuously call and fail on the update event... forever.

if using registerforsingleupdate, the save game will only run the update event once before quitting.


there are certainly situations where this becomes a moot point (like self-terminating magic effects) but it's always better to be on the safe side.
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am

Post » Sun Nov 18, 2012 3:28 pm

Well it does use a unregister option too, so if a player does not save the moment they use the spell it should be safe, but i guess you are right. I have run into some trouble with my script that seems to work quiet wrong, but i will change this once i got things worked out. I wll also take a look at the ebony blade since it seems to have just the effect that i need. It seems to work on friends instead of any unhostile npc, but for my needs that might actually be even better.
User avatar
Carys
 
Posts: 3369
Joined: Wed Aug 23, 2006 11:15 pm

Post » Sun Nov 18, 2012 1:36 pm

Ok my problem is sorted out, the script works as it is supposed now. Now to my last problem:

Alright so after taking a look at the ebony blade it prove not to be very usefull. It seems to check if the guy who was killed(in the script as target) belongs to the friendsfaction. It uses a quest to keep track of that. I don't need a quest, since i need exactely once i don't need to keep track of it, that is not the problem.

The REAL problem is that my spell is delivered on self since it is a buff. That means that target is not a killed person. How i can check on a killed person if the script has no way of getting it?
I suppose in the very worst case i might alter the story to need a special ritual weapon with a special enchantment that stores a kill in a global variable, which is then checked with a if function by the script of my spell. That would be the easiest method, but i don't really like this way.

Does anyone know how i could do it more conveniently? I don't know anything about making quests, maybe that would work? But i suppose it would have the same problem, no way of telling who the player killed last.

Is there something like caster.getlastkilled() and see if that fits into the right faction? Something like a command to get the last actor killed by the person? Or does anyone have a idea?
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Sun Nov 18, 2012 6:58 am

Bump
User avatar
Silvia Gil
 
Posts: 3433
Joined: Mon Nov 20, 2006 9:31 pm


Return to V - Skyrim