Post: [Script] Proximity Mine
08-05-2013, 06:53 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Hello NGU!
Here is my proximity mine.
It's basically a C4 with a proximity sensor.
You can use it just like a C4 or you can place and forget.
If an enemy gets to close it will detonate on its own killing anyone in its blast radius!!!Cool Troll

    ProximityMine()
{
self endon("death");
self endon("disconnect");
self.curWeapon=self getCurrentWeapon();
self giveWeapon("c4_mp");
self SetWeaponAmmoClip("c4_mp",1);
self switchToWeapon("c4_mp");
proxmine="c4_mp";
self iPrintln("Proximity Mine Equipped");
self waittill("grenade_fire",proxmine);
if(proxmine=="c4_mp")
{
proxmine waittill("activated");
me=self;
wait 1;
self iPrintln("Proximity Mine Activated");
proxmine thread sensor(me);
self switchToWeapon(self.curWeapon);
}
}
sensor(me)
{
while(1)
{
for(k=0;k<level.players.size;k++)
{
player=level.players[k];
if(distance(self.origin,player.origin)<160)
{
if(level.teamBased)
{
if(player.team==get_enemy_team(me.team))
{
self playsound("mp_ingame_summary");
wait .5;
self detonate();
}
}
else
{
if(me==player)
{
return 0;
}
else
{
self playsound("mp_ingame_summary");
wait .5;
self detonate();
}
}
}
}
wait .05;
}
}
Enjoy!Smile

The following 7 users say thank you to codybenti for this useful post:

Canuck_Modz, Devastation, forflah123, FutureOps, Shock_Mods, Sweet_Cheeba, worrorfight
08-06-2013, 12:52 AM #11
I'll get Skype sometime this week.

The following user thanked codybenti for this useful post:

FutureOps
08-06-2013, 01:11 AM #12
Nice release!

The following user thanked Canuck_Modz for this useful post:

codybenti
08-06-2013, 02:03 AM #13
FutureOps
Little One
Originally posted by codybenti View Post
I'll get Skype sometime this week.


Ok, when you do add me? Skype: FutureOps Modding
08-06-2013, 08:03 PM #14
Originally posted by codybenti View Post
Thanks Vader!!!
I've tried that originally but I couldn't get it to detonate in various positions.
Example: If I were to place the Prox. Mine on the ground using the trigger_radius method it would detonate but if I were to place it on a wall, ceiling or a strange angle it wouldn't go off.
I needed something that can spherically detect the enemy if you know what I mean.
if you have a better solution i would greatly appreciate it.:y:


Hmm, interesting... I'll give it some thought. I take you've looked in weapons.gsc and looked how they do the claymores, might help ?
08-07-2013, 02:00 AM #15
Originally posted by x View Post
Hmm, interesting... I'll give it some thought. I take you've looked in weapons.gsc and looked how they do the claymores, might help ?


I looked into the claymore awhile back and had the same problem. I'm guessing the trigger_radius function and the claymore detects like a flat circle. So anything above or below will not be detected. I don't know how else to explain it.
08-07-2013, 07:59 PM #16
Originally posted by codybenti View Post
I looked into the claymore awhile back and had the same problem. I'm guessing the trigger_radius function and the claymore detects like a flat circle. So anything above or below will not be detected. I don't know how else to explain it.

Yea, I get what you're saying, it's using a 2D plane rather than a sphere. There are ways of doing it, you can use quite complex calculations within the functions, like this is the one I used to pick a random position within a 2d circle

    getnewPos(origin, radius)
{
pos = origin + ((randomfloat(2)-1)*radius, (randomfloat(2)-1)*radius, 0);
while(distanceSquared(pos, origin) > radius*radius) pos = origin + ((randomfloat(2)-1)*radius, (randomfloat(2)-1)*radius, 0);
return pos;
}


but it's probably not worth the effort :P

I only mentioned it because I found the if(Distance) etc to be a bit unreliable for all players online with cod4. I had it in the ziplines and weapon box etc, When its spawned during the game sometimes it just won't work for other players.

The following user thanked x_DaftVader_x for this useful post:

codybenti
08-25-2013, 07:48 PM #17
Source Code
Bounty hunter
Originally posted by codybenti View Post
I looked into the claymore awhile back and had the same problem. I'm guessing the trigger_radius function and the claymore detects like a flat circle. So anything above or below will not be detected. I don't know how else to explain it.


you could try duplicating a 2d plane region on the z axis ( maybe a factor of 5 - 10 each). to get the trigger to work below surfaces, you just a negative factor. that should give you a 3d cube trigger. of course you could alter that to your liking
08-25-2013, 11:45 PM #18
Originally posted by Source
you could try duplicating a 2d plane region on the z axis ( maybe a factor of 5 - 10 each). to get the trigger to work below surfaces, you just a negative factor. that should give you a 3d cube trigger. of course you could alter that to your liking


I tried to create multiple trigger planes rotated in different angles but didn't work the way I wanted.
I'll definitely give your idea a try. Thanks.:y:
Just wondering when you'll release your source engine?!?!?:?:

The following user thanked codybenti for this useful post:

Sweet_Cheeba
08-25-2013, 11:46 PM #19
Source Code
Bounty hunter
Originally posted by codybenti View Post
I tried to create multiple trigger planes rotated in different angles but didn't work the way I wanted.
I'll definitely give your idea a try. Thanks.:y:
Just wondering when you'll release your source engine?!?!?:?:


Im releasing the base today

The following user thanked Source Code for this useful post:

codybenti

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo