NineCoronas2021 wrote...
Why exactly are these lines repeated:
int HasDoneThisBefore( object oPC );
int HasDoneThisBefore( object oPC )
it appears as if the second one is superflous?
Also, your answer to my third question went completely over my head lol
As Baaleos Stated this 'int HasDoneThisBefore( object oPC );' is a proto tyoe of the function.
I would call it a forward declairation. It basicly give the compiler all the information needed to allow a code block to use the function, without knowing what the function does or how it does it.
The second one woud define what the function does and how it does it.
since you do nto have the sini colon at the end of the statment, the compiler will expect a code block that defines what the function does.
int HasDoneThisBefore( object oPC )
{
// code block for that the function does.
}
superflous? Yep without the code block it would be.
Lets see the answer to your third question about the return. In order to understand the return you first have to understand functions. Functions are nothing more then a Lable given to a block of code. Kind of like variables are nothing more then a Lable given to a memory location. Just like the varaiable have a data type ( int, float,string...) so does the function. This data type that is given to the function is concidered its Return Value. This Return Value is calculated by the Code Block of the function and returned to the calling code. The way it is the code block tells it what to Return is by the 'return' reserved word. in our function declairation we have:
int HasDoneThisBefore( object oPC )
{
int x;
// Code doing something with oPC
return x;
}
lookint at it one piece at a time we have ;
int : This is the data type that the code block will return, It is also the data type that you can use the function as. anyplace you can legally use an int you will be able to use this function.
HasDoneThisBefore : The Lable that we are giving to the code block that will evulate out to our data type.
( ): The parentheses following the Lable denote this to the compiler as a function as opposed to just being a Varaible.
(object oPC) : If we have a varaiable defined within the parentheses, thies varaiables are created on the stack before the function's code block is ran. they will also be initialized with the data given when the function is used.
{ } : Is where the code block that defines what the function does goes.
return x : is a keword in the functions code that tells the compiler that this is where the function ends and the value to return. If there is nothing behind the return; That means that the function was a void data type and has no return value.
So to answer your question
return GetLocalInt( oPC, GetTag( OBJECT_SELF ));
The Return is at the begining because we are wanting to return the integer that GetLocalInt( oPC, GetTag( OBJECT_SELF )) is evaulating to.