AI_COND_014
- //Check Variable (1) (ObjVar) ObjVar[4000][20] is a global reference variable defined in worldserver.h
- //Used to hold Object Variables for specific NPCs. These are then set or read from AIP and QSD
- //Often used for stuff like event ids and tracking global states
- AIP_COND_014
- uint16 btVarIDX //Byte 0
- uint16 tBuffer //Byte 2
- uint32 iValue //Byte 4
- uint8 btOp //Byte 8
-
- if(btVarIDX > 19) //only 20 ( 0~19 ) index values possible for ObjVars
- return AI_FAILURE
- uint16 refNPC = entity->thisnpc->refNPC // Assumes that you have a global refNPC value currently set in your server. Set it and forget it
- if ( refNPC == 0 ) // Didn't have one set this time
- return AI_FAILURE
- uint32 tempval = GServer->ObjVar[refNPC][btVarIDX] //Grab the specified Object Variable and store it locally
- switch(btOp)
- case 0:
- if(tempval == iValue)
- return AI_SUCCESS
- case 1:
- if(tempval > iValue)
- return AI_SUCCESS
- case 2:
- if(tempval >= iValue)
- return AI_SUCCESS
- case 3:
- if(tempval < iValue)
- return AI_SUCCESS
- case 4:
- if(tempval <= iValue)
- return AI_SUCCESS
- case 10:
- if(tempval != iValue)
- return AI_SUCCESS
- default: // return Failure by default
- return AI_FAILURE
- return AI_FAILURE // Shouldn't ever be able to get to here but whatever. return fail just in case
And here is the lovely ObjVar system.
This is basically a great big globally available 2 dimensional array that is housed in the worldserver.
ObjVar[4000][20]
The monster type of an NPC is used to address the first part of the array. This value comes from a value that is stored within another variable owned by the current entity (NPC or monster) that is being parsed. The value is called
entity->thisnpc->refNPC. It is set from right here in AIP Conditions although not in this actual condition. Once set it stays constant until it becomes changed by some other action or condition. make sense? probably not but whatever.
What happens usually is that somewhere in the server a specified NPC such as Judy (ID = 1201) will have one of their Object Variables changed to reflect some global event or something. Maybe the worldcup event started.
So let's just image that we set ObjVar [1201][1] to a value of 20 when this event starts for the sake of argument
Since this is a global variable in the worldserver it means that any entity can access it.
In the case of the worldcup event we want every monster that dies to spawn one of those weird little zippy ball things
so in a specific part of the AIP file of every monster it checks (on_death) to see if ObjVar[1201][1] is equal to 20. If it is then a ball gets spawned
What this function does is to read an ObjVar value that is pointed at by the currently set refNPC value and the locally (in the AIP file) defined sub-array ( btVarIDX )
After reading in the value it then compares it against iValue using btOp to define which kind of comparison to use.
Why do i get the feeling that very few people will have a freaking clue what I'm taking about at this point?