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 9:03 pm

AIP_COND_021

  1. //Am I an orphaned summon?
  2. int32 AIP_COND_021
  3.     // Am I an orphan? True if I have no caller
  4.     if ( !entity->IsSummon ( ) )    //Only applies to Summons. If it's anything else return true
  5.         return AI_FAILURE           //No business being here if you are NOT a summon
  6.     CMap* map = GServer->MapList.Index [ entity->Position->Map ]    //select current map
  7.     CCharacter* caller = map->GetCharInMap ( entity->owner )        //find owner
  8.     if ( caller == NULL )                                           //No owner. Return success
  9.         return AI_SUCCESS
  10.     if(entity->owner == 0)                                          //No owner. Return success
  11.         return AI_SUCCESS
  12.     return AI_FAILURE


Am I an orphaned summon?
Pretty straight forward
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:04 pm

AIP_COND_022

  1. //Does my caller have a target
  2. AIP_COND_022
  3.     if ( !entity->IsSummon ( ) )    //Only applies to Summons. If it's anything else return true
  4.         return AI_FAILURE           //No business being here if you are NOT a summon
  5.     CMap* map = GServer->MapList.Index [ entity->Position->Map ]    //select current map
  6.     CCharacter* caller = map->GetCharInMap ( entity->owner )        //find owner
  7.     if(caller == NULL)              //No owner. returning failure
  8.         return AI_FAILURE
  9.     CCharacter* target = map->GetCharInMap(caller->CurrentAction->targetID) //Find owner's current target
  10.     if(target == entity)        //Owner's target is currently myself. That's dumb. returning failure
  11.         return AI_FAILURE
  12.     if(target != NULL)          //Owner has a target. Returning success
  13.         return AI_SUCCESS
  14.     return AI_FAILURE


Now we need to figure out if my owner currently has a target
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:06 pm

AIP_COND_023

  1. //Check Time (3) (World time?)
  2. //We currently have no concept of "world" time in the server so this isn't going anywhere any time soon
  3. //Additionally no AIP file uses this condition
  4. AIP_COND_023
  5.     uint32 ulTime       //Byte 0
  6.     uint32 ulEndTime    //Byte 4
  7.     //Get_WorldTIME between ulTime and ulEndTime
  8.     return AI_FAILURE


I got nothing with this one.
We have no way to actually check this.
World Time is a kind of meaningless concept, besides which, no AIP files ever even attempt to use this.
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:07 pm

AIP_COND_024

  1. //Check Date Time (4) (Actual time)
  2. // we can do this on. It uses the timer api built into your server computer
  3. AIP_COND_024
  4.     uint8 btDate        //Byte 0
  5.     uint8 btHour1       //Byte 1
  6.     uint8 btMin1        //Byte 2
  7.     uint8 btHour2       //Byte 3
  8.     uint8 btMin2        //Byte 4
  9.     SYSTEMTIME sTIME        //grab a copy of system time
  10.     GetLocalTime(&sTIME)
  11.  
  12.     if( btDate != 0 )
  13.         if(sTIME.wDay != btDate)    //not the correct date
  14.             return AI_FAILURE
  15.     //convert values to system time
  16.     uint16 wMin = ((sTIME.wHour * 60) + sTIME.wMinute);
  17.     uint16 wFrom = (btHour1 * 60) + btMin1;
  18.     uint16 wTo = (btHour2 * 60) + btMin2;
  19.     if(wMin >= wFrom && wMin <= wTo) //current time is within the specified limits
  20.         return AI_SUCCESS
  21.     return AI_FAILURE               //current time is NOT within the specified limits

This one we can do pretty easily
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:08 pm

AIP_COND_025

  1. //Check Weekday Time (5)
  2. AIP_COND_025
  3.     uint8 btDate        //Byte 0
  4.     uint8 btHour1       //Byte 1
  5.     uint8 btMin1        //Byte 2
  6.     uint8 btHour2       //Byte 3
  7.     uint8 btMin2        //Byte 4
  8.     SYSTEMTIME sTIME        //grab a copy of system time
  9.     GetLocalTime(&sTIME)
  10.     if(btWeekDay != sTIME.wDayOfWeek)   //not the correct week day
  11.         return AI_FAILURE
  12.     //convert values to system time
  13.     word wMin = ((sTIME.wHour * 60) + sTIME.wMinute);
  14.     word wFrom = (btHour1 * 60) + btMin1;
  15.     word wTo = (btHour2 * 60) + btMin2;
  16.     if(wMin > wFrom && wMin < wTo) //current time is within the specified limits
  17.         return AI_SUCCESS
  18.     return AI_FAILURE               //current time is NOT within the specified limits


This one isn't so bad either
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:10 pm

AIP_COND_026

  1. //Check Server/Channel
  2. //This one just checks the current server id against a value in the AIP file
  3. //Not actually used in any AIP files but easy enough to code
  4. AIP_COND_026
  5.     uint16 nX       //Byte 0
  6.     uint16 nY       //Byte 2
  7.     if (GServer->Config.ServerID >=nX && GServer->Config.ServerID <= nY)
  8.         return AI_SUCCESS
  9.     else
  10.         return AI_FAILURE


Check server channel.
Not difficult to code but up to now, no AIP files use it.
I guess it could be used to have different events in different channels of a multi-channel server.
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:12 pm

AIP_COND_027

  1. //Find Near Character. Locates the nearest entity that meets all the specifid criteria
  2. //Stores it into the nearChar variable
  3. AIP_COND_027
  4.     uint32 iDistance        //Byte 0
  5.     uint8 btIsAllied        //Byte 4
  6.     uint16 nLevelDiff       //0xffff - Byte 6
  7.     uint16 nLevelDiff2      //Byte 8
  8.     uint16 wChrNum          //Byte 10
  9.     uint8 btOp              //Byte 12
  10.     //count how many aiobj between nLevelDiff and nLevelDiff2 who is btIsAllied within iDistance
  11.     //must be (btOp) wChrNum
  12.    
  13.     //initialize a few variables
  14.     uint16 chrCount = 0
  15.     uint32 eCount = 0
  16.     uint32 nearestDistance = 9999999
  17.     uint32 checkDistance = 0
  18.  
  19.     CMap* map = GServer->MapList.Index[entity->Position->Map]       //Set current map
  20.     vector <CCharacter*> entityList = map->NearList ( entity, iDistance, entity->Position->current )    //get a filtered list of entities within iDistance
  21.     uint32 entityCount = entityList.size ( )
  22.     for ( uint16 j = 0; j < entityList.size ( ); j++ )
  23.         CCharacter* other = entityList.at ( j )
  24.         if ( btIsAllied == ( other->team == entity->team ) )
  25.             if ( other->Stats->Level >= ( entity->Stats->Level - nLevelDiff ) && other->Stats->Level <= ( entity->Stats->Level + nLevelDiff2 ) )
  26.                 int checkDistance       //calculate distance between myself and other   
  27.                 if ( checkDistance > iDistance )        //too far away to consider
  28.                     continue;
  29.                 chrCount++      //increment the count
  30.                 if ( checkDistance < nearestDistance )                 
  31.                     nearestDistance = checkDistance
  32.                     entity->nearChar = other->clientid  //Set nearChar
  33.         entity->findChar = entity->nearChar
  34.         if ( OperateValues<uint16> ( btOp, ( uint16* ) &chrCount, ( uint16 ) wChrNum ) )    //check against btOp
  35.             return AI_SUCCESS
  36.     return AI_FAILURE

Another one of these things.
Pretty similar to AIP_COND_002
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:14 pm

AIP_COND_028

  1. //Check Variable (4)
  2. //Every entity in the game has an AIV[20] array in their basic structure. We can use it to store anything we like
  3. AIP_COND_028
  4.     uint16 nVarIDX      //Byte 0
  5.     uint32 iValue       //Byte 4
  6.     uint8 btOp          //Byte 8
  7.     //Get_AiVAR
  8.     if ( nVarIDX > 19 )         //There are only 20 AIVars in the array 0 ~ 19
  9.         return AI_FAILURE
  10.     UINT tempval = entity->AIVar[nVarIDX];  //read the current value from the AIVar
  11.     switch(btOp)
  12.         case 0:
  13.              if(tempval == iValue)
  14.                  return AI_SUCCESS
  15.              else
  16.                  return AI_FAILURE
  17.         case 1:
  18.              if(tempval > iValue)
  19.                  return AI_SUCCESS
  20.              else
  21.                  return AI_FAILURE
  22.         case 2:
  23.              if(tempval >= iValue)
  24.                  return AI_SUCCESS
  25.              else
  26.                  return AI_FAILURE
  27.         case 3:
  28.              if(tempval < iValue)
  29.                  return AI_SUCCESS
  30.              else
  31.                  return AI_FAILURE
  32.         case 4:
  33.              if(tempval <= iValue)
  34.                  return AI_SUCCESS
  35.              else
  36.                  return AI_FAILURE
  37.         case 10:
  38.              if(tempval != iValue)
  39.                  return AI_SUCCESS
  40.              else
  41.                  return AI_FAILURE
  42.         default:
  43.             return AI_FAILURE
  44.     return AI_FAILURE

This time we are checking an internal variable called AIVar
each entity in the game has an AIVar[20] array that we can use to keep track of stuff like how many enemys it has killed or whatever
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:16 pm

AIP_COND_029

  1. //Attackers / attack target is the clan master ?
  2. AIP_COND_029
  3.     uint8 btTargetType      //Byte 0
  4.     if(btTargetType == 0)       // 0 : Attacker
  5.         CCharacter* attacker = entity->getCharAttacker( )   //Get my attacker
  6.         if ( attacker == NULL || !attacker->IsPlayer())
  7.             return AI_FAILURE
  8.         //Unfortunately we need to get clan information now and that is only contained in the Player structure
  9.         //So here goes with a conversion
  10.         CPlayer* thisClient = reinterpret_cast<CPlayer*>(attacker) //Get my current attacker
  11.         if (thisClient == NULL)                 //Don't have an attacket so return failure
  12.             return AI_FAILURE
  13.         if( thisClient->Clan->clanrank == 6)    //Player IS the clan master
  14.             return AI_SUCCESS
  15.         else                                    //Not clan master
  16.             return AI_FAILURE
  17.     if(btTargetType == 1)       // 1 : Attack target
  18.         CCharacter* target = entity->getCharTarget( )   //Get my current target
  19.         if ( target == NULL || !target->IsPlayer())     //Don't have one so return failure
  20.             return AI_FAILURE
  21.         CPlayer* thisClient = reinterpret_cast<CPlayer*>(target)    //Convert to player
  22.         if ( thisClient->Clan->clanrank == 6 )  //Player IS clan master
  23.             return AI_SUCCESS
  24.         else                                    //Not clan master
  25.             return AI_FAILURE
  26.     return AI_FAILURE           //Must be some funny value in btTargetType


So... All this crap is here simply to determine if my current attacker or my current target happens to be a clan master
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:18 pm

AIP_COND_030

  1. //Timer since spawn (seconds).
  2. //Mostly used to make summons like Bonfires go poof when they get too old
  3. AIP_COND_030
  4.     uint32 Timer        //Byte 0
  5.     //Timer is stored in seconds so we need to multiply it by 1000
  6.     clock_t etime = clock() - entity->SpawnTime;
  7.     if(etime > (Timer * 1000))  //Yes entity is older than defined value
  8.         return AI_SUCCESS
  9.     return AI_FAILURE


How long have I been alive?
Stuff like Bonfires have an extremely short lifespan so we use this to figure out when they need to commit suicide.
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 7 guests