Site Bot Posted July 16, 2011 Share Posted July 16, 2011 Article link: A GECK Scripting Tutorial Part 1 Programming Fallout 3 is really easy. The language is very simple and is made up of about 900 functions (Which isn't very many compared to real programming languages like C++). I'm going to use an snippet of code that I've written for a mod that I'm making. This script was part of an achievement script in the mod. It counts the number of headshots that have been made with the Sniper Rifle.The Script: scn ExampleArticleScriptOne short NumberOfHeadshotsref PlayerTargetREF if Player.GetEquipped WeapSniperRifle == 1 if Player.GetCombatTarget != 0 set PlayerTargetREF to Player.GetCombatTarget if PlayerTargetREF.GetKillingBlowLimb == 1 if NumberOfHeadshots < 1 set NumberOfHeadshots to 1 else set NumberOfHeadshots to NumberOfHeadshots + 1 endif else if PlayerTargetREF.GetKillingBlowLimb == 2 if NumberOfHeadshots < 1 set NumberOfHeadshots to 1 else set NumberOfHeadshots to NumberOfHeadshots + 1 endif else if PlayerTargetREF.GetKillingBlowLimb == 13 if NumberOfHeadshots < 1 set NumberOfHeadshots to 1 else set NumberOfHeadshots to NumberOfHeadshots + 1 endif endif endif endif endifendif Now to explain what each part of this script is doing. The first part of the script "scn ExampleArticleScriptOne" defines what the script will be saved as. "scn" just means script name. The next part is "short NumberOfHeadshots" & "ref PlayerTargetREF", the first part "short NumberOfHeadshots", short basically means a number that can be positive or negative but cannot be a decimal or a fraction, if you want the number to be a decimal then you would use "float <variable" and replace the <variable> with the name of the variable you want. Now the "ref PlayerTargetREF", "ref" can be used to refer to an object (ObjectID), and character/npc (ActorID), or any other persistent reference. Now to the main script, the line "if Player.GetEquipped WeapSniperRifle == 1" is kinda self-explanatory, in English it means; if the player has the weapon WeapSniperRifle (Sniper Rifle) equipped then run the script inside the if statement. When a function returns 1 it means that is true, or in this case, if Player.GetEquipped WeapSniperRifle returns 1 or == 1 then the player is using a sniper rifle. Next is the if statement that checks to see if the player is targeting anybody, if the player is targeting somebody then the function Player.GetCombetTarget will not return 0 so the script inside this if statement will run. This part is a little bit more complex, first we have to find out who the player is targeting then when they die we have to find out where the shot that killed them landed. First off is finding out who the player is targeting. We take the "ref" variable that we made earlier and we assign it an actor reference. The script "set PlayerTargetREF to Player.GetCombatTarget" will set "PlayerTargetREF" to the ActorID of whatever actor is returned from the function "Player.GetCombatTarget". After "PlayerTargetREF" has been assigned an actor, we can use it in the function "PlayerTargetREF.GetKillingBlowLimb" (http://geck.bethsoft.com/index.php/GetKillingBlowLimb For more information). The next if statements just ask what limb killed the player's target, and if that limb is 1, 2, or 13 then the script will add 1 to the headshot count. Those three numbers represent all of the limbs that are considered a headshot; where 1 and 2 are both the head and 13 is the brain. Just A Note: An experienced "modder" might have noticed that you could instead use "begin OnCombatStart" instead of using the if statement to check if the player is targeting anybody. That's all for part 1, I hope that this has helped at least one person. Please comment and help me improve my articles. I will try to write part 2 at some point. Cheers, Link to comment Share on other sites More sharing options...
u2020bullet Posted August 7, 2011 Share Posted August 7, 2011 when is part 2 coming out? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now