AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Creating Mines.. (https://forums.alliedmods.net/showthread.php?t=12962)

BioHazardousWaste 04-30-2005 00:11

Creating Mines..
 
Hey guys, I know i've been posting like a nub tonight :oops: , but i've been trying a bunch of new things, and there is still a lot I don't know :(

My latest is trying to make a landmine. I made an entity, did a bunch of code to check radius and whatnot, then got to the detonate mine procedure:

Code:
public DetonateMine(ident[],TaskID) {     if(PlayerMinePlanted[id]) //avoid multiple explosions of the same mine     {         new id = str_to_num(ident)         PlayerMinePlanted[id] = 0         new Float:MineLocation[3]         MineLocation[0] = PlayerMineOrigin[Mine][0]         MineLocation[1] = PlayerMineOrigin[Mine][1]         MineLocation[2] = PlayerMineOrigin[Mine][2]                 RadiusDamage(MineLocation, PlayerLevel[id], PlayerLevel[id])     } }

Seems simple enough, but is there a way to check if anyone in that radius was killed so that I can give the killer appropriate experience and frag count?

KCE 04-30-2005 00:23

What mod's this for?

Quote:

Falloff damage from a grenade or other explosive

Code:

stock Float:dfalloff_damage(Float:dist, Float:maxdist, Float:maxdamage)
return maxdamage * (1.0 - (dist / maxdist))


For damage radius, try something like this:
Code:
for (new i=1;i<=g_maxplayers;++i) {     if (is_valid_ent(i))     {         //get distance between the player damaged and the source of the damage, then check if in damage radius         if (get_entity_distance(dmginflictor,i) <= DMG_RADIUS)          {             //do damage, exp, score,...         }     } }

There's some more checks you need to do also, like check if player is alive and connected and also check the teams.

BioHazardousWaste 04-30-2005 00:29

I'm making a new matrix mod... but is it possible to check if anyone in that radius was killed so that I can give the killer appropriate experience and frag count?

Ced 04-30-2005 00:31

first of all the id in the playermineplanted array will b undefined and i don't think radius damage works anymore. Do
Code:
for ( new i = 0; i < g_MAXPLAYERS; i++ ) {    if ( is_user_alive( i ) {       new Float:Origin1[3], Float:Origin2[3], Float:fDistance       entity_get_vector( i, EV_VEC_origin, Origin1 )       entity_get_vector( entity, EV_VEC_origin, Origin2 )       fDistance = vector_distance( Origin1, Origin2 )       if (  fDistance <= MINERADIUS ) {          //whatever       }    } }
And u would have to define an entity, mine radius, and get the maxplayers of the time

BioHazardousWaste 04-30-2005 00:37

ok... so are you telling me I can't make an array of entities?

Ced 04-30-2005 00:38

um, u might b able to get the players origin in the death event, if not, u can get the origin from the damage event when the players health is <= 0 and compare it to your mine and check the distance to see if its in the radius

Ced 04-30-2005 00:39

no, i said id would be undefined since u have ident and there is not an id, lol. Btw, why don't u just make ident id and why do u have the task id? I would define all my taskid's.
Code:
#define TASK_CHECKMINE 100

BioHazardousWaste 04-30-2005 00:40

it's iffy ced.. the person could have been shot while within the radius (unlikely, but possible) I think KCE has got the idea, i'm going to try to implement that... but seriously, how do you make an array of entities?

Ced 04-30-2005 00:42

thats why u make sure they r dead first by checking their health, heh
Depends how u want to save your entities. U could do it like this
Code:
#define MAXPLAYERS 33 #define MAXMINES 5 new g_Mines[MAXPLAYERS][MAXMINES]

That could save them if u were looking by each individual, if u just want 1 big list, just make a normal array like KCE did

KCE 04-30-2005 00:46

Quote:

Originally Posted by BioHazardousWaste
it's iffy ced.. the person could have been shot while within the radius (unlikely, but possible) I think KCE has got the idea, i'm going to try to implement that... but seriously, how do you make an array of entities?

There's plenty of ways to do this. Look through some of the other programs.

well to do it for all entities in the game...

Code:
new i for (i = 1; i <= entity_count(); i++) { ...

What do you mean an array of entities?

hmm...I had this problem once before...forgot how I solved it...see if this'll work

Code:
new entities_list[]


All times are GMT -4. The time now is 16:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.