| NWN2 Scripting. |
Simulation Training. Introduction Home First Program Seeing Results Variables and Data Types Comments Functions Data Conversion Random Numbers Concatenation Arithmetic Operators Compound Assignments One More or Less Precedence Relational Operators The Open Branch The Closed Branch Logical AND Logical OR Compound Statements ELSE If Switch Case The ? Operator The for Loop The while Loop The do while Loop Introduction to Functions Passing Values Passing Multiple Values Multiple Functions Simplifying Functions TRUE/fALSE Conditions Return Values Setting Global Variables Getting Global Variables Setting Local Variables Getting Local Variables WayPoints Introduction Static Waypoint Sets Dynamic Waypoint Sets Dynamic WP Cycles Input Output |
Logical ORAnother logical condition used by C++ is the OR condition. Like the AND condition, the OR condition is a powerful addition to constructing gaming AI.
The Logical Or The logical OR operation is expressed as: (expression1) || (expression2) The above expressiosn will be evaluated TRUE if expression1 or expression2 or both are TRUE, otherwise the operation will be evaluated as FALSE. Another way of looking at this is the only tiem an OR operation is evaluated to FALSE is when both conditions are FALSE. Note that two vertical bars are used to indicated the OR relationship. The vertical bar is found on the keyboard over the ENTER key and is shared with the backslash \. In the NWN2 editor, TRUE is a 1 and FALSE is a 0. Observe that the double && is used to represent the OR operation:
Logical || Example An example of hte logical || operatoin is illustrated in the following program.
The Above Program compiles without errors. Here are some facts aout the program:
Where do we go from here? The next section introduces more decision-making techniques.
|
|