I got this far though, which is pretty cool.
Only thing is...it isn't working right.
Basically it should do the following:
1) Toggle ON/OFF
2) When ON, and if the player has enough mana, it should pull the victim's current weapon and add it to the player inventory.
3) It should Subract the mana cost as defined in symbols.
4) It should be EXACTLY like normal pull, except it will "Automatically" activate.
5) It shouldn't activate too often, only if the player has enough mana.
So ANY help in this regard would be great.
Thanks all.
ReT
Code:
# Jedi Knight Cog Script
#
# FORCE_AUTOPULL.COG
#
# Auto Pull
# Automatically pulls current weapon from victim in POV
# if the player has enough force mana.
symbols
thing player
message activated
message pulse
sound pullSound=ForcePull01.WAV local
int victim local
int potential local
int throwThing local
flex cost=50.0 local
flex mana local
flex dot local
flex maxDot local
int rank local
int type local
int retval=0 local
vector dir local
end
# =======================================================================================
code
activated:
if(toggle)
{
Print("Auto Pull OFF");
SetPulse(0);
toggle = 0;
}
else
{
Print("Auto Pull ON");
SetPulse(0.1);
toggle = 1;
}
Return;
# ----------------------------------------------------------------------------------------
pulse:
targetfound = -1;
maxDot = 0;
target = FirstThingInView(player, 90, 90, 0x404);
while(target != -1)
{
if(HasLOS(player, target) && (target != player))
{
dot = ThingViewDot(player, target);
if(dot > maxDot)
{
targetfound = target;
maxDot = dot;
}
}
target = NextThingInView();
}
if(targetfound != -1)
{
mana = GetInv(player, 14);
if(mana >= cost)
{
// Let's do this
ChangeInv(player, 14, -cost);
jkSetTargetColors(18, 19, 20);
jkSetTarget(targetfound);
PlayMode(player, 24);
PlaySoundThing(pullSound, player, 1.0, -1, -1, 0x80);
throwThing = SkillTarget(targetfound, player, 24, 0);
SetTimerEx(1.5, 1, throwThing, 0);
SetTimerEx(3.5, 2, throwThing, 0);
SetTimerEx(3.6, 2, throwThing, 0);
}
if(IsMulti())
{
SetTimerEx(4.0, 3, throwThing, 0);
SetTimerEx(4.1, 4, throwThing, 0);
}
ClearPhysicsFlags(throwThing, 0x1);
dir = VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(throwThing))), 30);
ApplyForce(throwThing, dir);
}
Return;
endOnly thing is...it isn't working right.
Basically it should do the following:
1) Toggle ON/OFF
2) When ON, and if the player has enough mana, it should pull the victim's current weapon and add it to the player inventory.
3) It should Subract the mana cost as defined in symbols.
4) It should be EXACTLY like normal pull, except it will "Automatically" activate.
5) It shouldn't activate too often, only if the player has enough mana.
So ANY help in this regard would be great.
Thanks all.
ReT