Begginer Modder's Question

Post » Mon Jun 18, 2012 1:00 am

I'm brand new to the CK and modding scene in general. I've read through the tutorials, reading through the creationkit.com reference and have been practicing constantly but I can't figure out how to mod an actors actor value that isn't the player.

Using Game.GetPlayer().ModAV("", value) I can modify the actor values of the player on the fly, but I haven't been able to figure out how to use the same syntax for the modification of an NPC in question...

Should I use a property? How can I reference a specific actor in the game world?

Thanks.
User avatar
Beat freak
 
Posts: 3403
Joined: Thu Dec 14, 2006 6:04 am

Post » Sun Jun 17, 2012 9:39 pm

Sorry for the double post, but I'll give a little background:

I want to use one of the unused stats in the editor, Fame, to be a separate stat on a weapon. When you equip the weapon, the player gains fame and when you unequip the weapon the player loses fame.

I have another script on a particular actor that, when hit, should react according to the amount of fame the aggressor has. In this case, when the on-hit function is triggered, I want to modify the health of the actor.
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Sun Jun 17, 2012 7:49 pm

Edit: To make a more productive bump, why won't this work? Is it my syntax?

Scriptname DebugBoss extends ObjectReference

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
float playerPen = Game.GetPlayer().GetActorValue("fame") as float
float playerAttack = Game.GetPlayer().GetActorValue("MeleeDamage") as float
float actual = playerPen + PlayerAttack
Actor DebugBoss.ModAV("Health", actual)
EndEvent

This script returns the error: required (...)+ loop did not match anything at input '.'
User avatar
Aaron Clark
 
Posts: 3439
Joined: Fri Oct 26, 2007 2:23 pm

Post » Mon Jun 18, 2012 12:22 am

Bump for you, I'd like to see this answered.
User avatar
Brandon Bernardi
 
Posts: 3481
Joined: Tue Sep 25, 2007 9:06 am

Post » Mon Jun 18, 2012 4:45 am

To address the compiler error first (guessing at the line here since you didn’t include the line number in the error message) – the compiler is reading the following line of your script "Actor DebugBoss.ModAV("Health", actual)" and is getting confused because it thinks you are defining a variable named DebugBoss and it isn’t expecting the ‘.’ character.

In terms of your original question, you’ve already figured out that to call ModAV on the player, you need to put “Game.GetPlayer()” in front of a ‘.’ character with “ModAV” after the ‘.’ If you want ModAV to work on something that isn’t the player, you need to replace what is before the ‘.’ with something else. In a lot of cases this will be a variable or property you define in your script. For example, to call ModAV on a property, you might have something like this:

Actor Property OtherGuy AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \bool abBashAttack, bool abHitBlocked)  OtherGuy.ModAV("Health", 10)EndEvent

And then, when you attach your script to something in the editor, you use the property window to point “OtherGuy” at the actor you want to affect.

In your particular example, it looks like what you want to do is affect the actor that your script is attached to, in which case we can actually save you some typing. First, change the “extends ObjectReference” at the top of your script to “extends Actor” – this tells the compiler that your script will be attached to Actors in the game (and also means the game won’t let you attach the script to anything that isn’t an actor). Next, change “Actor DebugBoss.ModAV("Health", actual)” to simply “ModAV("Health", actual)”. You’ll notice there is no ‘.’ If there is no ‘.’ (the function is just on its own), then the compiler assumes that what you want to affect is the object the script is attached to, rather than something else.

You should end up with something like this:

Scriptname DebugBoss extends ActorEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \bool abBashAttack, bool abHitBlocked)  float playerPen = Game.GetPlayer().GetActorValue("fame") as float  float playerAttack = Game.GetPlayer().GetActorValue("MeleeDamage") as float  float actual = playerPen + PlayerAttack  ModAV("Health", actual)EndEvent

Hopefully that was clear enough and helps :smile:
User avatar
c.o.s.m.o
 
Posts: 3419
Joined: Sat Aug 12, 2006 9:21 am

Post » Sun Jun 17, 2012 8:08 pm

It worked great! Thanks a ton for the tips and code. It helped tremendously.
User avatar
Steven Hardman
 
Posts: 3323
Joined: Sun Jun 10, 2007 5:12 pm


Return to V - Skyrim