wcho035 Posted March 30, 2009 Share Posted March 30, 2009 hi, I am trying to use an NPC I have created to use some fuctions for a mod. Let say the NPC is an actor, you can use the REF to reference it. I have tried numerous time but the compiler would not recognise or compile the new Actor with REFattact to it, but if there is an existing actor, that would work. E.g Let say "1temp" is an NPC I have created, GECK would not recognised 1tempREF.disable but if there is an existing NPC, let say Charon CharonREF.disable it does recognised. Is there some kind of table that I have to include the new NPC name I have created so this REF thing would work? Or the name "1temp" has to be made a variable in a script so that this would compile or GECK would recognise it? Thanks. Link to comment Share on other sites More sharing options...
TGBlank Posted March 30, 2009 Share Posted March 30, 2009 You want a reference to an instance, not to a base type. In other words, one in the render window, not one in the object palette. You want to use the reference name of THAT instance. Link to comment Share on other sites More sharing options...
Cipscis Posted March 30, 2009 Share Posted March 30, 2009 You can't just append the EditorID of your Form with "REF" in order to specify a reference to your Form. Instead, you'll need to specify a reference as being persistent, and give it an EditorRefID of its own, and then refer to it by that EditorRefID. You can do all of that in the Reference window - just double-click on your reference in the Render window to open it. The reason why "CharonREF" refers to a reference to the "Charon" Form is that there is a persistent reference to this Form that has the EditorRefID "CharonREF" Cipscis Link to comment Share on other sites More sharing options...
wcho035 Posted March 30, 2009 Author Share Posted March 30, 2009 Okay I get the picture, so I need to place the object or actor on a render world, give it a name on its reference ID then ONLY I can only refer to its name. Unfortuantely I am not sure that would work with actors which are spawn by the "Placeatme" command. Is there away to remove spawn actors without using the disable and markfordelete? Or, is there a way I can refer the spawn actor to the disable and markfordelete fuctions so that the compiler will compile? Link to comment Share on other sites More sharing options...
TGBlank Posted March 30, 2009 Share Posted March 30, 2009 afaik, the function placeatme returns the reference to the object.so...ref actorr set actorr to placeatme actorbaseid now actorr is a reference to the guy/gal/supermutant/explosion/teddybear you just spawned Link to comment Share on other sites More sharing options...
Cipscis Posted March 31, 2009 Share Posted March 31, 2009 Yep, that's absolutely correct. FormIDs (including RefIDs) that are assigned during runtime can only be referred to by storing their FormID in a "ref" variable, and RefIDs assigned during the use of PlaceAtMe are returned so that you can store them in a "ref" variable for later use. Cipscis Link to comment Share on other sites More sharing options...
wcho035 Posted March 31, 2009 Author Share Posted March 31, 2009 Hey guys thanks for the info and tips so far at helping me getting my coding problems sorted out. Much appreciated. I have done a few trial and error with the suggestions TGBlank and Cipscis have given. It was a yes and no result. Okay. Here was what happen. I have an NPC or actor, ID 1TrooperTemplateName Warrior Trooper I have a hirer which I engage dialogue with and then I want to hire the NPC.So I code it as. player.placeatme 1TrooperTemplate 1player.removeitem f 200 And if I am to "fired" the actor from the party. He is to be killed. ******************************************************************* Now, with the new suggestions. I put short actortemp Into the Quest script which is link to the quest-dialogue for both the hirer and the NPC which I hired. For the hirer's topic dialogue script space I mod the code to player.placeatme 1TrooperTemplate 1set scriptname.actortemp to player.placeatme 1TrooperTemplateplayer.removeitem f 200 Then at the NPC dialogue, I added "You are fired" topic and I coded the script at the NPC's "You are fired" topic dialogue script space as ref tempvarset tempvar to scriptname.actortemptempvar.disabletempvar.delete When I start up the game, instead of one, two Warrior Trooper show up and when I fired one, one of the NPC disappeared. And then at the second one, it crashes. So yes, I found the error is I have an extra player.placeatme 1TrooperTemplate 1 line, so I got rid of the line, then it is back to square one. Now, I have a few ideas at where to proceed, one is to write a script and attach to the NPC. Like Script ref actortempshort hire Begin Gamemode If hire = 1 set actortemp to player.placeatme 1TrooperTemplate or If hire = 0 actortemp.disableactortemp.markfordelete END That is very short blueprint of that the script attach to the NPC may look like, but I want to avoid it if I can, especially if I can code things at the topic dialogue script space in a few lines. So it is cleaner and simpler. I am just a basic coder not a talented one at that.I appreciate if someone can show me the right approach with the suggestion provided, or help me with the right coding to give me a goot start at cracking the problem. I wish I have a lot of time at troubleshooting and try every possible way, I just have not a lot of time at chasing every leads. Link to comment Share on other sites More sharing options...
TGBlank Posted March 31, 2009 Share Posted March 31, 2009 short actortemp player.placeatme 1TrooperTemplate 1set scriptname.actortemp to player.placeatme 1TrooperTemplateplayer.removeitem f 200 actortemp is a short, you cant store a ref in a short. or at least shouldn't. ref tempvarset tempvar to scriptname.actortemptempvar.disabletempvar.deleteYou can't access values from scriptname, Instead, create a quest, add a script to the quest that contains the variables, and access it as questname.variable. Script ref actortempshort hire Begin Gamemode If hire = 1 set actortemp to player.placeatme 1TrooperTemplate or If hire = 0 actortemp.disableactortemp.markfordelete ENDThis will never work if you glue the script to the actor. It wont run until an instance of the trooper spawns.If you spawn it in another way, hire, a local variable, will start at 0. So instantly after spawning it will be disabled and deleted. Link to comment Share on other sites More sharing options...
wcho035 Posted March 31, 2009 Author Share Posted March 31, 2009 TGBlank again thanks for the helpful suggestion. So here is what I had done. I have two quest. One for hiring and one for the trooper dialogue's There are two different Quest, with the same Questscript glue them both together. In the quest script I used as per suggestion given, I had added the variable *************************ref fireactor************************* In the Hiring quest, I have the following lines. *************************set Questscript.fireactor to player.placeatme 1TrooperTemplate 1************************* In the Trooper dialogue quest I have the following line. *************************ref tempvarset tempvar to Questscript.fireactortempvar.disabletempvar.delete************************* The problem still the same, again, I am saying I am a simple coder, much appreciate what I can do to make it work. Link to comment Share on other sites More sharing options...
TGBlank Posted March 31, 2009 Share Posted March 31, 2009 It is NOT questscript.variablename.It is questNAME.variablename. Using the same script for 2 quests won't make them share values, for example, if you have quest1 and quest2, both with the same script, and the script haves a variable var, then if you do: set quest1.var to 1. the var variable for quest1 will be 1, the var variable for quest2 will be 0, or w/e other value you set it to. What you want is to have only 1 "quest", and to do this when you hire: set quest.var to player.placeatme 1TrooperTemplate 1 and this when you dismiss: quest.var.disablequest.var.delete Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.