1 registered members (AndrewAMD),
677
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
after mouse_left 0.5 second wait??
#411693
11/18/12 21:22
11/18/12 21:22
|
Joined: Nov 2012
Posts: 32
thorus
OP
Newbie
|
OP
Newbie
Joined: Nov 2012
Posts: 32
|
hey guys, i realy like to know how i can do a pause after left click couse i have the action swing axe on left click and everytime i press is do it so i can make 20x attacks in 1 second, please can u help me to get a wait around 0.5 second after i pressed mouse_left till i can do it again? hope u understand my english... thanks!!
var player_weapon = 0;
var player_got_axe = 0;
STRING* key_weapon1 = "1";
STRING* hithole_tga = "hithole.tga"; // the hit hole bitmap
function display_hithole(); // shows the hit hole bitmap
function axt_schlaege(); // creates the bullets
//SOUND* axe_hit_wav = "axe_hit.wav"; // axe sound
//SOUND* gotweapon_wav = "gotweapon.wav"; // this sound is played when the player gets a new weapon
ENTITY* player_axeent = // the axe is created as an entity so that its model doesn't penetrate the walls
{
type = "chopper.mdl"; // use your own weapon model here
x = 50; // 50 quants ahead of the view, play with this value
y = -20; // 25 quants towards the right side of the screen, play with this value
z = -20; // 30 quants below, play with this value
pan = 210; // axe pan angle (set its tilt, roll, etc if you want to)
tilt = -5;
roll =90;
scale_x = 0.5; // spieler größe ändern
scale_y = 0.7; // spieler größe ändern
scale_z = 0.5; // spieler größe ändern
layer = 20;
}
action player_axe() // attach this action to your axe model
{
set (my, PASSABLE); // don't hinder player's movement
while (!player) {wait (1);} // wait until the player is loaded
while (vec_dist (player.x, my.x) > 80 || !key_pressed(18)) // wait until the player has come close to the axe and key e pressed
wait (1);
//snd_play(gotweapon_wav, 80, 0); // play the "got weapon" sound
player_got_axe = 1; // got the axe
wait (-0.5); // wait for 0.5 seconds
player_weapon = 1; // give the player the axe (show the axe entity on the screen)
ent_remove (my); // and then remove the axe from the ground
}
function player_weapons_startup()
{
var bob_factor = 0;
VECTOR player1_pos, player2_pos, trace_coords;
on_mouse_left = axt_schlaege; // call this function when the left mouse button is pressed
while (!player) {wait (1);} // wait until the player model is loaded
proc_mode = PROC_LATE; // run this function at the end of the function scheduler list (eliminates jerkiness)
while (1)
{
vec_set (player1_pos.x, player.x); // store the current position of the player
wait (1); // wait for one frame
vec_set (player2_pos.x, player.x); // get the new position of the player after a frame
if (vec_dist(player2_pos.x, player1_pos.x) > 0 && (key_shift)) // the player has moved during the last frame?
{
bob_factor += 25 * time_step; // then increase bob_factor
if (player_axeent) // if the pistol was picked up
player_axeent.z += 0.3 * sin(bob_factor); // move the axe up and down as the player moves in the level
player_axeent.x += 0.3 * sin(bob_factor);
player_axeent.y += 0.3 * sin(bob_factor);
}
if (vec_dist(player2_pos.x, player1_pos.x) > 0 && (!key_shift)) // the player has moved during the last frame?
{
bob_factor += 25 * time_step; // then increase bob_factor
if (player_axeent) // if the pistol was picked up
player_axeent.z += 0.07 * sin(bob_factor); // move the axe up and down as the player moves in the level
player_axeent.x += 0.07 * sin(bob_factor);
player_axeent.y += 0.07 * sin(bob_factor);
}
// the key for the first weapon was pressed and we've got the axe right now?
if (player_weapon == 0) // no weapon is selected?
{
player_axeent.flags2 &= ~SHOW;
}
if (player_weapon == 1)
{
player_axeent.flags2 |= SHOW;
}
}
}
var attack_perc = 0;
action axt_schlag()
{
if (mouse_left ==1)
{
wait(0.5);
}
if (attack_perc <=1 )
{
attack_perc += 51;
player_axeent.tilt +=60;
}
wait(-0.5);
if (attack_perc >=1 )
{
attack_perc -= 51;
player_axeent.tilt -=60;
}
}
function axt_schlaege()
{
if (lebensenergie <= 0) return;
VECTOR trace_coords;
while (mouse_left)
{
switch(player_weapon)
{
case 0:
return;
case 1:
axt_schlag();
wait(1);
return;
}
wait (1);
}
}
function display_hithole() // this tiny function pust a hit hole bitmap on the walls
{
vec_to_angle (my.pan, normal); // orient the hit hole sprite correctly
vec_add(my.x, normal.x); // move the sprite a bit away from the wall
set (my, PASSABLE); // the hit hole bitmap is passable
set (my, TRANSLUCENT); // and transparent
my.ambient = 30;
my.roll = random(360); // has a random roll angle
my.scale_x = 1; // we scale it down
my.scale_y = my.scale_x; // on the x and y axis
wait (-20); // show the hit hole bitmap for 20 seconds
ent_remove (my); // and then remove it
}
Last edited by JustSid; 11/19/12 08:46. Reason: Added code tags. Sadly it doesn't make it easier to read because there is zero indentation
|
|
|
Re: after mouse_left 0.5 second wait??
[Re: thorus]
#411694
11/18/12 21:35
11/18/12 21:35
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Waiting is pretty easy. You can use the wait function for that: http://www.conitec.net/beta/acrt-wait.htmPassing negative values to wait will wait the absolute value in seconds. Passing positive values to wait will wait the given number of frames.
wait(-0.5); // waits half a second.
wait(13); // Waits for 13 frames.
Please use code tags when posting code.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: after mouse_left 0.5 second wait??
[Re: thorus]
#411750
11/19/12 14:50
11/19/12 14:50
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
no doesnt work the problem is, when i hit the mousebutton fast ~20x the axe tilt go 60...120...180...and so on, when i wait the -0.5 seconds it tilt go back as i should do.. but it should not be able to do this .. I said ON_mouse_left, you can give it a function pointer and de-assign the function in the function. Then wait 0.5 and re-assign the function. Please look at the manual if you dont understand this..
|
|
|
|