This tutorial isn't meant for the new coggers... You have to have an understanding of how cog works and some knowledge of where files go in the resource directory. I'm going to assume you know what goes where in this tutorial.
The targeting reticule is mainly used in force powers (blinding, grip, pull, ect.) and tells the player who/what they have targeted. It has no effect other then that, as the force power's cog already knows what's targeted and what's not.
I reviewed many ways to write this tutorial, and I concluded that displaying the cog I made and giving detailed comments would be the best route, as (how i first started writing this tutorial) doing it step by step takes a long time, and is quite confusing (not only when writing it, but reading one as long as this one would have to be would be no walk in the park either).
There are 3 commands (there may be more, but you only need 3) specifically used for the target reticule.
JkSetTargetColor(color1, color2, color3);
JkSetTarget(Thing);
JkEndTarget();
JkSetTargetColor sets the colors of the 3 'bouncing' circles. Color1 is the color of the 1st circle, color 2 is the color of the 2nd circle, and color 3 is the color of the 3rd circle.
JkSetTarget sets the bouncing circles on the specified thing. Only one thing can be targeted in this manner at a time.
JkEndTarget removes the circles from whatever they were set to by JkSetTarget.
Below is the cog i wrote for this tutorial, it
is also (should be anyway) available in the zip. It replaces force
pull.
# Jedi Knight Cog Script
symbols
int
player
local
flex MaxDist=5 local
message startup
end
# ==========
code
startup:
player = GetLocalPlayerThing();
return;
# ..........
Activated:
victim = -1;
SetPulse(.33);
return;
# ..........
pulse:
victim = -1;
potential = FirstThingInView(player,
90, 8, 0x404); // Get the First thing in player's sight that is either
a player (0x400) or an actor (0x4)
while(potential != -1)
potential
= NextThingInView(); // Get the next thing if potential
was filtered out
if(victim != -1)
// If we have a victim targeted
return;
# ..........
deactivated:
If((HasLOS(player, victim)) &&
(victim != -1)) // Makes sure that victim is still in
sight, and that we actually have a victim to kill
SetPulse(0);
return;
end
That is the bare bones necessary for using the
target reticule as it is used in the force powers. By changing the
flags on FirstThingInView (thing type flags) you can make it select other
things besides players/actors (such as in force pull).
Good luck and happy editing,
[How was it? Feel free to e-mail
me at dragons_bane@hotmail.com
with any questions/comments/suggestions]
Thanks go out to ThreeDee for inspiring
this tutorial (those that are wondering if I could have made this thanks
any smaller.. no, believe me i tried :)) (j/k)
(note: the included cog is not commented)
# force_pull.cog
#
# Cog for the Target Reticule tutorial.
#
# Obsidian 11-14-99
int
potential local
int
victim
local
message activated
message deactivated
message pulse
{
if(
HasLOS(player, potential) && // If the player
can see potential
(potential != player) && // if the player isn't
potential
(VectorDist(GetThingPos(player), GetThingPos(potential)) <= MaxDist)
&& // Make sure potential is no farther then
MaxDist (5 JKUs)
!(GetThingFlags(potential) & 0x200) // *shrugs*
)
{
victim = potential; // If potential passes all the filters,
then make it the victim. Victim, however, will not be killed until
the deactivated: message is run.
}
}
{
jkSetTargetColors(1, 2, 3); // Set the colors for the
target circles
jkSetTarget(victim); // Set Victim as the target and
activates the circles
}
else
{
jkEndTarget(); // If we have no victim, then turn off
the circles/cancel the last target.
}
{
DamageThing(victim,
GetThingHealth(victim), 0x4, player); // Turns the lights
out on whoever is targeted
}
jkEndTarget();
// Turn circles off