Garry's Mod Wiki

NPC:SetIgnoreConditions

  NPC:SetIgnoreConditions( table conditions, number size )

Description

Sets conditions to ignore, which would normally interrupt an Engine-based schedule. Specified conditions will still be set, will call ENTITY:OnCondition and can be returned by NPC:HasCondition, but they will no longer interrupt the Engine schedule.

Arguments

1 table conditions
Conditions to ignore, see COND enum. The table must be sequential, numerical and values must correspond to condition enums.
2 number size
Number of conditions to include in the ignored conditions table. Set this to the size of ignored conditions table to ignore all specified conditions.

Example

Ignore all conditions for this SNPC, allows it to naturally process the engine schedule.

function ENT:StartEngineSchedule() -- best place to set ignored conditions without ENT.BuildScheduleTestBits local tblIgnoredConds = { } for i = 1, table.Count(COND) do -- 72 keyvalues tblIgnoredConds[i] = i -- { [1] = 1, [2] = 2 } and so on end self:SetIgnoreConditions(tblIgnoredConds,#tblIgnoredConds) end

Example

Ignore specific conditions from interrupting this SNPC while attacking.

function ENT:StartEngineSchedule() -- best place to set ignored conditions without ENT.BuildScheduleTestBits if self:GetCurrentSchedule() >= SCHED_RANGE_ATTACK1 and self:GetCurrentSchedule() <= SCHED_SPECIAL_ATTACK2 then local tblIgnoredConds = {COND.NEW_ENEMY, COND.LIGHT_DAMAGE} self:SetIgnoreConditions(tblIgnoredConds,#tblIgnoredConds) end end