land mines
by Dracola · 07/04/2005 (2:06 pm) · 34 comments
Download Code File
the first way I though to make a land mine was to make a projectile that wouldn't explode on collision with the ground but after a while of investigating I thought it might be worth it to do it all in script. So I'll explain what happens.
1. you carry a mine in your hand as a weapon.
2. you "throw" a projectile that looks exactly the same as the weapon.
3. okay now it gets kind of... unrealistic but I don't think anybody will notice in the game. The projectile (mine) hits the ground and goes away, but makes an item replicate that lies half in the ground and waits.
4. The unwary accidentally steps on the land mine. Since its an Item I was having trouble with radius damage and explosions so I decided that I would make a projectile that would do that all for me. So somebody steps on it and it generates a projectile and deletes itself, the projectile explodes making it look like the mine blew up.
I attached a file called mine.cs put that in Starter.fps/server/scripts
I also attached a folder named mine with the .dts files in it put that in starter.fps/data/shapes I have a file structure layed out that will help.
Open Starter.fps/server/scripts/game.cs
under all the exec's at the top of the file put
that runs mine.cs
now we need the player to be able to carry mines go into player.cs and under all the lines that look like this put.
now go into starter.fps/client/config.cs
and put this in
you obviously should replace the next # with whichever number is next. You could do something like this in starter.fps/client/scripts/default.bind.cs but I don't think it matters
If you want to start with mines than go into game.cs again and near the bottom put
next to all the functions that look like that. You need to delete the old
%player.mountImage(?Image,0);
or else you'll be mounting two things and that doesn't work... I don't think.
Now save everything!
go into your game. To make mines press f11 then f4 and select shapes/weapons/mine or ammo/mine or if you want to make a planted bomb go to shapes/mines/mine2
known issues:
Model and animation is very bad don't use it.
Updates
these were not in the original tutorial.
this is the inc score fix. I have updated the zip so you could replace the mine.cs in that with your old one and that would fix it if you don't want to do that you can go to about line 880 and
under rotate = false;
add
and line 826 and
under initialposition = %pos;
add
that should fix it if not let me know. The new zip also contains the ms3d version of the mine.
I also changed the mines velInheritFactor to 1.0
I also made the mine throw at the correct time in the (slow) animations.
the first way I though to make a land mine was to make a projectile that wouldn't explode on collision with the ground but after a while of investigating I thought it might be worth it to do it all in script. So I'll explain what happens.
1. you carry a mine in your hand as a weapon.
2. you "throw" a projectile that looks exactly the same as the weapon.
3. okay now it gets kind of... unrealistic but I don't think anybody will notice in the game. The projectile (mine) hits the ground and goes away, but makes an item replicate that lies half in the ground and waits.
4. The unwary accidentally steps on the land mine. Since its an Item I was having trouble with radius damage and explosions so I decided that I would make a projectile that would do that all for me. So somebody steps on it and it generates a projectile and deletes itself, the projectile explodes making it look like the mine blew up.
I attached a file called mine.cs put that in Starter.fps/server/scripts
I also attached a folder named mine with the .dts files in it put that in starter.fps/data/shapes I have a file structure layed out that will help.
Open Starter.fps/server/scripts/game.cs
under all the exec's at the top of the file put
Exec("./mine.cs");that runs mine.cs
now we need the player to be able to carry mines go into player.cs and under all the lines that look like this put.
maxInv[mine] = 1; maxInv[mineammo] = 10;
now go into starter.fps/client/config.cs
and put this in
moveMap.bindCmd(keyboard, "the next #", "commandToServer(\'use\',\"mine\");", "");
you obviously should replace the next # with whichever number is next. You could do something like this in starter.fps/client/scripts/default.bind.cs but I don't think it matters
If you want to start with mines than go into game.cs again and near the bottom put
%player.setInventory(mine,1); %player.setInventory(mineammo,5); %player.mountImage(mineImage,0);
next to all the functions that look like that. You need to delete the old
%player.mountImage(?Image,0);
or else you'll be mounting two things and that doesn't work... I don't think.
Now save everything!
go into your game. To make mines press f11 then f4 and select shapes/weapons/mine or ammo/mine or if you want to make a planted bomb go to shapes/mines/mine2
known issues:
Model and animation is very bad don't use it.
Updates
these were not in the original tutorial.
this is the inc score fix. I have updated the zip so you could replace the mine.cs in that with your old one and that would fix it if you don't want to do that you can go to about line 880 and
under rotate = false;
add
client = %obj.client;
and line 826 and
under initialposition = %pos;
add
client = %obj.client;
that should fix it if not let me know. The new zip also contains the ms3d version of the mine.
I also changed the mines velInheritFactor to 1.0
I also made the mine throw at the correct time in the (slow) animations.
About the author
Recent Blogs
• Lots of Buildings (with lots of pics)• TimerBar
• AI cinematics
• Grenade Code
• Dual Wielding
#2
Find some peace and serenity in the land of the rising Sun! My most favorite place away from the US.
07/05/2005 (7:21 am)
Thanks, Treb! Had a lot of what I'm looking for in the feature list above...I already have some questions; I'll investigate this resource today and they'll probably be answered...;).Find some peace and serenity in the land of the rising Sun! My most favorite place away from the US.
#3
07/05/2005 (11:20 am)
Very cool resource, perfect for a project I'm working on, hopefully can give you some feedback :)
#4
07/06/2005 (10:31 am)
Anyone have any ideas on how to make a collision radius around the mine? It seems the collision works just on actually hitting the dts object, but I would like to spread the collision area to be larger than the actual object.
#5
07/06/2005 (11:25 am)
you could use a trigger ?
#6
07/06/2005 (7:05 pm)
My mines are ending up hanging in mid-air... is anyone else having this problem?
#7
07/07/2005 (3:50 pm)
Excellent work!
#8
07/07/2005 (9:24 pm)
if you threw the mine and it hit you in midair it would make a item there items have no physics yet. True I could use a trigger I will investigate that when I get home. I am glad it helps.
#9
1. You can only make the mine blow when actually hitting the object, it would be nice to have a proximity when it blows.
2. When you die from a mine, the mine is considered to be the thing which kills the player. Thus giving this error:
server/scripts/game.cs (299): Unable to find object: '' attempting to call function 'incScore'
The mine somehow needs to give a kill point to the player that layed the mine. This is also needed so if you walk over your own mine that it is seen as a suicide.
I am thinking about how to accomplish these things and will post if I figure anything good. If anyone else has any ideas, please post!
07/08/2005 (4:55 am)
I love this resourse, and am trying to improve on it. Two things that I have noticed.1. You can only make the mine blow when actually hitting the object, it would be nice to have a proximity when it blows.
2. When you die from a mine, the mine is considered to be the thing which kills the player. Thus giving this error:
server/scripts/game.cs (299): Unable to find object: '' attempting to call function 'incScore'
The mine somehow needs to give a kill point to the player that layed the mine. This is also needed so if you walk over your own mine that it is seen as a suicide.
I am thinking about how to accomplish these things and will post if I figure anything good. If anyone else has any ideas, please post!
#10
For the proximity mines, search the forums. There are a few examples available (ex: using triggers, doing periodic checks, etc.)
07/08/2005 (10:29 am)
@ Geo: for Q2, I got around this by adding an "originator" field to the datablock, set this to the player id when they use the mine, and modified a few functions in game.cs to use this field if present.For the proximity mines, search the forums. There are a few examples available (ex: using triggers, doing periodic checks, etc.)
#11
07/10/2005 (8:59 pm)
oh yeah I forgot to write something about the score error try Jerries sollution. Proximity mines would require a trigger. Pretty much make a trigger also when the mine projectile hits the ground. and make the trigger set off the mine that might be harder though.
#12
07/13/2005 (6:00 am)
thanks treb, just what i needed
#13
07/15/2005 (6:01 pm)
hmm about the proximity mines you could probably make the collision mesh bigger. Did I include the ms3d files if not I can send them to whoever wants them.
#14
07/15/2005 (7:16 pm)
I would like to check em out... georules(at)gmail.com
#15
What I mean is particles (parts of the explosion) would fly out in a circular or spherical pattern and do damage to players, vehicles, buildings, etc.
Thoughts?
07/16/2005 (1:05 pm)
anyone know how to do a frag mine? What I mean is particles (parts of the explosion) would fly out in a circular or spherical pattern and do damage to players, vehicles, buildings, etc.
Thoughts?
#16
oh about the emailing I will have to wait till I get home for that because I don't have the ms3d files over in Japan. about 1 week left. sorry.
07/19/2005 (10:40 am)
well you would probably make the projectile make many more projectiles upon collision that would be given random vectors I might do that when I get home.oh about the emailing I will have to wait till I get home for that because I don't have the ms3d files over in Japan. about 1 week left. sorry.
#17
07/26/2005 (10:41 am)
Man, this resource rocks!
#18
edit: oh yes and I'll also update it so the inc score issue is gone.
all updated!
07/28/2005 (12:42 pm)
okay I'm working on the frag grenade and I'll update this resource to contain the ms3d file. edit: oh yes and I'll also update it so the inc score issue is gone.
all updated!
#19
07/28/2005 (12:58 pm)
Sounds great Master Treb! I'm looking forward to it! Thanks!
#20
07/29/2005 (11:26 am)
Okay I'm back on track with the frag I think recent code I made should work for a spherical throwing of shrapnel I'll work more on it 
Torque Owner Dracola