DoMagicEnergy

Category: Objects / Status
Since engine version: 4.6.5.0 CP (extended in 4.9.6.0 CR)

Description

Adjusts the magic value of an object. The change is only performed as a whole - if the specified change would pass the upper or lower physical limit of the object, it is not performed and the function returns false. The effect is that with only one call you can make a change and check whether the change is even possible.

Syntax

bool DoMagicEnergy (int iChange, object pObj, bool fAllowPartial);

Parameters

iChange:
Change of magic value (positive or negative)
pObj:
[opt] Object of which to change the magic value. Can be 0 in local calls.
fAllowPartial:
[opt] If true, the function will also transfer magical energy partially instead of failing. In this case, the function will only fail if the magical energy is not changed at all. Since CR.

Example

if (DoMagicEnergy(-10)) ObjectCall(CreateObject(MLGT,0,0,GetOwner()), "Activate", this());
Casts a lightning spell if enough magic energy is available.
See also: GetMagicEnergy
Sven2, November 2001