Author Topic: Directional Jetting  (Read 1339 times)

I'm making a mod and I was wondering, since my mod uses a gravityless environment, if it would be possible to make a playertype with jets that boost you towards where you are looking instead of upward.

Is it possible?



You'll have to package the jet button function (I'm reasonably sure it's armor::ontrigger), then get the player's eye vector using method getEyeVector() then constantly add a velocity in that direction until the jet button is released

You'll have to package the jet button function (I'm reasonably sure it's armor::ontrigger), then get the player's eye vector using method getEyeVector() then constantly add a velocity in that direction until the jet button is released
Thanks! :D

I'm reasonably sure it's armor::ontrigger
Code: [Select]
package Blah
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
parent::onTrigger(%this, %player, %slot, %val);

if(%slot == 4)
{
echo("\c2Oh look! Someone is jetting.");
}
}
};
activatePackage(Blah);
« Last Edit: August 17, 2012, 12:14:28 PM by jes00 »

Wait

onTrigger is crouch


Talking bollocks again
« Last Edit: August 17, 2012, 12:30:43 PM by chrisbot6 »

Wait

onTrigger is crouch

... what?

Code: [Select]
package Blah
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
parent::onTrigger(%this, %player, %slot, %val);

if(%val == 4)
{
echo("\c2Oh look! Someone is jetting.");
}
}
};
activatePackage(Blah);

Don't you mean %slot == 4?

Code: [Select]
package Blah
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
parent::onTrigger(%this, %player, %slot, %val);

if(%val == 4)
{
echo("\c2Oh look! Someone is jetting.");
}
}
};
activatePackage(Blah);
Code: [Select]
package Blah
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
%r = parent::onTrigger(%this, %player, %slot, %val);
...
return %r;
}
};

Better because onTrigger may have to return something


You should use if(%slot == 4 && %val == 1)

Is there any circumstance where %val is not true or false? If not, just use if(%val)

Is there any circumstance where %val is not true or false?

Nope.

Code: [Select]
package directionaljet
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
parent::onTrigger(%this, %player, %slot, %val);

while(%slot == 4 && %val == 1)
{
%player.addVelocity(%player.getEyeVector());
}
}
};
activatePackage(directionaljet);
This crashes the game. I'm assuming this is because you can't put the eyevector right into addVelocity and expect it to work.

So, how do I change the eyeVector into a number that can be put there?

Code: [Select]
package directionaljet
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
parent::onTrigger(%this, %player, %slot, %val);

while(%slot == 4 && %val == 1)
{
%player.addVelocity(%player.getEyeVector());
}
}
};
activatePackage(directionaljet);
This crashes the game. I'm assuming this is because you can't put the eyevector right into addVelocity and expect it to work.

So, how do I change the eyeVector into a number that can be put there?

Lol, don't use a while loop. Just use a schedule, in a different function. I'll write something up, sec.

Edit: Here you go, try this:



Code: [Select]
package directionaljet
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
parent::onTrigger(%this, %player, %slot, %val);

if(%slot == 4 && %val == 1)
{
%player.directionalJet(1);
}
else
if(%slot == 4 && %val == 0)
{
%player.directionalJet(0);
}
}
};
activatePackage(directionaljet);

function player::directionalJet(%this,%bool)
{
if(%bool)
{
cancel(%this.djl);

//assuming this is correct.
%this.addVelocity(%player.getEyeVector());

%this.djl = %this.schedule(1,directionalJet,%bool);
}
else
{
return 0;
}
}
« Last Edit: August 17, 2012, 12:45:23 PM by elm »