1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
/**
Tutorial Arrow
Arrow to show important stuff to the player, can be created by using one of the global functions.
@author Sven2, Maikel
*/
// Remove arrow if it was showing a target object which got removed.
protected func AttachTargetLost() { RemoveObject(); }
// Remove arrow if target object entered a container.
protected func Entrance() { RemoveObject(); }
/*-- Arrow Creation --*/
/** Removes all tutorial arrows.
*/
global func TutArrowClear()
{
for (var arrow in FindObjects(Find_ID(TutorialArrow)))
arrow->RemoveObject();
return;
}
/** Creates an arrow to indicate a position.
* @param x X-coordinate of the position.
* @param y Y-coordinate of the position.
* @param angle angle at which the arrow should be drawn, standard \c 135 degrees.
* @param dist distance of the arrow to the position, standard 16 pixels.
* @return the arrow created.
*/
global func TutArrowShowPos(int x, int y, int angle, int dist)
{
if (angle == nil)
angle = 135;
if (dist == nil)
dist = 16;
var arrow = CreateObject(TutorialArrow, x, y, NO_OWNER);
if (!arrow)
return;
// Display bouncing arrow, corrected for arrow size.
dist += 8;
x -= Sin(angle, dist);
y += Cos(angle, dist);
arrow->SetAction("Show");
arrow->SetPosition(x, y);
arrow->SetR(angle);
return arrow;
}
/** Creates an arrow to indicate the target.
* @param target target object which should be indicated by the arrow.
* @param angle angle at which the arrow should be drawn, standard \c 135 degrees.
* @param dist distance of the arrow to the target object, standard 16 pixels.
* @return the arrow created.
*/
global func TutArrowShowTarget(object target, int angle, int dist)
{
if (!target)
return;
if (angle == nil)
angle = 135;
if (dist == nil)
dist = 16;
var arrow = CreateObject(TutorialArrow, target->GetX(), target->GetY(), NO_OWNER);
if (!arrow)
return;
// Display spinning arrow, corrected for arrow size.
dist += 8;
arrow->SetAction("Attach", target);
arrow->SetR(angle);
arrow->SetVertex(0, VTX_Y, -dist, VTX_SetPermanentUpd);
return arrow;
}
/** Creates an arrow to indicate a GUI position.
* @param x X-coordinate of the GUI position.
* @param y Y-coordinate of the GUI position.
* @param angle angle at which the arrow should be drawn, standard \c 135 degrees.
* @param dist distance of the arrow to the position, standard 16 pixels.
* @return the arrow created.
*/
global func TutArrowShowGUIPos(int x, int y, int angle, int dist)
{
if (angle == nil)
angle = 135;
if (dist == nil)
dist = 16;
var arrow = CreateObject(TutorialArrow, x, y, NO_OWNER);
arrow.MeshTransformation = Trans_Scale(3600);
if (!arrow)
return;
// Change arrow category to C4D_Gui.
arrow->SetCategory(C4D_IgnoreFoW | C4D_Foreground | C4D_Parallax);
arrow.Plane = 2500;
// Display bouncing arrow, corrected for arrow size.
dist += 8;
x -= Sin(angle, dist);
y += Cos(angle, dist);
arrow->SetAction("Show");
arrow->SetPosition(x, y);
arrow->SetR(angle);
return arrow;
}
/** Creates an arrow to indicate the target.
* @param target GUI object which should be indicated by the arrow.
* @param angle angle at which the arrow should be drawn, standard \c 135 degrees.
* @param dist distance of the arrow to the target object, automatically corrects for GUI object's size.
* @return the arrow created.
*/
global func TutArrowShowGUITarget(object target, int angle, int dist)
{
if (!target)
return;
if (angle == nil)
angle = 135;
if (dist == nil)
dist = 16;
var arrow = CreateObject(TutorialArrow, target->GetX(), target->GetY(), NO_OWNER);
arrow.MeshTransformation = Trans_Scale(3600);
if (!arrow)
return;
// Change arrow category to C4D_Gui and set correct plane.
arrow->SetCategory(C4D_IgnoreFoW | C4D_Foreground | C4D_Parallax);
arrow.Plane = target.Plane;
// Display spinning arrow, corrected for GUI and arrow size.
dist += 8 + target->GetID()->GetDefHeight() / 2;
arrow->SetAction("Attach", target);
arrow->SetR(angle);
arrow->SetVertex(0, VTX_Y, -dist, VTX_SetPermanentUpd);
return arrow;
}
/*-- Proplist --*/
local Name = "$Name$";
local MeshTransformation = [1400, 0, 0, 0, 0, 1400, 0, 0, 0, 0, 1400, 0];
local Parallaxity = [0, 0];
local Plane = 375;
local ActMap = {
Attach = {
Prototype = Action,
Name = "Attach",
Procedure = DFA_ATTACH,
Length = 20,
Delay = 2,
X = 0,
Y = 0,
Wdt = 32,
Hgt = 32,
NextAction = "Attach",
Animation = "Spin",
},
Show = {
Prototype = Action,
Name = "Show",
Procedure = DFA_FLOAT,
Length = 20,
Delay = 2,
X = 0,
Y = 0,
Wdt = 32,
Hgt = 32,
NextAction = "Show",
Animation = "Bounce",
},
};
|