Wednesday, January 11, 2012

CAOS Notes: ORRV

 Let's say you want to make everything in your world carryable by the hand.

This is actually a terrible idea and a great way to screw up your world, but let's throw all that to the wind and have ourselves some chaos.


enum 0 0 0
    setv va00 attr
    orrv va00 2
    attr va00
next


Yes, 0 0 0. If this kills your game you may want to filter it a bit.

ORRV is another weird little command. If you ORRV an ATTR or BHVR value, it will, similar to ANDV, spit out a number that will tell you if the value you're checking is set or not. Only if the value is set, instead of spitting out the value you're checking, it'll spit out your original attr/bhvr.

So in our last lesson:
     setv va00 bhvr
    andv va00 16

If va00 = 16, the eatable bhvr is set.

You can do the same thing with ORRV:
     setv va00 bhvr
    orrv va00 16

But va00 will equal bhvr, not 16, if that bhvr is set. (doif va00 = bhvr...)

There's always a thousand ways to code the same thing, so just do whatever you want.
ORRV, however, has this neat little side effect, you see. If the value you're checking for is not set, ORRV will return the ATTR or BHVR value that your agent would have if it was it set.

So if you want to set an agent as invisible, suffering physics, or whatever, ORRV it, and then just ATTR the value. If it's already set, it'll have no effect, and it if it's not, it will be.

Of course, you could accomplish the same with ANDV, it would just take more lines than necessary:

enum 0 0 0
    setv va00 attr
    andv va00 2
    doif va00 ne 2
        setv va00 attr
        addv va00 2
        attr va00
    endi
next


ORRV is just easier in this case.

Avoid using this to set BHVR values, since those, unlike ATTR values, actually need certain scripts to run and will throw errors if you don't have them. Also remember that if you set an agent to suffer physics, you'll actually have to give it some physics for it to mean anything (ACCG, ELAS, FRIC, etc).

So ORRV is nice for setting attributes an agent doesn't already have, but if you wanted to, say, make all your agents unmovable (to restrain yourself from interfering in a wolfling run, maybe), you'd still have to subtract the value manually:

enum 0 0 0
    setv va00 attr
    orrv va00 2
    doif va00 eq attr
        subv va00 2
        attr va00
    endi
next


Anyway, hopefully by now you have the hang of using ANDV and ORRV for your ATTR/BHVR checking and changing needs. I'm still grasping it myself, so if you're a wiser sort and see anything that I'm missing, do share the knowledge for the benefit of all!

No comments:

Post a Comment