AIP conditions

Tools for osRose and osiRose will be placed in here, as well as Rose file formats.

Please PM rl2171 or lmame to get them added to the list.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:22 pm

AI_COND_011

  1. //Check ability of my Attacker
  2. AIP_COND_011
  3.     uint8 cAbType       //Byte 0
  4.     uint32 iValue       //Byte 4
  5.     uint8 cMoreLess     //Byte 8
  6.     CCharacter* myAttacker = entity->getCharAttacker( ) //get the character that attacked me
  7.     if(myAttacker == NULL)
  8.         return AI_FAILURE
  9.     int AttackerValue = AI_GetAbility(myAttacker, cAbType)  //get attackers ability value
  10.     if(cMoreLess == 0)  //0 = more
  11.         if(AttackerValue >= iValue)
  12.             return AI_SUCCESS
  13.     else                // 1 = less
  14.         if(AttackerValue <= iValue)
  15.             return AI_SUCCESS
  16.     return AI_FAILURE

More abilitys to compare
This one checks whether a specified ability of my attacker is greater than or less than another value arbitrarily defined in the AIP file. kinda lame if you ask me.
If my attackers level is less than 3 then do something.... Run away in fear perhaps?
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:24 pm

AI_COND_012

  1. //Check Time is it day or night
  2. AIP_COND_012
  3.     uint8 cWhen         //Byte 0
  4.     //Is it night or day? cWhen: 1 = night 0 = day
  5.     CMap* map = GServer->MapList.Index[entity->Position->Map];
  6.     if ( cWhen == 1 )
  7.         if ( map->CurrentTime > 2 )  // night
  8.             return AI_SUCCESS
  9.     else
  10.         if ( map->CurrentTime < 3 )  // day
  11.             return AI_SUCCESS
  12.     return AI_FAILURE

Checks if it is day or night in the current map
Nothing much else to say about this one
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:30 pm

AI_COND_013

  1. //Check myself or Target for buffs
  2. AIP_COND_013
  3.     uint8 btCheckTarget         //Byte 0
  4.     uint8 btStatusType          //Byte 1
  5.     uint8 btHave                //Byte 2
  6.  
  7.     //Does my target btHave MagicSTATUS (btStatusType)
  8.     //btCheckTarget does Get_MagicSTATUS but uses different AND masks
  9.     //btCheckTarget = 0 AND EAX,1EAAA84
  10.     //btCheckTarget = 1 AND EAX,1E155570
  11.     //btCheckTarget = 2 normal
  12.     CCharacter* target = NULL;
  13.     UINT buffs = 0;
  14.     if(btCheckTarget == 1)          //check enemy
  15.        target = entity->getCharTarget( )        //Get target entity
  16.        if(target == NULL)
  17.            return AI_FAILURE
  18.     else if(btCheckTarget == 0)     //check self
  19.          target = entity
  20.     else                            //should never be anything other than 0 or 1
  21.         return AI_FAILURE
  22.     switch(btStatusType)
  23.         case 0:                     //debuff
  24.             buffs = target->Buffs->getBitMask(eBuffBinaryData::DebuffOnly);
  25.             break;
  26.         case 1:                     //buff
  27.             buffs = target->Buffs->getBitMask(eBuffBinaryData::BuffOnly);
  28.             break;
  29.         case 2:                     //effect such as burning
  30.             // if found then set something in buffs
  31.             // Not yet handled
  32.             break;
  33.     if (btHave == 1)                //True if HAS buffs
  34.         if ( buffs != 0 )
  35.             return AI_SUCCESS
  36.         return AI_FAILURE
  37.     else                            // true if NOT HAS buffs
  38.        if( buffs != 0 )
  39.            return AI_FAILURE
  40.        return AI_SUCCESS
  41.     return AI_FAILURE

This one checks to see if the entitys current target has or does not have any buffs currently applied.
It's kind of horribly complicated to find this out since buffs work on a bitmask system that is confusing as hell
Basically all entitys (including players) have a 32bit variable called MagicSTATUS. The first 16 bits of that variable represent buffs and the second 16 represent debuffs so we have to apply completely different bitmasks and AND them with the current MagicStatus value to find out if a specific buff is present. Additionally I don't remember if the function calls used in this code are actually present in standard osrose codebase. Frans did a whole bunch of rewriting in there when we were working over the skills and buff system
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:49 pm

AI_COND_014

  1. //Check Variable (1) (ObjVar)   ObjVar[4000][20] is a global reference variable defined in worldserver.h
  2. //Used to hold Object Variables for specific NPCs. These are then set or read from AIP and QSD
  3. //Often used for stuff like event ids and tracking global states
  4. AIP_COND_014
  5.     uint16 btVarIDX         //Byte 0
  6.     uint16 tBuffer          //Byte 2
  7.     uint32 iValue           //Byte 4
  8.     uint8 btOp              //Byte 8
  9.  
  10.     if(btVarIDX > 19)       //only 20 ( 0~19 ) index values possible for ObjVars
  11.         return AI_FAILURE
  12.     uint16 refNPC = entity->thisnpc->refNPC     // Assumes that you have a global refNPC value currently set in your server. Set it and forget it
  13.     if ( refNPC == 0 )                          // Didn't have one set this time
  14.         return AI_FAILURE
  15.     uint32 tempval = GServer->ObjVar[refNPC][btVarIDX]  //Grab the specified Object Variable and store it locally
  16.     switch(btOp)
  17.         case 0:
  18.             if(tempval == iValue)
  19.                 return AI_SUCCESS
  20.         case 1:
  21.             if(tempval > iValue)
  22.                 return AI_SUCCESS
  23.         case 2:
  24.             if(tempval >= iValue)
  25.                 return AI_SUCCESS
  26.         case 3:
  27.             if(tempval < iValue)
  28.                 return AI_SUCCESS
  29.         case 4:
  30.             if(tempval <= iValue)
  31.                 return AI_SUCCESS
  32.         case 10:
  33.             if(tempval != iValue)
  34.                 return AI_SUCCESS
  35.         default:                // return Failure by default
  36.             return AI_FAILURE
  37.     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?
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:52 pm

AI_COND_015

  1. //Check Variable (2) (WorldVAR) //PY will work just like NPC ObjVar.  To Be Coded later since we currently don't actually have a world Var yet
  2. //Currently never used in any AIP file
  3. AIP_COND_015
  4.     uint16 btVarIDX         //Byte 0
  5.     uint16 tBuffer          //Byte 2
  6.     uint32 iValue           //Byte 4
  7.     uint8 btOp              //Byte 8
  8.     return AI_FAILURE


WorldVars work exactly the same way as ObjVars...
Except for the fact that they don't actually exist...
This is basically the stub of a whole bunch of functionality that was never built out in the world or ROSE
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:53 pm

AI_COND_016

  1. //Check Variable (3) (EconomyVar)
  2. //Same thing again but for economy variable
  3. //Currently never used in any AIP file
  4. int32 AIP_COND_016
  5.     uint16 btVarIDX         //Byte 0
  6.     uint16 tBuffer          //Byte 2
  7.     uint32 iValue           //Byte 4
  8.     uint8 btOp              //Byte 8
  9.     return AI_FAILURE


Another incomplete stub function that they never finished off
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:55 pm

AI_COND_017

  1. //Select ObjVar reference
  2. //This is where we actually select an NPC and set the refNPC variable
  3. AIP_COND_017
  4.     uint16 iNpcNo           //Byte 0
  5.     entity->thisnpc->refNPC = iNpcNo; // sets the reference variable for the correct ObjVar
  6.     return AI_SUCCESS


This one actually sets the refNPC variable that will later be used to address a specified ObjVar.
Just remember that each entity can potentially have their own unique refNPC value although a particular entity can only have one value in refNPC at a time.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 8:59 pm

AI_COND_018

  1. //Check Distance to my owner
  2. //For this one the current entity needs to be a summon
  3. AIP_COND_018
  4.     uint32 iDistance        //Byte 0
  5.     uint8 btOp              //Byte 4
  6.  
  7.     if ( !entity->IsSummon ( ) )    //Only applies to Summons. If it's anything else return failure
  8.         return AI_FAILURE           //No business being here if you are NOT a summon
  9.     }
  10.     CMap* map = GServer->MapList.Index[entity->Position->Map]   //Select current map
  11.     CCharacter* caller = map->GetCharInMap( entity->owner )     //Find the summon's owner
  12.     if ( caller == NULL )
  13.         return AI_SUCCESS    //This has to return true if there is no owner. Otherwise orphaned bonfires will live forever
  14.     if(entity->owner == 0)
  15.         return AI_SUCCESS;  //Monster has no owner so returning true should make it suicide
  16.     uint16 distance         //calculate distance from monster to owner
  17.     //Use operateValues on BtOp and distance. It's a fancy schmancy bit of code that does all the dirty work for you
  18.     if(OperateValues<uint16>(btOp, (uint16*)&distance, iDistance))
  19.         return AI_SUCCESS
  20.     else
  21.         return AI_FAILURE   //only this result allows the summon to remain alive
  22.     return AI_SUCCESS       //default allows for suicide


The first of many functions relating to summons.
This one checks the distance from the focused entity to the location of that entitys caller (owner)
I don't think that the base code in osrose allows for directly finding an owner in the way that it is done here. We had to build in a few readback systems to make that kind of thing possible.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 9:00 pm

AIP_COND_019

  1. //Check zone Time between start and end
  2. //This is used for stuff such as Burtland opening and closing Clan Fields at the same time each day
  3. AIP_COND_019
  4.     uint32 ulTime       //Byte 0
  5.     uint32 ulEndTime    //Byte 4
  6.  
  7.     //Get_ZoneTIME between ulTime and ulEndTime
  8.     CMap* map = GServer->MapList.Index[entity->Position->Map]   //set current map
  9.     int StartTime = int(ulTime)     //just a couple of explicit type conversions.
  10.     int EndTime = int(ulEndTime)    //Nothing to get excited about
  11.     if(map->ZoneTime >= StartTime && map->ZoneTime <= EndTime)
  12.         return AI_SUCCESS
  13.     return AI_FAILURE


Checks map (zone) time to see if it is within a specified time window.
We use code like this to figure out when the clanfields can be opened and also for certain events
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: AIP conditions

Postby PurpleYouko on Wed May 29, 2019 9:02 pm

AIP_COND_020

  1. //Check My own ability
  2. AIP_COND_020
  3.     uint8 btAbType      //Byte 0
  4.     uint32 iValue       //Byte 4
  5.     uint8 btOp          //Byte 8
  6.     uint16 value =      AI_GetAbility       (entity, btAbType)      //Lookup
  7.     if(value < 0) return AI_FAILURE;
  8.     if(OperateValues<uint16>(btOp, (uint16*)&value, iValue))
  9.         return AI_SUCCESS
  10.     return AI_FAILURE


More ability checks. This time my own ability.
No idea why this stuff had to be all over the place like this rather than grouped together
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

PreviousNext

Return to Tools and File Format

Who is online

Users browsing this forum: No registered users and 6 guests

cron