Cthorthu Posted February 28, 2023 Share Posted February 28, 2023 Hi! I need a script to make a NPC teammate with player when spawning. I hope someone with scripting knowledge can help me :) NPC is not unique, it may spawn several times. I'm going to add this script to the NPC. I have this (incomplete) script: ScriptName CustomNPCTeammate extends Actor{This script makes the NPC teammate with player}Event OnLoad() xxxxxxx.SetPlayerTeammate()endEventI wonder if there a reference that calls the actor itself (to replace "xxxxxxx") (Along endless searches in google and bing, I have seen "akActor" several times, and I think this may be what I need, but can't find the meaning of "akActor" and if this can be used in this context, I'm probably completely wrong).Not sure if I need to create this structure (taking in mind it is not a unique NPC):ScriptName CustomNPCTeammate extends Actor{This script makes the NPC teammate with player}ObjectReference property CtCustomNPC autoEvent OnLoad() CtCustomNPC.SetPlayerTeammate()endEventAny help will be appreciated! Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 28, 2023 Share Posted February 28, 2023 If you will be adding the script to the custom NPC itself, you can use the special Self variable to indicate the actor holding the script. ScriptName CustomNPCTeammate extends Actor {This script makes the NPC teammate with player} Event OnLoad() Self.SetPlayerTeammate() endEvent If for some reason that does not want to compile, cast Self into actor first. (Self as Actor).SetPlayerTeammate() Link to comment Share on other sites More sharing options...
Cthorthu Posted February 28, 2023 Author Share Posted February 28, 2023 Thank you very much Ishara! :) I was going crazy looking fot it Link to comment Share on other sites More sharing options...
scorrp10 Posted February 28, 2023 Share Posted February 28, 2023 Or just Event OnLoad() SetPlayerTeammate() EndEventSince your script extends Actor class, it natively has access to its methods. akActor is typical argument name for functions that get an Actor as parameter. I.e. if you attach a script to a piece of armor, (Script will extend ObjectReference) so that any NPC equipping it becomes player's teammate:you can define an event handler: Event OnEquipped(Actor akActor) akActor.SetPlayerTeammate() EndEvent Link to comment Share on other sites More sharing options...
Cthorthu Posted February 28, 2023 Author Share Posted February 28, 2023 Very interesting. I'm learning and this is very useful Thank you!! Link to comment Share on other sites More sharing options...
Recommended Posts