SetGraphics
Category: Objects
/ Display
Since engine version: 4.9.1.0 GWE
(extended in 4.9.5.0 CE)
Description
Changes the graphics of an 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 szGfxName, object pObj, id idSrcDef, int iOverlay, int iOverlayMode, string szAction, int dwBlitMode, object pOvelayObject);
Parameters
- szGfxName:
[opt]
Name of the graphic to be set. If 0, the default graphic (Graphics.png or bmp) is set.
- pObj:
[opt]
Object the graphics of which you want to change. Can be 0 in local calls.
- idSrcDef:
[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 iOverlay!=0, the overlay is removed.
- iOverlay:
[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).
- iOverlayMode:
[opt]
Only in conjunction with iOverlay 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. From CR. |
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. From CR. |
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! From CR. |
GFXOV_MODE_ExtraGraphics |
6 |
Draws the target object a second time, using the supplied graphics. The source coordinates are the same as in the original object drawing. Since CR. |
- szAction:
[opt]
Only for iOverlayMode==GFXOV_MODE_Action: the activity in definition idSrcDef, the graphics of which shall be superimposed onto the object. This activity has to be defined as Action in
ActMap.txt of the source definition. Notice: the length of this animation should be 1; longer animations are not yet possible. From CR.
- dwBlitMode:
[opt]
Blit mode of the overlayed graphics (e.g. additive). Siehe
SetObjectBlitMode
- pOvelayObject:
[opt]
Only for iOverlayMode==GFXOV_MODE_Object: the object the graphics of which shall be superimposed onto the target object. From CR.
Remark
With iOverlay=0 only the base graphics of an object are changed. The effect corresponds to replacing Graphics.bmp/-.png/Overlay.png in the object
definition. Source information from
ActMap.txt 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
SetGraphics(0, FindObject(ROCK), GOLD);
Gives a randomly chosen rock in the landscape the appearance of gold.
SetGraphics("Armored", FindObject(KNIG));
Gives the most recently created knight the appearance of a knight in armor, using the files GraphicsArmored.png and OverlayArmored.png found in the knight definition file.
var obj; while (obj = FindObject(0, 0,0,0,0, 0, 0,0, 0, obj)) SetGraphics(0, obj);
Restores the original graphics for all objects in the game.
SetGraphics(0, this(), CLNK, GFX_Overlay, GFXOV_MODE_Picture);
SetObjDrawTransform(800,0,0, 0,800,0, this(), GFX_Overlay);
An object script: the calling object will have a small clonk image superimposed on its picture.
SetGraphics(0, FindObject(KNIG), SHIA, GFX_Overlay, GFXOV_MODE_Base, 0, GFX_BLIT_Additive);
Some knight will be displayed with a shield, additively drawn onto the clonk.
Sven2, Juni 2003, März 2005