cast(spell: string, target: npc) -> boolcast(spell: string, target: player) -> boolcast(spell: string, target: drop) -> boolcast(spell: string, target: object) -> boolcast(spell: string) -> bool
Casts a spell on an npc by packet. The npc must have been found this pass. False when it could not be sent, with the reason in the trace. You must be in range - approach(target) or reach(target) first.
Casts a spell on another player by packet. False with the reason in the trace.
Casts a spell on an item lying on the floor, such as Telekinetic grab.
Casts a spell on scenery, such as charging an obelisk orb.
Casts a self / no-target spell (a teleport) by packet.
| Parameter | Type | What it does |
|---|---|---|
| spellrequired | string | the spell name, as the spellbook spells it |
| targetrequired | npc | the npc to hit |
let goblin = nearestNpc(name: "Goblin", within: 10, notInCombat: true)
if goblin != none { cast("Fire strike", goblin) }
let foe = nearestPlayer(within: 8)
if foe != none { cast("Fire strike", foe) }
let loot = nearestDrop(name: "Nature rune", within: 5)
if loot != none { cast("Telekinetic grab", loot) }
let obelisk = nearestObject(name: "Obelisk of Water", within: 6)
if obelisk != none { cast("Charge Water Orb", obelisk) }
cast("Home Teleport")