adding a perk to all actors in the game

Post » Mon Jun 18, 2012 2:35 pm

Trying to add a perk to all the actors in the game.

Ok I have the following working in the game (thanks to http://www.gamesas.com/user/523547-xepha/ )

Scriptname aadpMainCombatQuest extends Quest EVENT onInit()		 registerForUpdate(3)		 gotoState ("stuff")endEVENTSTATE stuff		 EVENT onUpdate()					 				 Debug.MessageBox("Hello, World!")		 endEVENTendSTATE

How do I change this to add a perk to all the actors?

After I can do that then I will learn to filter it just for actors that use a weapons.
User avatar
Matthew Aaron Evans
 
Posts: 3361
Joined: Wed Jul 25, 2007 2:59 am

Post » Mon Jun 18, 2012 4:11 am

I've recently been thinking about this, and there's a trick that I think might work.

In each of your Update events, try something like this:
Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 2000)if (randomActor.GetItemCount(YourToken) <= 0)	randomActor.AddItem(YourToken, 1)endif

It's certainly not efficient, but it should work and it avoids setting up a Explosion or AOE effect.
User avatar
Taylor Bakos
 
Posts: 3408
Joined: Mon Jan 15, 2007 12:05 am

Post » Mon Jun 18, 2012 3:51 am

OH yeah... cool Reneer, thanks. I am going to need that for sure (adding tokens to the actors) but for now I was hoping to just "extend" the base actor somehow
and use something like:


; Adds the awesome perk to the player
Game.GetPlayer().AddPerk(AwesomePerk)

But not just on the player.

So this "get random actor" command will get the actor refs around the player huh? WOW good find!

is the 2000 the number of attempts or the distance it trys to find them?

I've recently been thinking about this, and there's a trick that I think might work.

In each of your Update events, try something like this:


Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 2000)if (randomActor.GetItemCount(YourToken) <= 0)	randomActor.AddItem(YourToken, 1)endif

It's certainly not efficient, but it should work and it avoids setting up a Explosion or AOE effect.
User avatar
Brian Newman
 
Posts: 3466
Joined: Tue Oct 16, 2007 3:36 pm

Post » Mon Jun 18, 2012 3:04 pm

But I also still need to add the arrow deflection perk to ALL actors as in my OP.
User avatar
Lily Something
 
Posts: 3327
Joined: Thu Jun 15, 2006 12:21 pm

Post » Mon Jun 18, 2012 11:02 am

The 2000 is the unit distance that it searches for random actors. And I think that once you get that actor's reference, you can just use http://www.creationkit.com/AddPerk_-_Actor.
User avatar
Mackenzie
 
Posts: 3404
Joined: Tue Jan 23, 2007 9:18 pm

Post » Mon Jun 18, 2012 1:04 pm

like this?

I am sure this is not right:


Scriptname aadpMainCombatQuest extends QuestEVENT onInit()		 registerForUpdate(3)		 gotoState ("stuff")endEVENTSTATE stuffEVENT onUpdate()					Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 2000)if (randomActor > 0)	   randomActor().AddPerk(AwesomePerk)  Debug.MessageBox("add perk to actor")endif			  endEVENTendSTATE
User avatar
Felix Walde
 
Posts: 3333
Joined: Sat Jun 02, 2007 4:50 pm

Post » Mon Jun 18, 2012 3:03 am

yeah that got me a bunch of compile errors:



Starting 1 compile threads for 1 files...
Compiling "aadpMainCombatQuest"...
c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(14,10): randomActor is not a function or does not exist
c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(14,10): cannot call the member function randomActor alone or on a type, must call it on a variable
c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(14,32): variable DeflectArrows is undefined
c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(14,24): none is not a known user-defined type
No output generated for aadpMainCombatQuest, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on aadpMainCombatQuest
User avatar
Yvonne Gruening
 
Posts: 3503
Joined: Mon Apr 23, 2007 7:31 pm

Post » Mon Jun 18, 2012 10:12 am

Close, but try this:

Scriptname aadpMainCombatQuest extends QuestEVENT onInit()		 registerForUpdate(3)		 gotoState ("stuff")endEVENTSTATE stuffEVENT onUpdate()				    Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 2000)if (randomActor.HasPerk(AwesomePerk) == 0)	   randomActor.AddPerk(AwesomePerk)  Debug.MessageBox("add perk to actor")endif			  endEVENTendSTATE
User avatar
Beulah Bell
 
Posts: 3372
Joined: Thu Nov 23, 2006 7:08 pm

Post » Mon Jun 18, 2012 12:21 pm

oh man ALL MOST THERE!!!!

I get this error:

c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(14,24): variable DeflectArrows is undefined

I am not using the sample perk "AwesomePerk" I am using the perk ID:

DeflectArrows

This "DeflectArrows" is exactly how the vanilla PERK is named in the CK. So why the error?

Do I need to assign the ID DeflectArrows to some kind of script variable? Like: PerkTemp = DeflectArrows

Thanks again Reneer for taking time away from your own projects to help on this.

GOD...I felt so powerful as a Oblivion moder in the last couple of years...almost anything I wanted to do I could find a way to do it...but now I feel like a stumbling, drooling babbling toddler moder. And it is not a fun feeling but I know I am not the only one.
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Mon Jun 18, 2012 2:03 pm

You've run into one of the (to me) more annoying aspects of Skyrim scripting: references and aliases / http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions.

Basically, what you need to do is this:

Perk Property AwesomePerk Auto (copy that to the top of your script, like you would a float or ref)

Now, you need to save the script (comment out any lines that may refer to AwesomePerk for now) and then compile the script. Then right-click and access the properties of the script, and you should be able to "select" that AwesomePerk thing, and set it to the DeflectArrows perk proper. Then click ok, uncomment the code, and compile.

Note that there is likely another / easier way to do this, but this is how I've been doing it.

I understand why Bethesda did it this way... it's just annoying to me. :P
User avatar
Heather beauchamp
 
Posts: 3456
Joined: Mon Aug 13, 2007 6:05 pm

Post » Mon Jun 18, 2012 2:02 am

Duke Patrick, could you share your solution here too? I would like to do something similar as well. Ie: Adding a perk to all npcs.
User avatar
cutiecute
 
Posts: 3432
Joined: Wed Sep 27, 2006 9:51 am

Post » Mon Jun 18, 2012 9:25 am

I will let you know as soon as I do!

I have it mostly working now (more or less) but it is giving me the message box that it is adding the perk to actors CONSTANTLY and it should STOP after 5 actors as that is all that is in the test cell I am in. So there is still something not right. I added a message box to tell me IF the perk was found on the actor and I do get that message sometimes as well so I know for a fact the perk IS being added to the/some actors.

Just seem like maybe there are dozens more actors than I know about in the cell, or (more likely) there is still something not right with my script.

Anyway I will look into this more this weekend. But for now Reneer has me going in the right direction and I could not have done it witout his help.


Duke Patrick, could you share your solution here too? I would like to do something similar as well. Ie: Adding a perk to all npcs.
User avatar
Thomas LEON
 
Posts: 3420
Joined: Mon Nov 26, 2007 8:01 am


Return to V - Skyrim