Get actor ID

Post » Mon Nov 19, 2012 12:11 am

Hello
I want to to make a script and attach it to an actor and get his ID on hit event. how do i do it ?
User avatar
Felix Walde
 
Posts: 3333
Joined: Sat Jun 02, 2007 4:50 pm

Post » Sun Nov 18, 2012 8:53 pm

By ID, do you mean their formID? If so, are you looking for the formID of the Actor or the ActorBase?

Cipscis
User avatar
Iain Lamb
 
Posts: 3453
Joined: Sat May 19, 2007 4:47 am

Post » Mon Nov 19, 2012 2:33 am

Hello Cipscis
No, his Main Actor ID when you open an Actor in the Object window\Actors\Actor
Here is the deal. do you remember before when you helped me out with Event Onhit in order to get the actor level ?
well it did not work. I had to open the actor in the game map, and give it an new ID in the "Reference Editor ID" So I can Set A Value To It In Order To Work
i had to change to this:
Scriptname gp_testxp extends ObjectReference
Actor Property PlayerRef Auto
Actor Property GP_01REF Auto
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool bHitBlocked)
If akAggressor == PlayerRef
Debug.Notification("Level " + GP_01REF.GetLevel())
endif
EndEVENT

now the problem is ia have to make a diferent script with a different name for each actor in game !
instead i thought if i can add a function to get the actor main ID since each actor in game has a unique Main ID like this for example:

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool bHitBlocked)
If akAggressor == PlayerRef
GetID()
Debug.Notification("Level " + ID.GetLevel())
endif
EndEVENT

i Know there isnt any function called GetID(), but just to tell you what i would like to do.
or tell me how to do it in another way.
thx.
User avatar
RObert loVes MOmmy
 
Posts: 3432
Joined: Fri Dec 08, 2006 10:12 am

Post » Mon Nov 19, 2012 10:41 am

Int iFormID = (GetBaseObject() As ActorBase).GetFormID()
That'll return the hex FormID of the ActorBase converted to decimal.
User avatar
Gavin Roberts
 
Posts: 3335
Joined: Fri Jun 08, 2007 8:14 pm

Post » Mon Nov 19, 2012 12:33 pm

Hello again justin
And thank you for replying again.
So I put the script you sent me instead of getid ?
Or how do I do it ?
I want to use the same script for all actors and let the script detect each actor level without
Me calling each actor property by name.
Thx.

User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am

Post » Mon Nov 19, 2012 1:16 am

You could use the above in an ActiveMagicEffect. You could also switch it up a bit and get the info by filling quest aliases and checking them. There is no GetID, but there is http://www.creationkit.com/GetFormID_-_Form.
User avatar
Matt Terry
 
Posts: 3453
Joined: Sun May 13, 2007 10:58 am

Post » Mon Nov 19, 2012 3:30 am

Justin's code will do what you want ... BUT:


The OnHit Event script will have to be added to every Actor in the game, if you want to report on every actor. And you do not want to be doing that!!

So: I think this is only going to work if you Dynamically Attach Scripts to an Actor via a MagicEffect

Warning: This is hard to understand!

http://www.creationkit.com/Dynamically_Attaching_Scripts

Having read it, do you understand what to do?



The other - maybe easier - way to do it would be to use the Story Manger System: http://www.creationkit.com/Bethesda_Tutorial_Story_Manager

This is also difficult to understand and make work the first couple of times you try ... but once you have figured it out it is a very useful system

And the: http://www.creationkit.com/Assault_Actor_Event Event




Those are the only ways I can see how you will get working what you want to get working.
User avatar
Sara Lee
 
Posts: 3448
Joined: Mon Sep 25, 2006 1:40 pm


Return to V - Skyrim