Skip to content

SetActorHostileToActor

Sets an actor on another actor - or stands it down.

true makes target the actor’s opponent: it faces it, walks after it and swings like at a player (SetActorHostile), and every screen shows the two fight. The server decides each blow itself: out of reach it misses, a raised guard blocks it ([actors] block_chance), otherwise it is the attacker’s weapon - or its fists - against the body part struck, times [actors] attack_scale, at most [actors] max_damage, through OnActorAttackActor. With [actors] fight_back the target turns on its attacker at the first blow unless it fights someone already; without it, set both. An actor fights one opponent at a time: this replaces a player it was on, and SetActorHostile replaces this. false stands it down if it is on target - so do either’s death or removal, another world, chase_range and MoveActor.

SetActorHostileToActor(id, target, hostile)
Parameter Type
id number the actor
target number the actor to fight
hostile boolean true = the actor fights target; false = peace

boolean - false unless both are living actors in one world (and not the same one)

-- a brawl in the tavern: the drunk starts it, the other answers the first blow
local drunk = CreateActor(nil, x, y, z, 90, "Drunk", nil, "none")
local miller = CreateActor(nil, x + 2, y, z, 270, "Miller", nil, "none")
SetActorHostileToActor(drunk, miller, true)

GetActorTarget · OnActorAttackActor · SetActorHostile · StopActor · the NPC actors group of the index