Difference between revisions of "ConflictSystem"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
(FreezeConflictTable)
(GetConflictRelation)
Line 70: Line 70:
  
 
=== GetConflictRelation ===
 
=== GetConflictRelation ===
 +
''
 +
  -- Get the relation of conflict mobileA is to mobileB.
 +
  -- @param mobileA(mobileObj)
 +
  -- @param mobileB(mobileObj)
 +
  -- @param mobileAConflictTable(optional) return value from GetConflictTable()
 +
  -- @return One of ConflictRelations, nil if not-found/expired.
 +
 +
  function GetConflictRelation(mobileA, mobileB, mobileAConflictTable)
 +
    mobileAConflictTable = mobileAConflictTable or GetConflictTable(mobileA) or {}
 +
    -- only valid, frozen/non-expired, will make the cut.
 +
    if ( ValidConflictRelationTable(mobileAConflictTable[mobileB]) ) then
 +
        return mobileAConflictTable[mobileB][1]
 +
    end
 +
    return nil
 +
  end
 +
''
 +
 
=== ValidConflictRelationTable ===
 
=== ValidConflictRelationTable ===
 
=== UpdateConflictRelation ===
 
=== UpdateConflictRelation ===

Revision as of 07:59, 27 January 2018

welcome this will discuss the contents of the globals\helpers\conflict.lua

ConflictRelations Table

Conflict Functions

GetConflictTable

 -- Get the conflict table for a mobile
 -- @param mobile(mobileObj)
 -- @return luaTable containing all conflicts for this mobile
 function GetConflictTable(mobile)
   if ( mobile == nil or not mobile ) then
       LuaDebugCallStack("[Conflict] Invalid mobile provided.")
       return {}
   end
   return mobile:GetObjVar("Conflicts") or {}
 end

ClearConflictTable

 -- Clear the conflict table of a mobile
 -- @param mobile(mobileObj)
 -- @return none
 function ClearConflictTable(mobile, isPlayer)
   if ( mobile == nil or not mobile ) then
       LuaDebugCallStack("[Conflict] Invalid mobile provided.")
       return
   end
   if ( mobile:HasObjVar("Conflicts") ) then
       mobile:DelObjVar("Conflicts")
   end
   if ( isPlayer == true ) then
       InitializeClientConflicts(mobile)
   end
 end

SetConflictTable

 -- Set the conflict table for a mobile
 -- @param mobile(mobileObj)
 -- @param data(luaTable)
 -- @return none
 function SetConflictTable(mobile, data)
   mobile:SetObjVar("Conflicts", data)
 end

FreezeConflictTable

 --- Freeze the conflict table on a mobile, optionally saving the frozen table on a 
 different object. Will clear all conflicts for the mobile if target does not equal 
 mobile.
 -- @param mobile(mobileObj)
 -- @param target(gameObj)(optional) the gameObj the conflict table will be saved to
 -- @return none
 function FreezeConflictTable(mobile, target)
   target = target or mobile
   local conflictTable = GetConflictTable(mobile)
   for mobileId,conflict in pairs(conflictTable) do
       -- set all the expires to true, meaning they never expire
       conflictTable[mobileId][2] = true
   end
   -- save the frozen table on the target
   SetConflictTable(target, conflictTable)
 end

GetConflictRelation

 -- Get the relation of conflict mobileA is to mobileB.
 -- @param mobileA(mobileObj)
 -- @param mobileB(mobileObj)
 -- @param mobileAConflictTable(optional) return value from GetConflictTable()
 -- @return One of ConflictRelations, nil if not-found/expired.
 function GetConflictRelation(mobileA, mobileB, mobileAConflictTable)
   mobileAConflictTable = mobileAConflictTable or GetConflictTable(mobileA) or {}
   -- only valid, frozen/non-expired, will make the cut.
   if ( ValidConflictRelationTable(mobileAConflictTable[mobileB]) ) then
       return mobileAConflictTable[mobileB][1]
   end
   return nil
 end

ValidConflictRelationTable

UpdateConflictRelation

ConflictEquals

AdvanceConflictRelation

ForeachAggressor

IsAggressor

IsMobTaggedBy

TagMob

InheritAggressivePlayerConflicts

GetNearbyTaggedMobiles

InitializeClientConflicts