Counting vampires killed with a specific weapon

Post » Fri Nov 16, 2012 6:29 pm

Edit: In the interest of anyone trying to do something like this in the future, the following is everything done so far:
Spoiler

- I've created a global with a value of 0 and called it "LoDVampsKilled".
- I've made my weapon and named it "LoDSword"
- I've Created a quest called LoDTrackerQuest, changed event to Kill Actor Event, and unticked Run Once, and then created one stage of 0, ticked Start up and Shut down and made an empty ENTRY.
- Created two Alias', the first "VictimAlias" with fill type as Find Matching Reference, from event, KillActor. Then Event Data, Victim. And set Match conditions for each vampire race.
- The second Alias I've named "KillerAlias" identical to victim with the exception of Event data which is set to Killer, and conditions which there is 1, GetEquipped with "LoDSword" specified.
- Now on stage 0 of my quest I've made a new property in Papyrus Fragment, it's type is Global, I've named it "LoDVampsKilled" and then set it's value to my Global of the same name.
- Entered the following into fragment:
if alias_KillerAlias.GetReference() == Game.GetPlayer()LoDKillCount.SetValueInt((LoDKillCount.GetValue() as int)+1)Debug.Notification(LoDKillCount.GetValueInt())endifstop()
-And assuming I haven't forgotten everything, it works! And hopefully if anyone needed this, I've saved some time.


Hi there, I've been trying to figure this out myself based on tutorials and questions somewhat relating to mine but I'm at a wall right now and not sure where I go from here.

I'm attempting to write a script that counts the amount of vampires killed with a custom weapon that I can then scale a perk or enchantment effect with, but first thing's first, vicious vampire murder.

Scriptname LoDTracking   extends ActorInt Property VampsKilled Auto = 0 ;Stores how many vampires have been killed with LoDEvent OnDeathIf Race HasKeyword (Vampire)VampsKilled = VampsKilled + 1ElseEndIfEndEvent
This is what I have right now, I'm sure it's laughably wrong all over but be gentle.

Don't get me wrong, I don't want anyone to write my entire script for me, but I could really use some helpful direction with this, and the tutorials I've found aren't pointing me the right way it seems.

Should I be using GetRace? And how would I use that here?

Thanks for any help!

EDIT: Got rid of my COMPLETELY wrong message section, let's pretend that never happened.
User avatar
Tinkerbells
 
Posts: 3432
Joined: Sat Jun 24, 2006 10:22 pm

Post » Fri Nov 16, 2012 10:01 pm

The main problem is that your script would need to be on every vampire in the game (and levelled actors don't run scripts).

If the player had an OnKill event, you could use that, but as it is you need to use the OnStoryKillActor event. This is a story manager event which means that you use it by creating a quest that is started by the KillActor event (there are some instructions near the bottom of http://www.gamesas.com/topic/1370343-trouble-casting-a-spell-from-an-wearable-item-to-player/page__p__20707539__hl__onstorykillactor__fromsearch__1#entry20707539, if you need them). You get an alias for the player and the victim from the event, so you could check the weapon and race there.

Another problem with your script is that Race is not a member of the Actor script. In a script that extends Actor (as yours does), you could call GetRace().HasKeyword() (note the dot). In a quest fragment you would have to use Alias_Player.GetRace().HasKeyword(), assuming the quest had an alias Player.
User avatar
Jason Rice
 
Posts: 3445
Joined: Thu Aug 16, 2007 3:42 pm

Post » Fri Nov 16, 2012 11:50 pm

Thanks for the response Ingenue, that sounds like a lot more work than I was expecting, but that's not necessarily a bad thing!

Think I'll have to go over the quest tutorials before I go further, thanks for pointing me in a direction! :biggrin:

Edit: Could I use conditions in alias' to determine whether the killer has the correct weapon equipped and that the victim is one of the vampire races (by setting GetIsRace conditions) and then simply have a papyrus fragment that increases an integer when the player meets the killer alias condition?
If any of that made sense at all.

2nd Edit: I'm trying to test this out myself anyway but the CK won't let me put anything in Papyrus Fragment, it's all greyed out, I continue to be confused. - Just had to make a log entry!

3rd Edit: Woop woop! It's working this way! Now all I need to do is set variables and what not! Thanks a ton Ing! :biggrin:
User avatar
suzan
 
Posts: 3329
Joined: Mon Jul 17, 2006 5:32 pm

Post » Sat Nov 17, 2012 9:42 am

Okay, now I'm stuck again, I need to add my property as a conditional inside a conditional script so that the enchantment can use the GetVMQuestVariable for scaling. Unfortunately fragments don't seem to be able to contain conditionals and are themselves not conditional, so I need a separate script to count the variable.
At this point, I am stuck, should I simply define the variable in a separate script and still have my fragment increase the integer? If so, how do I do that within the fragment? If it's possible that seems the simplest route to go.

Edit: I *think* I figured it out by using kmyQuest, feel free to reply still though! I have to go to work so I don't have time to test this.
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Sat Nov 17, 2012 9:33 am

Definitely sounds like you're on the right track. If you add a conditional script to the quest you can access it from fragments using kmyquest by selecting it in the kmyquest dropdown.
User avatar
Ice Fire
 
Posts: 3394
Joined: Fri Nov 16, 2007 3:27 am

Post » Fri Nov 16, 2012 6:43 pm

That's what I was hoping, now I'm all excited to get back to work on it!
User avatar
roxanna matoorah
 
Posts: 3368
Joined: Fri Oct 13, 2006 6:01 am

Post » Fri Nov 16, 2012 9:05 pm

Well, I'm home having a good crack at it, but I can't for the life of me manage to increase my variable at all, I'm using the method I mentioned previously, should the following be working or am I not setting the arithmetic correctly?

if alias_KillerAlias.GetReference() == Game.GetPlayer()float VampsKilledVampsKilled = kmyQuest.VampsKilledkmyQuest.VampsKilled + 1Debug.Notification("Yep, totally a vampire.")Debug.Notification(kmyQuest.VampsKilled)endifstop()

This is where I declare the property.
Scriptname LoDVampKillCount extends Quest Conditionalint VampsKilled_Var conditional   ; Where the property's value is storedint property VampsKilled  int function get()    return VampsKilled_Var  endFunction  function set(int value)    VampsKilled_Var = value  endFunctionendProperty

Naturally I'll continue to try and figure this out but as always, help is mucho appreciated!

Edit: For clarification, this is detecting whether or not a vampire is being killed accurately, however the value displayed afterwards is always at 0.
User avatar
Genocidal Cry
 
Posts: 3357
Joined: Fri Jun 22, 2007 10:02 pm

Post » Fri Nov 16, 2012 8:03 pm

You don't need to put the get and set functions in.
Int Property VampsKilled Auto
would do that for you. But you also don't need to make VampsKilled a property, a variable is fine. Properties are created and assigned with the Properties button in the CK and typically refer to object references in the game.

All that is preamble. The main problem is that you aren't assigning the value + 1 to the value. You could do kmyQuest.VampsKilled = kmyQuest.VampsKilled + 1 or kmyQuest.VampsKilled =+ 1, or put an IncreaseVampsKilled function in the quest script that assigned to the variable. Anyhow there has to be an equals sign in there somehow.
User avatar
Lawrence Armijo
 
Posts: 3446
Joined: Thu Sep 27, 2007 7:12 pm

Post » Fri Nov 16, 2012 8:21 pm

For some reason the variable wasn't showing up in GetVMQuestVariables for the enchantment scaling until I made it a property, that's the only reason I did that, I've simplified it down to an auto property though, thanks.

So it's sort of counting now, on each vampire kill it counts 1, 2. As in - Kill 1, 2 - Kill 1, 2 - Kill 1, 2- like some kind of demented dance instructor. Not sure what's happening with it. :confused:
I only changed the value being assigned, failing basic arithmetic feels bad.
if alias_KillerAlias.GetReference() == Game.GetPlayer()float VampsKilledkmyQuest.VampsKilled = kmyQuest.VampsKilled + 1Debug.Notification("Yep, totally a vampire.")Debug.Notification(kmyQuest.VampsKilled)endifstop()
User avatar
A Lo RIkIton'ton
 
Posts: 3404
Joined: Tue Aug 21, 2007 7:22 pm

Post » Sat Nov 17, 2012 12:39 am

Sorry, just realized it's a quest property, and you're starting and stopping the quest - it gets reset. Use a global variable (or a variable in another quest).
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Sat Nov 17, 2012 9:16 am

Ahah, that makes sense, would it be better practice to use one over the other?
User avatar
Ashley Tamen
 
Posts: 3477
Joined: Sun Apr 08, 2007 6:17 am

Post » Sat Nov 17, 2012 5:57 am

I don't know, sadly. I have read in http://www.gamesas.com/topic/1361933-modding-best-practices-and-changes-persisting-in-saved-games/page__p__20547357__hl__avoid%20global%20variables__fromsearch__1#entry20547357some advice about avoiding global variables, but since quest variables are saved in the save game too, for all I know they have the same problems. I should love to hear comments from anyone else :)
User avatar
R.I.P
 
Posts: 3370
Joined: Sat Dec 01, 2007 8:11 pm

Post » Sat Nov 17, 2012 8:05 am

Based on some of that thread my use of global variables should be fine since all I'm doing is counting up and using a greater than or equal to argument, if any duplicates crop up with 0 they should be ignored.
Now I'm learning how to actually...use...global variables.
This is pretty enjoyable.
User avatar
Cccurly
 
Posts: 3381
Joined: Mon Apr 09, 2007 8:18 pm

Post » Fri Nov 16, 2012 7:33 pm

Just showing my face charlie (see what I did there) to say I'm working on a similar idea, using variables and such, but not with a particular weapon and not with vampires, do don't worry not competing ;) Just wanted to say I hope you sort it soon, sounds pretty cool, and also if you figure it out please post how it works and stuff :)
User avatar
Mark
 
Posts: 3341
Joined: Wed May 23, 2007 11:59 am

Post » Sat Nov 17, 2012 10:44 am

Once I've gotten anywhere with these global variables I should be making tracks, once I have everything working I'll be starting over from scratch so none of my butchered horrid mistakes are left behind in the plugin, at which point I'll gladly post exactly what my process was here!

Is your kill tracking to do with your Hunting guild by chance? I'm very interested in seeing how that pans out!

P.s. I see what you did there!
User avatar
Jamie Lee
 
Posts: 3415
Joined: Sun Jun 17, 2007 9:15 am

Post » Fri Nov 16, 2012 10:55 pm

Ace man :)

It is mate yea, just juggling some ideas around, basically what cool little things can I have. And I was thinking of having maybe dialogue show when the player has killed x amount of animals or creatures or vampires or dragons... that sort of thing :)

Variables and stuff are a bit too advanced for me right now, have no idea where to even put a script to track a variable like animals killed (unless it's in a silent quest, in which case I know but don't know).

But it was only a couple of months ago I knew nothing of modding, and now I surprise myself with the cool things I'm able to do in the CK now lol.
User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Sat Nov 17, 2012 10:37 am

I am now stuck once again, I'm really having trouble figuring out how to modify global values within the fragment at all, the wiki is very unclear about globals and their use, at least to my nooby nooby eyes anyway.
Starting to feel like it actually would've been easier to run another quest to hold the value but I wasn't sure how to set that quest up.
The quest for kill count would just be a script event right?
With an auto property to store the count in so that the first quest can write and read it correct?
Assuming I'm correct with that there is one thing I am still unsure of, I don't understand how to access that quests script properties from my original quest, I will play around with it however and try to figure it out.

Edit: Would making the new script I'm naming LoDDepositBox an extension of the first script give the first script access to the variables? Or would that have to be the other way around? Or neither, I am 100% wrong? :blush:
User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Sat Nov 17, 2012 8:09 am

There is another way of doing this, sorry if this has been mentioned already:
Make the weapon grant an ability to the player. This ability happens to be a constant effect cloak.
This cloak has as its first associated item a concentration aimed script spell. This spell should be conditioned to only work on vampire races.
This script spell in turn attaches a different ability to actors that OnDeath modifies a global or conditional variable, if akKiller.GetEquippedWeapon()==WeaponInQuestion; AssociatedGLobal.SetValue((AssociatedGlobal.GetValue() as int)+1)
User avatar
Damian Parsons
 
Posts: 3375
Joined: Wed Nov 07, 2007 6:48 am

Post » Sat Nov 17, 2012 4:58 am

That actually sounds like a pretty good way of handling the simple counting mechanic, thanks Ducey, I'll give that a go once Steam has redownloaded my base game. I was getting quite a few CK crashes that I assume were due to some loose files.
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Sat Nov 17, 2012 4:27 am

Actually crashing is often due to security software, as I found out recently. Things like AVG and Norton should be fine, but if you have certain VPN type security stuff I think you run into problems.
User avatar
Epul Kedah
 
Posts: 3545
Joined: Tue Oct 09, 2007 3:35 am

Post » Fri Nov 16, 2012 9:28 pm

I don't have anything like that, but I was getting errors starting the CK up every time so I figured it was some bad files it was trying to load that didn't have what they needed from certain .esm/.esp's.
User avatar
Lexy Corpsey
 
Posts: 3448
Joined: Tue Jun 27, 2006 12:39 am

Post » Fri Nov 16, 2012 8:20 pm

Everyone gets some errors when they start up the CK as far as I'm aware.
User avatar
Monika Krzyzak
 
Posts: 3471
Joined: Fri Oct 13, 2006 11:29 pm

Post » Sat Nov 17, 2012 6:04 am

Ah, I just assumed most people wouldn't. Well what a waste of time! :-p
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Sat Nov 17, 2012 12:12 am

So I'm exploring the first option of using quests right now and using Ducey's method as a backup simply because I think I'm getting a good handle on how the quest system works, with one exception, I don't know to change my new conditional variable without using it as kmyQuest, which would cause the same repetition I'm experiencing.
I have my second quest set up with a script that simply declares my new conditional property where I'll track how many vampires have been killed.
I just need my first script to increase that number, and I'm not totally sure how I get there.

Edit: I'm waiting for my CK to start up after crashing so I'm just playing with ideas, does referencing it by scriptname.variable work for that? Or do I need to actually attach the script to the quest somehow?
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Fri Nov 16, 2012 7:04 pm

You would make a quest type property on the first quest's script and fill it with the second quest, then call a function in the second quest. The only slight hiccup is the need to cast to whatever the second quest's script is called, e.g.:

Quest Property SecondQ Auto

(SecondQ as SecondQuestScript).MyFunction()
User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Next

Return to V - Skyrim