Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, TedMar, AndrewAMD), 986 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
First person sword script #182353
02/06/08 14:36
02/06/08 14:36
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi, as the title says I'm looking for a first person sword script.
Thanks

Re: First person sword script [Re: PadMalcom] #182354
02/06/08 16:16
02/06/08 16:16
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I don't have any but a fp-sword-script is not that hard to realise.
What you need is an animate arm+sword model and two vertex in that sword.
Now you put that model as world-model in front of the player (make it passable).
When the player hits the attack button you play the animation and trace from the sword-base to the sword tip to "cut" your opponent.
(Thats at least one methode)

Re: First person sword script [Re: Xarthor] #182355
02/07/08 05:34
02/07/08 05:34
Joined: Mar 2007
Posts: 75
M
Metal_Man Offline
Junior Member
Metal_Man  Offline
Junior Member
M

Joined: Mar 2007
Posts: 75
you could also use a view-model for the sword and perform a c-scan in front of the player to attack

Re: First person sword script [Re: Metal_Man] #182356
02/07/08 08:01
02/07/08 08:01
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
here is me code i am using:
Code:


entity player_weapon
{
type = <knife_arm.mdl>;
layer = 0;
view = camera;
albedo = 50;
ambient = -100;
x = 32;
y = -20;
z = -19;
pan = 10;
tilt = 10;
roll = -10;
}

function player_fight()
{
var animdist;
var mouse_left_pressed = 0;
var rdm;
while(1)
{
if(mouse_left && mouse_mode == 0)
{

temp.pan = 10;
temp.tilt = 10;
temp.z = 128;

indicator = _click;
scan_entity(camera.x,temp);


//snd_play(click_wav,100,0);

if(item_player_weapon && mouse_left && animdist == 0)
{

vec_set(temp.x,nullvector);
temp.x = 48;
vec_rotate(temp.x,camera.pan);
vec_add(temp.x,player.x);

trace_mode = ignore_me + ignore_models;
result = trace(my.x,temp.x);

if(result != 0)
{
snd_play(hit_wav,10,0);
}else{
snd_play(swing_wav,50,0);
}

temp.pan = 90;
temp.tilt = 90;
temp.z = 96;

damage = player_dmg;
scan_entity(camera.x,temp);

rdm += 1;//int(random(2));
if(rdm%2 == 0)
{
while(animdist < 100)
{
ent_animate(player_weapon,"attack_a",animdist,anm_cycle);
animdist += 10 * time;
wait(1);
}

ent_animate(player_weapon,"attack_a",100,anm_cycle);
animdist = 0;
}
if(rdm%2 == 1)
{
while(animdist < 100)
{
ent_animate(player_weapon,"attack_b",animdist,anm_cycle);
animdist += 10 * time;
wait(1);
}

ent_animate(player_weapon,"attack_b",100,anm_cycle);
animdist = 0;
}

}
while(mouse_left){wait(1);}
}
wait(1);
}
}


its alittlebit long but works fine^^ (it use two different attack-animations)

Re: First person sword script [Re: kasimir] #182357
02/07/08 09:34
02/07/08 09:34
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Great I will have a try, tranks

Re: First person sword script [Re: PadMalcom] #182358
02/07/08 11:38
02/07/08 11:38
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
ups there is a lot of stuff in this code - i simplyfied him:
Code:


function player_fight()
{
var animdist;
var rdm;

while(1)
{
if(mouse_left && mouse_mode == 0)
{

vec_set(temp.x,nullvector);
temp.x = 48; //sword range
vec_rotate(temp.x,camera.pan);
vec_add(temp.x,player.x);

trace_mode = ignore_me + ignore_models;
result = trace(my.x,temp.x);

if(result != 0)
{
snd_play(hit_wav,10,0); //sound for hitting a wall
}else{
snd_play(swing_wav,50,0);
}


//use this if you want area damage or use activate_shoot in trace above
temp.pan = 90;
temp.tilt = 90;
temp.z = 96;

damage = player_dmg; //use your own var^^
scan_entity(camera.x,temp);


animdist = 0;

rdm += 1;
if(rdm%2 == 0)
{
while(animdist < 100)
{
ent_animate(player_weapon,"attack_a",animdist,anm_cycle);
animdist += 10 * time;
wait(1);
}
}
if(rdm%2 == 1)
{
while(animdist < 100)
{
ent_animate(player_weapon,"attack_b",animdist,anm_cycle);
animdist += 10 * time;
wait(1);
}
}

while(mouse_left){wait(1);} //delte this if you want to have a cycle - repeat swinging while pressing mouse
}

wait(1);
}
}



Re: First person sword script [Re: kasimir] #182359
02/12/08 16:46
02/12/08 16:46
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
if you want - i have uploaded an simply inventory and weapon - code:

Filefront - itssimplyme


Moderated by  adoado, checkbutton, mk_1, Perro 

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