Reference help!

Post » Sat May 28, 2011 6:48 pm

Hello!
I m trying to make a random class generator for a bunch of NPCs i made for my mod.
For example:

When the player walks through a trigger, the game will roll random numbers and get a result of 1 to 4. Accoring to that number the NPC will get a different class.
But i really dont know how i can call the ID of that NPC. I mean how to tell the script to change the class of the first NPC.
I made the script below so far but is not working. My game dont crash but not class change occurs.

Attention: NPC is not in game world that moment. He will spawn to the world later, having the class i have rolled for him.

I m using .GetOwner but i dont think its right.
My NPC ID is "PC01"
Can anyone help me plz?

scriptname NPCClasstrigger

short PC01class
ref NPC01

Begin OnTrigger Player

set PC01class to Rand 1 4

set NPC01 to PC01.GetOwner

if PC01Class == 1
NPC01.SetClass Crusader
message "Crusader"
elseif PC01Class == 2
NPC01.SetClass Warrior
message "Warrior"
elseif PC01Class == 3
NPC01.SetClass Warlock
message "Warlock"
elseif PC01Class ==4
NPC01.SetClass Thief
message "Thief"
endif

End

User avatar
chloe hampson
 
Posts: 3493
Joined: Sun Jun 25, 2006 12:15 pm

Post » Sat May 28, 2011 10:26 am

If PC01 is the editor id name of the reference of your NPC, you should be able to call your functions directly on that. No need for NPC01 at all. It's definitely not GetOwner, at any rate.
User avatar
Spencey!
 
Posts: 3221
Joined: Thu Aug 17, 2006 12:18 am


Return to IV - Oblivion