tnade711 Posted June 20, 2014 Share Posted June 20, 2014 I can't quite rap my head around it for some reason. I've been told its "A Reference type variable stores a game object, of any type (item, NPC, door, container, a piece of wall, etc.)." Now this may sound obvious at first but I've read over coding containing reference values i.e. ref rcontainer, set rcontainer to getcontainer. All it looks like in that line of code is that it renamed the command getcontainer. Could someone please explain a bit more indepth the reference function and perhaps an example of it if possible. Link to comment Share on other sites More sharing options...
vforvic Posted June 21, 2014 Share Posted June 21, 2014 This took me a while to understand and at times I'm still not sure I have it 100%, but I'll give it a shot. I think sometimes confusion comes from a Reference compared to a Reference Variable. A Reference (Reference Editor ID) is a unique name you give a GECK object (Base Object). This is done so that when you put for example a vanilla 10mm pistol (Base Object name Weap10mmPistol) in the game you can identify in a script that one specific 10mm pistol if needed. For example Colonel Autumn, which has a Base Object name of "ColonelAutumn" is in the game world twice with 2 different Reference names. This way the game can manipulate each of these References of the same Object separately. I think of a Reference Variable as a dynamic placeholder in a script. It is used in scripts to make reference to something that is not named specifically. One thing to keep in mind is that they can be set to almost anything including set to nothing at all which is 0. The name used for a Reference Variable can be almost anything as long as you declare it (give it a name) at the start of the script. So I can name (declare) a Reference Variable "MyLightRef" or I can name it "yadayadayada" and it does not matter. The only thing is you should normally not start a Ref Name with a number, some special characters or some names which are reserved. As an example. I make a new Raider in the GECK called EscapingRaider. I put 50 of these raiders at the end of a long large room with the Player at the other end by a door. The Player has to kill 1 specific Raider before it reaches the door, but the Player does not know which one and there is no time to kill them all. In this case I give 1 of the Raiders I have put in the room a Reference (Reference Editor ID) name of EscapingRaiderREF. I then give them all a Travel Package to run to the door. Right before the door I put a Trigger Box with the following Script attached. If this specific Raider reaches the door then the mission fails. scn EscapingRaiderTrigger ;This script is attached to a Trigger Box (Primitive) in the game world ;Anything that move into the box activates the script. ref actionRef ;Here is where I tell the script that actionRef is a Reference Variable (ref) ;I could have said "ref action" or "ref stuff" and it would be ok. ;You can name this almost anything as long as it makes sense to you. Begin onTriggerEnter ;When something enters the Trigger Box this part of the script runs set actionRef to getActionRef ;Get the Reference Name of whatever entered the box ;Whenever the script sees actionRef in the script it ;will substitute this Reference Name in its place. if actionRef == EscapingRaiderREF ;If the Reference Name of the Object that walked ;into the Trigger is EscapingRaiderREF then the next ;line will also run. showmessage MissionFailed ;Pops up a message saying the mission has been failed endif EndGranted this might not normally be how I would do this specific event, but it could be done this way. I could also use a Reference Variable in conjunction with a FormList I have populated with NPC's which placed a Nuclear Explosion at the Players location if an NPC in the FormList reached a particular location. scn NukeTrigger ref obj ;Once again I could have named this almost anything. Begin onTriggerEnter ;Runs when something enters the Trigger Box. set obj to GetActionRef ;Sets the Ref Variable obj to what ever entered the Trigger if obj.isInList NukeList == 1 ;If whatever entered the Trigger is in the FormList NukeList then run below. showmessage NukeSuccess Player.placeatme smallnukeexplosion ;Player has a bad day. endif End Finally about your specific comment “All it looks like in that line of code is that it renamed the command getcontainer.” It is actually kind of the opposite. This code would be used somewhere you wanted to find out what container, and remember an NPC or the Player can be considered a container, an object is located. I have seen this mostly used for custom weapons where a script would be attached to the weapon for a custom reload animation. The following script would be attached to that specific weapon. Scn FancyRifleReloadAnimationScript ref rContainer begin gamemode ;The following line says to set the Variable rContainer to whatever Container has the weapon. ;Let’s assume a Talon NPC Talon1GunAM has the weapon and is firing it. set rContainer to GetContainer ;essentially says to set rContainer to Talon1GunAM ;From this point anytime the script reads rContainer it will really use Talon1GunAM. ;Which means the following line really says “if TalonGunAM is reloading do the following” if rContainer.GetAnimAction == 9 ;The following 3 lines show the custom reload stuff. if rContainer.GetEquipped FancyRifle == 1 PlaySound FancyReload rContainer.CastImmediateOnSelf FancyRifleReloadActorEffect endif endif end See, clear as mud. :smile: Link to comment Share on other sites More sharing options...
tnade711 Posted June 23, 2014 Author Share Posted June 23, 2014 (edited) This took me a while to understand and at times I'm still not sure I have it 100%, but I'll give it a shot. I think sometimes confusion comes from a Reference compared to a Reference Variable. A Reference (Reference Editor ID) is a unique name you give a GECK object (Base Object). This is done so that when you put for example a vanilla 10mm pistol (Base Object name Weap10mmPistol) in the game you can identify in a script that one specific 10mm pistol if needed. For example Colonel Autumn, which has a Base Object name of "ColonelAutumn" is in the game world twice with 2 different Reference names. This way the game can manipulate each of these References of the same Object separately. I think of a Reference Variable as a dynamic placeholder in a script. It is used in scripts to make reference to something that is not named specifically. One thing to keep in mind is that they can be set to almost anything including set to nothing at all which is 0. The name used for a Reference Variable can be almost anything as long as you declare it (give it a name) at the start of the script. So I can name (declare) a Reference Variable "MyLightRef" or I can name it "yadayadayada" and it does not matter. The only thing is you should normally not start a Ref Name with a number, some special characters or some names which are reserved. As an example. I make a new Raider in the GECK called EscapingRaider. I put 50 of these raiders at the end of a long large room with the Player at the other end by a door. The Player has to kill 1 specific Raider before it reaches the door, but the Player does not know which one and there is no time to kill them all. In this case I give 1 of the Raiders I have put in the room a Reference (Reference Editor ID) name of EscapingRaiderREF. I then give them all a Travel Package to run to the door. Right before the door I put a Trigger Box with the following Script attached. If this specific Raider reaches the door then the mission fails. scn EscapingRaiderTrigger ;This script is attached to a Trigger Box (Primitive) in the game world ;Anything that move into the box activates the script. ref actionRef ;Here is where I tell the script that actionRef is a Reference Variable (ref) ;I could have said "ref action" or "ref stuff" and it would be ok. ;You can name this almost anything as long as it makes sense to you. Begin onTriggerEnter ;When something enters the Trigger Box this part of the script runs set actionRef to getActionRef ;Get the Reference Name of whatever entered the box ;Whenever the script sees actionRef in the script it ;will substitute this Reference Name in its place. if actionRef == EscapingRaiderREF ;If the Reference Name of the Object that walked ;into the Trigger is EscapingRaiderREF then the next ;line will also run. showmessage MissionFailed ;Pops up a message saying the mission has been failed endif EndGranted this might not normally be how I would do this specific event, but it could be done this way. I could also use a Reference Variable in conjunction with a FormList I have populated with NPC's which placed a Nuclear Explosion at the Players location if an NPC in the FormList reached a particular location. scn NukeTrigger ref obj ;Once again I could have named this almost anything. Begin onTriggerEnter ;Runs when something enters the Trigger Box. set obj to GetActionRef ;Sets the Ref Variable obj to what ever entered the Trigger if obj.isInList NukeList == 1 ;If whatever entered the Trigger is in the FormList NukeList then run below. showmessage NukeSuccess Player.placeatme smallnukeexplosion ;Player has a bad day. endif End Finally about your specific comment “All it looks like in that line of code is that it renamed the command getcontainer.” It is actually kind of the opposite. This code would be used somewhere you wanted to find out what container, and remember an NPC or the Player can be considered a container, an object is located. I have seen this mostly used for custom weapons where a script would be attached to the weapon for a custom reload animation. The following script would be attached to that specific weapon. Scn FancyRifleReloadAnimationScript ref rContainer begin gamemode ;The following line says to set the Variable rContainer to whatever Container has the weapon. ;Let’s assume a Talon NPC Talon1GunAM has the weapon and is firing it. set rContainer to GetContainer ;essentially says to set rContainer to Talon1GunAM ;From this point anytime the script reads rContainer it will really use Talon1GunAM. ;Which means the following line really says “if TalonGunAM is reloading do the following” if rContainer.GetAnimAction == 9 ;The following 3 lines show the custom reload stuff. if rContainer.GetEquipped FancyRifle == 1 PlaySound FancyReload rContainer.CastImmediateOnSelf FancyRifleReloadActorEffect endif endif end See, clear as mud. :smile:Thank you, but maybe i'm stupid cause my mind is still having trouble wrappig around it. I hope you don't mind if I ask a few questions! 1. why do you have to set action ref to getactionref. Couldn't you just leave it as if getactionref = escaping raider?2. Also could you explain in specifics what you mean by ";The following line says to set the Variable rContainer to whatever Container has the weapon." Sorry I'm a noob :3 Like what do you mean set the variable rcontainer to whatever container has the weapon. Why would you want to set rconatiner to say the player container? EDIT: I understand now. Sorry I'm tried and my mind is off right now. I read over it a couple times and I understand now. Say I spawn two bandits named MISSIONESSENTIALALTERNATE BANDIT. Both same npcs both share the same ref id's if I kill one I get the good ending kill the other I get a bad end. since both share the same REF id I use the reference to give the one with the good ending the place holder reference for the good ending. it sort of gives a specific generic npc like "bandit" a second name. Am I getting this right? Also I do have a few other questions but can I say add you on steam cause I'd rather not ask them out here in the open forum. Edited June 23, 2014 by tnade711 Link to comment Share on other sites More sharing options...
vforvic Posted June 24, 2014 Share Posted June 24, 2014 Your very close. You just have the names a bit off. The Base Object ID is what you name an Object when you make it in the GECK. Whether your making a NPC, a Weapon, a Door, a Rock or anything, it has a Base Object ID name. So using your example.In the GECK you make a new Bandit. In the first line you see ID which is the Base Object ID and you put MissionEssential. The second line you see Name which is the name you see in the game, Lucas Simms, Allistair Tenpenny, Amata, etc, and you put BANDIT. Now every NPC that you just made that you drag or spawn into the world will be named BANDIT. In the GECK you drag 2 of those Bandits into the middle of Megaton. You double-click on each of those 2 Bandits and you see identical boxes with the Reference Editor ID empty on each. Here is where you would put GoodEndingREF and BadEndingREF. Now you could use those 2 Ref ID's in scripts to make your good or bad ending occur. There is actually more than 1 way to do this type of thing. You could have a Quest Script that monitored when one of those Refs died or you could use a Trigger Box or all kinds of Functions depending on exactly what type of thing you were scripting.Keep in mind that spawning objects in using the Console is not the same as placing them in the GECK because you can't spawn in things with Ref ID's. Let me answer your questions anyway.On your question 1. Yes you are right you could and probably would do this, but for the sake of explanation I did it to show how Refs work. You'll find there is always more than 1 good way to make things work in the GECK.On your question 2. rContainer, or whatever you wanted to call it, is a placeholder for a unknown value in the script. The value is filled or set by whatever Ref enters the Trigger Box. Remember that a container can be almost anything that can hold the item. So for example you could have a Quest Script that runs all the time checking to see if a certain weapon goes into a particular container and if it does then a message pops up or the earth shakes or whatever.On your question 3. For the same reason you would want to see if it was in any other "container." So you could make something happen or not happen. Link to comment Share on other sites More sharing options...
tnade711 Posted June 25, 2014 Author Share Posted June 25, 2014 Your very close. You just have the names a bit off. The Base Object ID is what you name an Object when you make it in the GECK. Whether your making a NPC, a Weapon, a Door, a Rock or anything, it has a Base Object ID name. So using your example.In the GECK you make a new Bandit. In the first line you see ID which is the Base Object ID and you put MissionEssential. The second line you see Name which is the name you see in the game, Lucas Simms, Allistair Tenpenny, Amata, etc, and you put BANDIT. Now every NPC that you just made that you drag or spawn into the world will be named BANDIT. In the GECK you drag 2 of those Bandits into the middle of Megaton. You double-click on each of those 2 Bandits and you see identical boxes with the Reference Editor ID empty on each. Here is where you would put GoodEndingREF and BadEndingREF. Now you could use those 2 Ref ID's in scripts to make your good or bad ending occur. There is actually more than 1 way to do this type of thing. You could have a Quest Script that monitored when one of those Refs died or you could use a Trigger Box or all kinds of Functions depending on exactly what type of thing you were scripting.Keep in mind that spawning objects in using the Console is not the same as placing them in the GECK because you can't spawn in things with Ref ID's. Let me answer your questions anyway.On your question 1. Yes you are right you could and probably would do this, but for the sake of explanation I did it to show how Refs work. You'll find there is always more than 1 good way to make things work in the GECK.On your question 2. rContainer, or whatever you wanted to call it, is a placeholder for a unknown value in the script. The value is filled or set by whatever Ref enters the Trigger Box. Remember that a container can be almost anything that can hold the item. So for example you could have a Quest Script that runs all the time checking to see if a certain weapon goes into a particular container and if it does then a message pops up or the earth shakes or whatever.On your question 3. For the same reason you would want to see if it was in any other "container." So you could make something happen or not happen.Okay its becoming more clear. But for the sake of privacy do you have a steam I could private chat you on? Some of the questions involve a mod I"m working on and for the sake of paranoia I don't want to ask them out in the open. Don't worry its just a couple of questions. But if you could do this that would be nice. Link to comment Share on other sites More sharing options...
Deleted1205226User Posted June 27, 2014 Share Posted June 27, 2014 Your explanation, vforvic, is one of the best I could read. It deserves to be stickied or integrated in a tutorial.Thank you. :) Link to comment Share on other sites More sharing options...
Recommended Posts