Code: Select all
// custom player movement
script 501 enter
{
int angle, pitch, velx, vely, velz;
int velocity;
while(1)
{
angle = GetActorAngle(0);
pitch = GetActorPitch(0);
int buttons = GetPlayerInput(-1, INPUT_BUTTONS);
// on ground movement
if(buttons & (BT_FORWARD + BT_BACK + BT_MOVELEFT + BT_MOVERIGHT))
Thing_Stop(0);
if((buttons & (BT_FORWARD + BT_BACK)) && (buttons & (BT_MOVELEFT + BT_MOVERIGHT)))
velocity = sin(0.125) + playerspeedmult;
else
velocity = 1.0 + playerspeedmult;
// forward
if (buttons & BT_FORWARD)
{
SetActorVelocity(0, FixedMul(velocity, cos(angle)), FixedMul(velocity, sin(angle)), 0, TRUE, FALSE);
}
// backwards
if (buttons & BT_BACK)
{
SetActorVelocity(0, -FixedMul(velocity, cos(angle)), -FixedMul(velocity, sin(angle)), 0, TRUE, FALSE);
}
// left
if (buttons & BT_MOVELEFT)
{
SetActorVelocity(0, FixedMul(velocity, cos(angle + 0.25)), FixedMul(velocity, sin(angle + 0.25)), 0, TRUE, FALSE);
}
// right
if (buttons & BT_MOVERIGHT)
{
SetActorVelocity(0, FixedMul(velocity, cos(angle - 0.25)), FixedMul(velocity, sin(angle - 0.25)), 0, TRUE, FALSE);
}
delay(1);
}
}
Code: Select all
// check if player hits use key and has valid itemtopickup
script 667 enter
{
while(1)
{
// retrieve button input
int buttons = GetPlayerInput(-1, INPUT_BUTTONS);
// first, make sure there is an item under the crosshair and the item still exists
if (itemtopickup[PlayerNumber()] && ThingCount(T_NONE, itemtopickuptid[PlayerNumber()]))
{
// now press use to pick up item!
if ((buttons == BT_USE) && !pressonce[PlayerNumber()])
{
log(s: "You take the ", s: itemnames[itemtopickup[PlayerNumber()]]);
// now remove item from game world
Thing_Destroy(itemtopickuptid[PlayerNumber()]);
// prevent holding down the use key
pressonce[PlayerNumber()] = 1;
}
}
// reset pressonce if not pressing use
if ((buttons != BT_USE))
{
pressonce[PlayerNumber()] = 0;
}
delay(1);
}
}
I tried changing this line...
Code: Select all
// now press use to pick up item!
if ((buttons == BT_USE) && !pressonce[PlayerNumber()])
Code: Select all
// now press use to pick up item!
if ((buttons & BT_USE) && !pressonce[PlayerNumber()])
How do I solve this problem?