AIP_REWD_025
- //Set or modify ObjVar Variable
- AIP_REWD_025
- uint16 nVarno //Byte 0
- uint32 iValue //Byte 4
- uint8 btOp //Byte 8
-
- if ( nVarno > 19 ) //only 20 ( 0 ~ 19 ) addresses available
- return AI_SUCCESS
- if(entity->thisnpc->refNPC >= MAX_NPC) //MAX_NPC should coroespond to the size of your LIST_NPC.STB file
- return AI_SUCCESS
- short tempval = GServer->ObjVar[entity->thisnpc->refNPC][nVarno] //temporary holder for current ObjVar value
-
- switch(btOp) // So what to do with the current value in the ObjVar array
- case 5:
- tempval = iValue // Overwrite it with iValue
- case 6:
- tempval += iValue // add iValue to it
- case 7:
- tempval -= iValue // subtract iValue from it
- case 9:
- tempval++ // increment it
- default: // or maybe btOp was not one of the usable values so do nothing
- return AI_SUCCESS
- if(tempval < 0) // Make sure tempval stays >= 0
- tempval = 0
- GServer->ObjVar[entity->thisnpc->refNPC][nVarno] = tempval // Save tempval back into the ObjVar
-
- return AI_SUCCESS
This one is quite versatile. We can use it for several things.
Basically though it is used to set or modify one of the 20 possible ObjVar variables for refNPC (selected in conditions).
As you may remember ObjVar is a 2 dimensional array with the first index being address by the entity's currently set refNPC variable which we set up in one of the conditions. refNPC is persistent in that it remains set for the lifetime of an entity or until it is overwritten by another AIP condition.
So that means that every NPC (technically every monster type but there are only ever one of each NPC type in the world at any given time) has an array of 20 values that can be stored and manipulated
What makes this so versatile is that a number of the positions in this 20 number array have extra-curricular activities. i.e. they have direct effects on the world other than just storing things like current world states.
element 0 is extremely special. It represents the NPCs
eventIDIf you set this one to some new value then you will actively be changing the entire event.
Example.
Good old Judy in Zant. She controls tons of events
so for events connected to Judy we would be looking at ObjVar[1201][0]
if this value is zero then she just gives you the default scripts and tells you that nothing much is going on right now.
if you set it to 101 though.... That starts the summer event so when you talk to her she will say
Hello, <NAME>. Do you have any plans for this summer vacation?
and then send you off to the sunshine coast to clean up the beach by collecting trash. She will also trade that trash for all kinds of goodies.
All that just by setting one simple ObjVar value using a refNPC of 1201
Wanna start the world cup soccer event? Set it to 308
the only problem in all this is that in the standard osrose servers there is no direct link between element 0 and the event id. The AIP will still make it work but the code uses special case scenarios rather than directly connecting the dots.
Element 2 is rumored to be special as well in certain cases.
if we set ObjVar [1113][2] it can trigger something related to union wars. That's [Referee] Leum in case you were wondering. This is far from fully coded out though so don't expect it to just work if you set that value