Jump to content

Photo

Companion Script- why 'b' before quest variables?

quest variable short companion script

  • Please log in to reply
7 replies to this topic

#1
templeofninpo

templeofninpo

    Fan

  • Supporter
  • PipPipPip
  • 415 posts

Like many people, my first mod was a companion mod made with gratious help from oGrayFox's Youtube tutorials.

 

He says putting the 'b' in front of the variables in the quest script is important but he doesn't elaborate.

RE:

 

short bLiamHireable ; Liam being one of my new companions
short bLiamDoOnce

Begin GameMode
    if (bLiamDoOnce != 1)
        Set bLiamHireable to 1
        Set bLiamDoOnce to 1
    EndIf
End

 

I left a message on his youtube channel just now... though I don't know if he is still in the picture or not.

 

Side Note: does anyone know if there is a trick to accompany packages?


Edited by templeofninpo, 04 March 2015 - 03:48 AM.


#2
unoctium

unoctium

    Fan

  • Supporter
  • PipPipPip
  • 439 posts

It's not important in itself. It's just a traditional way for the modder to distinguish the different variables of a quest script and an object script. In truth, a variable can be anything you want it to be. It's just a term to identify a variable state(such as 0, 1, etc) that will be used by the game.

 

And what do you mean when you ask if there is a trick to accompany packages?



#3
templeofninpo

templeofninpo

    Fan

  • Supporter
  • PipPipPip
  • 415 posts

can't seem to make one work... though it was given to an NPC companion pre-hiring, so I was thinking it maybe has something to do with that.

and cheers.



#4
madmongo

madmongo

    Faithful poster

  • Members
  • PipPipPipPip
  • 1,109 posts

I have made dozens of companions and I have never once put a b in front of any variables. It can't be too important. Really, it's just computer programming shorthand to indicate that you are using it as a binary variable, i.e. you only care if it is 1 or 0 (even though technically it's created as a short integer).

 

If you want to make a companion, at the bare minimum you need a companion script. You don't need a quest script.

 

A very simple script would be something like this:

 

scn MyCompanionScript

 

short DoOnce

short Following

short Waiting

 

Begin GameMode

if(DoOnce!=1)

  Set Waiting to 1

  Set Following to 0

  Set DoOnce to 1

  Endif

End

 

Once you have created the script, when you create your NPC, select this script (under the name and Editor ID on the left).

 

Now put your NPC somewhere, and once he/she/it is there, double click on them and give them a reference name (i.e. MyCompanionREF).

 

Now create two packages, one called MyCompanionFollow and the other called MyCompanionWait.

The MyCompanionFollow is a package type of follow, select the player for the reference to follow, give it a follow distance of say 200 or so, and under conditions add a condition to check the script variable for MyCompanionREF and select the variable Following == 1.

 

For the wait, you can use either a guard or a sandbox package. With the sandbox the NPC will move around and do stuff more. Set the sandbox location to the current location, set the distance to something like 500. Again make a condition, and this time check against the script variable of Waiting (again check == with a value of 1).

 

Open up your NPC and add those two packages to their package list.

 

Now create a quest. You'll need to make 4 topics for it. You'll need to add in a GREETING, then make 3 custom topics called something like MyCompanionFollowOption, MyCompanionWaitOption, and MyCompanionNevermind. These 3 will be top level and all will have the goodbye flag set. All of them will CheckID against your companion under the conditions. The nevermind doesn't do anything except allows you to exit without changing anything. The follow option has a simple 2 line script that sets Follow to 1 and sets Wait to 0, followed by a MyCompanionREF.evp (to re-evaluate its AI package). The wait option also has a simple 3 line script that sets follow to 0, wait to 1, and again the evp.

 

And that's it. That's all it takes to make a companion.

 

The companion wheel will not work and you can't access the companion's inventory, but that is a bare minimum companion.

 

If you want a working companion wheel, there's a lot more you have to do, and you have to use specific variables and dialog options instead of just making your own like the above. The above is just to show you what is the absolute minimum required to make a companion work. Also, if you want there to be a quest for your companion to be hired, or maybe you want your companion to have a quest after you've hired them, that can be done by adding a quest script and another quest or whatever you want. You can get much, much fancier.

 

If you want a working companion wheel, invetory access, etc. this tutorial goes step by step through the process, and even has a couple of extras like a "relax" option, which I generally use also.

 

http://www.nexusmods...as/mods/45278/?

 

If you go through the tutorial, you'll see that there are a few more steps other than the ones I listed above, but it's not much more complicated than that.

 

Note - the above is all from memory and I'm not at my gaming computer so I may have whiffed a couple of things - if you really want to make a companion use the tutorial I linked to. I just wanted to show you what the absolute mininum was for a companion so you'll understand how the companion system works. You don't really want to make a companion that way since it won't have a working companion wheel or inventory access.


Edited by madmongo, 04 March 2015 - 07:03 PM.


#5
templeofninpo

templeofninpo

    Fan

  • Supporter
  • PipPipPip
  • 415 posts

I appreciate the instruction though I already have multiple companions made from using 0GrayFox's youtube tutorials. companion wheels and all.... the 'b' isn't important for the companion wheel is it?



#6
unoctium

unoctium

    Fan

  • Supporter
  • PipPipPip
  • 439 posts

The Companion Wheel is in the New Vegas sourcecode, and is associated with the SetPlayerTeammate command for your reference. For example, within your script, if you write the instruction "YourCompanionREF."SetPlayerTeammate, it will not only cause the actor to simulate the combat behaviour of the player, fight the enemies that you attack and attack you and so on, but it will also call upon the Companion Wheel upon activating that reference, (when you talk to them.) Note however, that this will not make the companion follow you. That can only be done separately through an A.I. package, that will usually relate to the variables in your scripts. 

 

However, the Companion Wheel is useless outside the talking command and the way to allow the commands on the companion wheel to work will be to add your companion to the FollowerTopics, which, unlike the 'b' preface for your variables, is important, as unlike Fallout 3, these topics now have source code related to the commands on the Companion Wheel. For example, adding your companion to FollowerSwitchAggressive topic will allow the Aggressive/Passive option to be accessible to the companion wheel, which otherwise, would be useless.


Edited by unoctium, 04 March 2015 - 09:55 PM.


#7
templeofninpo

templeofninpo

    Fan

  • Supporter
  • PipPipPip
  • 415 posts
Cool. I'm thinking idle markers can glitch other things ex. Npc won't start combat if in the middle of one.

The issue was raised when other npcs got glitchy when I fired a companion... still working on it.

#8
RoyBatterian

RoyBatterian

    Retired

  • Premium Member
  • 9,732 posts

Having a b before the variable name is just a way to distinguish it from other variables, the b stands for boolean. It's not necessary, it's just there for readability.

 

There is one variable which MUST be named exactly in your script, and that is the Waiting variable. If it's not then the game will teleport the companion to you when you change cells.

 

If you want the wheel to work, you have to use the Followers topics, they are hard coded.







Also tagged with one or more of these keywords: quest, variable, short, companion, script

Page loaded in: 1.034 seconds