Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, Ayumi), 702 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Weapon animation #152809
09/08/07 17:35
09/08/07 17:35
Joined: Jan 2005
Posts: 30
F
fp Offline OP
Newbie
fp  Offline OP
Newbie
F

Joined: Jan 2005
Posts: 30
i have got an animated weapon model and the following script from AUM.
i want to add stand, shot, empty shot, reload, and change weapon animations to the script, but it does not work.

i have tried something like this:

ent_cycle("stand",my.skill46);
my.skill46 +=2*time;
my.skill46 %= 100;

it does not work, iīve always got error messages: empty pointer

Can anybody help me, please



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var trace_coords;
var weapon_height;
var current_ammo = 5;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

string hithole_tga = <hithole.tga>;
string target_mdl = <target.mdl>;
//string target_mdl = <crosshair_64x64.tga>;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

sound bullet_wav = <bullet.wav>;
sound gotweapon2_wav = <gotweapon2.wav>;
sound nobullets_wav = <nobullets.wav>;
sound gotammo_wav = <gotammo.wav>;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function fire_bullets(); // creates the bullets
function show_target(); // displays the (red) target model
function display_hithole(); // shows the hit hole bitmap

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

entity weapon2_ent
{
type = <pistole.mdl>; // weapon model
pan = 0; // weapon angle
x = 40; // 55 quants ahead of the view, play with this value
y = -15; // 22 quants towards the right side of the screen, play with this value
z = -22; // 22 quants below, play with this value
pan = 2; // weapon's pan angle (you can also use tilt and roll)

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

action players_weapon2
{

my.passable = on; // the weapon is made passable
while (player == null) {wait (1);} // we wait until the player is created
while (vec_dist (player.x, my.x) > 50) // we wait until the player comes closer than 50 quants
{
my.pan += 3 * time_step;
wait (1);
}
snd_play (gotweapon2_wav, 80, 0);
my.invisible = on;
weapon2_ent.visible = on;
sleep (1);
ent_remove (my);
}

starter use_weapon2()
{
proc_late(); // run this function at the end of the function scheduler list (elliminates jerkiness)

var player1_pos; // stores the initial position of the player
var player2_pos; // stores the position of the player after a frame
while (player == null) {wait (1);}
while (1)
{
vec_set (player1_pos.x, player.x); // store the initial player position
if (weapon2_ent.visible == on) // the weapon is visible?
{
weapon2_ent.scale_x =4;
weapon2_ent.scale_y =4;
weapon2_ent.scale_z =4;

vec_set(trace_coords.x, vector(10000, 0, 0)); // the weapon has a firing range of up to 10,000 quants
vec_rotate(trace_coords.x, camera.pan);
vec_add(trace_coords.x, camera.x);
if (c_trace(camera.x, trace_coords.x, ignore_me | ignore_passable) > 0) // hit something?
{
ent_create (target_mdl, target.x, show_target); // then show the target model

}
}
wait (1);
vec_set (player2_pos.x, player.x); // store player's position after 1 frame
if (vec_dist (player1_pos.x, player2_pos.x) != 0) // the player has moved during the last frame?
{
weapon_height += 30 * time_step; // then offset weapon_height (30 = weapon waving speed)
weapon2_ent.z += 0.03 * sin(weapon_height); // (0.03 = weapon waving amplitude)
}
}
}

function show_target()
{

my.passable = on; // the target model is passable
my.ambient = 100; // and should look bright enough
my.scale_x = min (6, vec_dist (my.x, camera.x) / 500); // play with 6 and with 500
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
wait (1);
ent_remove (my);
}

on_mouse_left = fire_bullets; // call this function when the left mouse button is pressed

function fire_bullets()
{
if (weapon2_ent.visible == off) {return;} // don't do anything if the player hasn't picked up the weapon yet
if (current_ammo > 0) // got ammo?
{
c_trace(camera.x, trace_coords.x, ignore_me | ignore_passable | activate_shoot);

if (you == null) // hit a wall?
{
ent_create (hithole_tga, target.x, display_hithole); // then create a bullet hit hole
}
snd_play (bullet_wav, 100, 0); // play the bullet sound at a volume of 100

current_ammo -= 1; // decrease the number of bullets
}
else // no ammo left?
{
snd_play (nobullets_wav, 100, 0); // then play the noammo.wav sound
}
}

function display_hithole()
{
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
my.passable = on; // the hit hole bitmap is passable
my.transparent = on; // and transparent
my.ambient = 50;
my.flare = on;
my.oriented = on; // the sprite is oriented
my.roll = random(360); // and has a random roll angle (looks nicer this way)
my.scale_x = 0.5; // we scale it down
my.scale_y = my.scale_x; // on the x and y axis
sleep (20); // show the hit hole for 20 seconds
ent_remove (my); // and then remove it
}

action ammo_pack
{
my.passable = on;
while (player == null) {wait (1);}
while (vec_dist (player.x, my.x) > 50)
{
my.pan += 3 * time_step;
wait (1);
}
snd_play (gotammo_wav, 80, 0);
my.invisible = on;
current_ammo += 20; // use your own value here
sleep (1);
ent_remove (my);
}

Re: Weapon animation [Re: fp] #152810
09/08/07 17:40
09/08/07 17:40
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Try weapon2_ent.frame += 1 * time;
It should play the animation
And you can limit it to a certain number of frames with if statements or while loops.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Weapon animation [Re: EpsiloN] #152811
09/08/07 18:14
09/08/07 18:14
Joined: Jan 2005
Posts: 30
F
fp Offline OP
Newbie
fp  Offline OP
Newbie
F

Joined: Jan 2005
Posts: 30
Thank you EpsiloN
yes, the animation has been played, but how to limit it to a certain number of frames. i didnīt get that, sorry

Re: Weapon animation [Re: fp] #152812
09/09/07 15:48
09/09/07 15:48
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
add states.
if weapon_state == 1
weapon.frame += 1 * time;
if(weapon.frame > x) { weapon_frame = x; }
if(weapon.frame < y) { weapon_frame = y; }

where x is the last frame from the animation (just a section of the whole animation) and y is the first.
do that for every section of the animation. if weapon_state == 2...3...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1