Solved Problem about a OR condition

Question that is answered or resolved.

16-bit Fighter

Active member
I wonder why the first code works but not the last ones. I'd like to have a right line code with a simple condition with OR.

Code:
if(vAniID == openborconstant("ANI_RUNATTACK")){

Code:
if(vAniID == openborconstant("ANI_RUNATTACK") || openborconstant ("ANI_FREESPECIAL7")){

Code:
if(vAniID == openborconstant(("ANI_RUNATTACK") || ("ANI_FREESPECIAL7"))){

Code:
if(vAniID == openborconstant("ANI_RUNATTACK") || ("ANI_FREESPECIAL7")){
 
Solution
The problem is that it's missing its variable and declaration along openborconstant for animation name where the OR operation is. It should be like this:

Code:
if(vAniID == openborconstant("ANI_RUNATTACK") || vAniID == openborconstant("ANI_FREESPECIAL7")){
The problem is that it's missing its variable and declaration along openborconstant for animation name where the OR operation is. It should be like this:

Code:
if(vAniID == openborconstant("ANI_RUNATTACK") || vAniID == openborconstant("ANI_FREESPECIAL7")){
 
Solution
No problem. ;) It is what it is for declaring variables to certain functions. Not only do you use openborconstant with declaring animations, but also declaring stuff such as types, subtypes, etc.

Here's a list for openborconstant, in case anyone wants to know about it and how it's used.
openborconstant(name)

  • Get a constant or system value by name.
  • Return the value or just an empty variant if the name is not supported.
Names

  • Types and subtypes for entity. Not all are listed, and not all listed are useful right now.
  • Type
    • "TYPE_NONE"
    • "TYPE_PLAYER"
    • "TYPE_ENEMY"
    • "TYPE_ITEM"
    • "TYPE_OBSTACLE"
    • "TYPE_STEAMER"
    • "TYPE_SHOT"
    • "TYPE_TRAP"
    • "TYPE_TEXTBOX"
    • "TYPE_ENDLEVEL"
    • "TYPE_NPC"
  • Subtype
    • "SUBTYPE_NONE"
    • "SUBTYPE_BIKER"
    • "SUBTYPE_BOOMERANG"
    • "SUBTYPE_NOTGRAB"
    • "SUBTYPE_ARROW"
    • "SUBTYPE_TOUCH"
    • "SUBTYPE_WEAPON"
    • "SUBTYPE_NOSKIP"
    • "SUBTYPE_FLYDIE"
    • "SUBTYPE_BOTH"
    • "SUBTYPE_PROJECTILE"
    • "SUBTYPE_FOLLOW"
    • "SUBTYPE_CHASE"
  • Attack types
    • "ATK_NORMAL"
    • "ATK_NORMAL2"
    • "ATK_NORMAL3"
    • "ATK_NORMAL4"
    • "ATK_BLAST"
    • "ATK_BURN"
    • "ATK_FREEZE"
    • "ATK_SHOCK"
    • "ATK_STEAL"
    • "ATK_NORMAL5"
    • "ATK_NORMAL6"
    • "ATK_NORMAL7"
    • "ATK_NORMAL8"
    • "ATK_NORMAL9"
    • "ATK_NORMAL10"
    • "ATK_ITEM" = attack type when hit by an "itembox" from an item.
    • "ATK_LAND" = is for damage taken when damage_on_landing is applied, or from the engine's default Throw system.
    • "ATK_LIFESPAN = attack type which happens when the LIFESPAN value is reached
    • "ATK_PIT" = its an attack type which happens when you fall on a hole
    • "ATK_TIMEOVER = attack type which happens when you got a time over
  • Level directions.
    • "SCROLL_RIGHT"
    • "SCROLL_DOWN"
    • "SCROLL_LEFT"
    • "SCROLL_UP"
    • "SCROLL_BOTH"
  • Direction of an entity. (4194+)
    • DIRECTION_LEFT
    • DIRECTION_RIGHT
  • Direction adjustment property for binding and attack hits. (4194+)
    • DIRECTION_ADJUST_LEFT
    • DIRECTION_ADJUST_OPPOSITE -- Force target's direction to opposite of owner's.
    • DIRECTION_ADJUST_NONE
    • DIRECTION_ADJUST_RIGHT
    • DIRECTION_ADJUST_SAME -- Force target's direction to same of owner.
  • Animation id.
    • "ANI_IDLE"
    • "ANI_WALK"
    • "ANI_JUMP"
    • "ANI_LAND"
    • "ANI_PAIN"
    • "ANI_FALL"
    • "ANI_RISE"
    • "ANI_ATTACK1"
    • "ANI_ATTACK2"
    • "ANI_ATTACK3"
    • "ANI_ATTACK4"
    • "ANI_UPPER"
    • "ANI_BLOCK"
    • "ANI_JUMPATTACK"
    • "ANI_JUMPATTACK2"
    • "ANI_GET"
    • "ANI_GRAB"
    • "ANI_GRABATTACK"
    • "ANI_GRABATTACK2"
    • "ANI_THROW"
    • "ANI_SPECIAL"
    • "ANI_FREESPECIAL"
    • "ANI_SPAWN"
    • "ANI_DIE"
    • "ANI_PICK"
    • "ANI_FREESPECIAL2"
    • "ANI_JUMPATTACK3"
    • "ANI_FREESPECIAL3"
    • "ANI_UP"
    • "ANI_DOWN"
    • "ANI_SHOCK"
    • "ANI_BURN"
    • "ANI_SHOCKPAIN"
    • "ANI_BURNPAIN"
    • "ANI_GRABBED"
    • "ANI_SPECIAL2"
    • "ANI_RUN"
    • "ANI_RUNATTACK"
    • "ANI_RUNJUMPATTACK"
    • "ANI_ATTACKUP"
    • "ANI_ATTACKDOWN"
    • "ANI_ATTACKFORWARD"
    • "ANI_ATTACKBACKWARD"
    • "ANI_FREESPECIAL4"
    • "ANI_FREESPECIAL5"
    • "ANI_FREESPECIAL6"
    • "ANI_FREESPECIAL7"
    • "ANI_FREESPECIAL8"
    • "ANI_RISEATTACK"
    • "ANI_DODGE"
    • "ANI_ATTACKBOTH"
    • "ANI_GRABFORWARD"
    • "ANI_GRABFORWARD2"
    • "ANI_JUMPFORWARD"
    • "ANI_GRABDOWN"
    • "ANI_GRABDOWN2"
    • "ANI_GRABUP"
    • "ANI_GRABUP2"
    • "ANI_SELECT"
    • "ANI_DUCK"
    • "ANI_FAINT"
    • "ANI_CANT"
    • "ANI_THROWATTACK"
    • "ANI_CHARGEATTACK"
    • "ANI_VAULT"
    • "ANI_JUMPCANT"
    • "ANI_JUMPSPECIAL"
    • "ANI_BURNDIE"
    • "ANI_SHOCKDIE"
    • "ANI_PAIN2"
    • "ANI_PAIN3"
    • "ANI_PAIN4"
    • "ANI_FALL2"
    • "ANI_FALL3"
    • "ANI_FALL4"
    • "ANI_DIE2"
    • "ANI_DIE3"
    • "ANI_DIE4"
    • "ANI_CHARGE"
    • "ANI_BACKWALK"
    • "ANI_SLEEP"
    • "ANI_FOLLOW1"
    • "ANI_FOLLOW2"
    • "ANI_FOLLOW3"
    • "ANI_FOLLOW4"
    • "ANI_PAIN5"
    • "ANI_PAIN6"
    • "ANI_PAIN7"
    • "ANI_PAIN8"
    • "ANI_PAIN9"
    • "ANI_PAIN10"
    • "ANI_FALL5"
    • "ANI_FALL6"
    • "ANI_FALL7"
    • "ANI_FALL8"
    • "ANI_FALL9"
    • "ANI_FALL10"
    • "ANI_DIE5"
    • "ANI_DIE6"
    • "ANI_DIE7"
    • "ANI_DIE8"
    • "ANI_DIE9"
    • "ANI_DIE10"
    • "ANI_TURN"
    • "ANI_RESPAWN"
  • These are infact variable, but unchanged during a level.
    • "PLAYER_MIN_Z"
    • "PLAYER_MAX_Z"
    • "BGHEIGHT"
    • "MAX_WALL_HEIGHT"
  • These are the sound effects defined by the module and loaded at startup.
    • "SAMPLE_GO"
    • "SAMPLE_BEAT"
    • SAMPLE_BLOCK"
    • "SAMPLE_INDIRECT"
    • "SAMPLE_GET"
    • "SAMPLE_GET2"
    • "SAMPLE_FALL"
    • "SAMPLE_JUMP"
    • "SAMPLE_PUNCH"
    • "SAMPLE_1UP"
    • "SAMPLE_TIMEOVER"
    • "SAMPLE_BEEP"
    • "SAMPLE_BEEP2"
    • "SAMPLE_BIKE"
 
Thank you! I thought it was possible to make it shorter.

It is, sort of, but you told the engine to evaluate something that's always true. Here's an example:

C:
if(i)
{
    // i = true.
}

By not asking if i is equal to anything, you're instead just asking if i has a value. It's literally asking "is the variable i anything but NULL or 0"? It's pretty common to do this when we don't know if i has a value or not and we want to act accordingly.

Now in your example, you want to ask two questions: Is vAniID equal to the run attack animation constant, OR is vAniID equal to the Freespecial7 animation constant?

But this code means something else:

C:
if(vAniID == openborconstant("ANI_RUNATTACK") || openborconstant ("ANI_FREESPECIAL7")){

Is vAniID equal to the run attack animation constant, OR is Freespecial7 anything but NULL or 0?

See? You accidently wrote the same kind of check I put in the example above, but you're doing it on openborconstant ("ANI_FREESPECIAL7") which of course always has a value. So it's always going to evaluate true if you ask if it exists, and so by extension, your statement will always be true. That's why you must include the variable you compare it to on both sides of the OR.

C:
if(vAniID == openborconstant("ANI_RUNATTACK") || vAniID == openborconstant("ANI_FREESPECIAL7")){

HTH,
DC
 
Last edited:
Back
Top Bottom