Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, AndrewAMD), 1,640 guests, and 13 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
[Newton] Weapon bullet system #50452
07/28/05 13:03
07/28/05 13:03
Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Marcio Esper Offline OP
Senior Member
Marcio Esper  Offline OP
Senior Member

Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Hi,

One guy ask in the forum about how to make a weapon system to use with newton vehicle.

I put the code here to help more people.

You need to the code work

1 - the newton's wdl includes in your script
2 - a weapon model to assign the code
3 - a bullet model (cam be any thing.)

You need change the code vertex number to your vertex model number.

If you use it, not forget to send me a gift

I hope you enjoy,

the code

Code:

//bullet code by Marcio Esper
//using NGD 1.51
// you need a gun entitie to set the bullet origen
//you need a bullet model
//examine the code, some things you can delet if i forget in the code


entity* projetil;

var destino[6];
var origem[6];
var final [6];
var newtonImpulseRecord[8];

function baladata(material){

var collisionType;
var body;
dll_handle = newtonHandle;

body = NewtonGetBody (my);
collisionType = my.collision_sph_box;
body = NewtonAddMapEntity (my, collisionType);
NewtonSetBodyMass (body, my.mass);
NewtonSetBodyLinearDamp (body, my.linear_drag);
NewtonSetBodyAngularDamp (body, my.angular_drag_x, my.angular_drag_y, my.angular_drag_z);
NewtonSetBodyForceAndTorque (body, ApplyGravityForceEvent);
NewtonSetBodyMaterial (body, material);
NewtonSetBodyActiveState (body, my.start_active);
vec_for_vertex(destino, torres, 130);
vec_for_vertex(origem, torres, 78);
//vec_diff (final,destino,origem); not need this


//ENT_playSOUND (torres, bum, 100); - uncoment and make a sound if you need it


// gun end of tuble point
newtonImpulseRecord[0] = destino.x;
newtonImpulseRecord[1] = destino.y;
newtonImpulseRecord[2] = destino.z;

// origin of bullet (use to determone the direction of the impulse)
newtonImpulseRecord[3] = origem.x;
newtonImpulseRecord[4] = origem.y;
newtonImpulseRecord[5] = origem.z;

// copy the bullet mass - change it to more or less distance and damage
newtonImpulseRecord[6] = 10000;

// copy the bullet speed - change like above
newtonImpulseRecord[7] = 900;
NewtonBodyAddImpulse (body, newtonImpulseRecord);

}



action bala{

projetil =me;
my.red=255;
my.green=200;
my.blue=100;
my.lightrange = 400;
my.light=on;
my.mass =10;
my.health = 20;
my.shape_factor = 0.9;
my.start_active=1;
baladata(wood_material);

}

Function tiro(){

vec_for_vertex(temp, torres, 130); //get temp the position of vertex
ent_create("balabh.mdl", temp, bala); //you need a bullet model, in this case I use balabh.mdl, you can use a little box


}



on_mouse_left = tiro();




Sorry for the terrible English,

best regards,

Marcio

Re: [Newton] Weapon bullet system [Re: Marcio Esper] #50453
07/28/05 18:21
07/28/05 18:21
Joined: Jun 2005
Posts: 1,001
Pennsylvania, USA
FoxZero Offline
Serious User
FoxZero  Offline
Serious User

Joined: Jun 2005
Posts: 1,001
Pennsylvania, USA
I'm glad you posted this in this forum. It fires flawlessly but one question, is there a way for it to actually damage objects? Newton says objects take damage from impacts, but mine don't.


Check out my site http://foxzero.net
My band's website
http://wolf-hybrid.net

R.I.P. Dave Williams
Re: [Newton] Weapon bullet system [Re: FoxZero] #50454
07/28/05 19:02
07/28/05 19:02
Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Marcio Esper Offline OP
Senior Member
Marcio Esper  Offline OP
Senior Member

Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
You can make it change the newtonScript2.wdl template.



best regards,

Marcio

Re: [Newton] Weapon bullet system [Re: Marcio Esper] #50455
07/29/05 00:30
07/29/05 00:30
Joined: Jun 2005
Posts: 1,001
Pennsylvania, USA
FoxZero Offline
Serious User
FoxZero  Offline
Serious User

Joined: Jun 2005
Posts: 1,001
Pennsylvania, USA
Ok I'll give it a try. Thanks again for the code.


Check out my site http://foxzero.net
My band's website
http://wolf-hybrid.net

R.I.P. Dave Williams

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