SetGraphics

Category: Objects / Display
Since engine version: 1.0 OC

Description

Changes the graphics of the object. This affects the display of the given object everywhere in the game: in the landscape, in menus, or on control buttons.

Syntax

bool SetGraphics(string gfx_name, id source_definition, int overlay, int overlay_mode, string action, int dwBlitMode, object overlay_object);

Parameters

gfx_name:
[opt] Name of the graphic to be set. If nil, the default graphic is set.
source_definition:
[opt] Definition of which the graphics are to be used. If not specified, the definition of the changed object is used. If not specified and overlay!=0, that overlay is removed.
overlay:
[opt] Index of the overlay graphics to be set. If specified, must be greater than 0 and will add an overlay of the given index to the object or changes an existing overlay of the given index. Overlays with higher index will be drawn on top of those with a lower index. If an object has only one overlay you can use the symbolic constant GFX_Overlay (=1).
overlay_mode:
[opt] Only in conjunction with overlay parameter: specifies how the overlay is to be drawn. The following constants are allowed:
Constant Value Effect
GFXOV_MODE_None 0 Invalid: do not use
GFXOV_MODE_Base 1 The base graphics of the specified definition, meaning the target rectangle (0,0,Width,Height,OffsetX,OffsetY), will be superimposed at the object position.
GFXOV_MODE_Action 2 The actiity of the specified object definition.
GFXOV_MODE_Picture 3 Only affects display of the object in inventory or menus (e.g. when activating in a building). The picture rectangle of the specified definition will be superimposed over the representative picture of the object. In this way you can superimpose a clonk image on a rock or a magic spell picture on a scroll.
GFXOV_MODE_IngamePicture 4 Overlays the picture graphics of the source definition over the shape of the target object.
GFXOV_MODE_Object 5 Superimposes the current object graphics including all overlays of pOverlayObject onto the object. Warning: never superimpose an object recursively onto itself!
GFXOV_MODE_ExtraGraphics 6 Draws the target object a second time, using the supplied graphics. The source coordinates are the same as for drawing obj.
action:
[opt] Only for overlay_mode==GFXOV_MODE_Action: the activity in definition source_definition, the graphics of which shall be superimposed onto the object. This activity has to be defined as Action in ActMap of the source definition. Notice: the length of this animation should be 1; longer animations are not yet possible.
dwBlitMode:
[opt] Blit mode of the overlayed graphics (e.g. additive). Siehe SetObjectBlitMode
overlay_object:
[opt] Only for overlay_mode==GFXOV_MODE_Object: the object the graphics of which shall be superimposed onto the target object.

Remark

With overlay=0 only the base graphics of an object are changed. The effect corresponds to replacing Graphics.png/Overlay.png in the object definition. Source information from the ActMap or DefCore.txt will not be modified by this command. So the given coordinates should always point to sensible areas in the bitmap (including SolidMask areas).

Examples

FindObject(Find_ID(Rock))->SetGraphics(nil, Gold);
Gives a randomly chosen rock in the landscape the appearance of gold.
for (var obj in FindObjects(Find_And())) obj->SetGraphics();
Restores the original graphics for all objects in the game.
SetGraphics(nil, Clonk, GFX_Overlay, GFXOV_MODE_Picture);
SetObjDrawTransform(800,0,0, 0,800,0,GFX_Overlay);
An object script: the calling object will have a small clonk image superimposed on its picture.
See also: Object definitions (ocd), SetObjDrawTransform, SetObjectBlitMode, SetPicture
Sven2, 2005-03