AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Origin of bomb target (https://forums.alliedmods.net/showthread.php?t=24897)

c0rdawg 03-04-2006 13:02

Origin of bomb target
 
I've been looking around the forums but I don't really understand how to find the origins of both bomb targets on a de map in counter-strike. Could someone show me how?

VEN 03-04-2006 14:21

Yes. It's possible but please tell me the purpose so i probably would tell you the better solution.

Anyway here is the answer:
Code:
stock get_brush_entity_origin(ent, Float:orig[3])

c0rdawg 03-04-2006 20:50

I just need the origins of both bombsites. How would i use that to find both the bombsites, that will probably find one of them right? and if i use it again what can i do to stop it from finding the same bomb site again?

VEN 03-05-2006 03:27

You should undestand that bomb site isn't just a point.
Basically it's a box. Sometimes it's not just a single box.
So that method would be good only in few cases.
I can't tell you more because i need more detailed question.
If you want a good answer you should tell for what purpose you want to find the origin.

c0rdawg 03-05-2006 11:29

changing the bomb location to the other bomb site

VEN 03-05-2006 19:31

Quote:

Originally Posted by c0rdawg
changing the bomb location

C4 backpack (dropped bomb)?
Sometimes bomb target contain more than one entity box.
Anyway code would be tricky.

You need a lot of checks:
- how many bomb target entities map contain
- which entity belong to which bombsite
- is backpack is dropped
- is backpack belong to a bombsite
- trace destination origin to avoid bomb stuck
- maybe even more

Maybe i would write you an example later.

GHW_Chronic 03-05-2006 20:18

this wouldn't be hard at all to do. Here, I'll script this out, sigh

Code:
stock find_bomb_targets(Float:location1[3],Float:location2[3]) {     new ent1=find_ent_by_class(32,"bomb_target")     new ent2=find_ent_by_class(ent1,"bomb_target")     entity_get_vec(ent1,EV_VEC_origin,location1)     entity_get_vec(ent2,EV_VEC_origin,location2)     return PLUGIN_CONTINUE }

put that into your script and use this example to find the original bomb site locations.
Code:
new Float:bombsite_location1[3] new Float:bombsite_location2[3] find_bomb_targets(bombsite_location1,bombsite_location2)

and to move the bomb sites put this at the end of your script:

Code:
//Max number of new bombsites a player can create: #define MAX_BOMBSITES   3 //Global Variables: new bombsites_num=0 new Float:bombsite_location[MAX_BOMBSITES][3] new Float:bombsite_radius[MAX_BOMBSITES] stock handle_bombsites() {     for(new i1=1;i1<=32;i1++)     {         ifis_user_alive(i1))         {             cs_set_user_plant(i1,0)         }     }     for(new i=0;i<=bomsites_num - 1;i++)     {         find_ent_in_sphere(0,bombsite_location[i],bombsite_radius[i])         while(ent<=32 && ent)         {             if(is_user_alive(ent))             {                 cs_set_user_plant(i1,1)             }         }     }     return PLUGIN_CONTINUE }

And call that function every second or 2 with this in plugin_init:
Code:
set_task(2.0,"handle_bombsites",0,"",0,"b")

And then to fill in those global variables, make a command like this:

Code:
//in plugin_init     register_concmd("amx_fake_bombsite","make_fake_bombsite",ADMIN_LEVEL_HERE,"Makes a fake bombsite at a player's location: <nick> <size>")     register_concmd("amx_delete_fake_bombsite","delete_fake_bombsite",ADMIN_LEVEL_HERE,"Deletes a fake bombsite that you've already made: <#num or all>") //not in plugin_init public make_fake_bombsite(id,level,cid) {     if(!cmd_access(id,level,cid,3))     {         return PLUGIN_HANDLED     }     new arg1[32]     new target = cmd_target(id,arg1,4)     if(!target)     {         return PLUGIN_HANDLED     }     if(bombsites_num>=MAX_BOMBSITES)     {         console_print(id,"[AMXX] Max bomsites (MAX_BOMBSITES) have already been made. Delete some fake bombsites first.")         return PLUGIN_HANDLED     }     entity_get_vector(target,EV_VEC_origin,bombsite_location[bombsites_num])     new arg2[32]     read_argv(2,arg2,31)     bombsite_radius[bombsites_num]=100*str_to_float(arg2)     bombsites_num++     return PLUGIN_HANDLED }

make up your own delete bombsite command handler function.
make CVARs etc to your pleasure.
Requires Cstrike and Engine modules.

VEN 03-05-2006 20:43

(edit: this is for C4 backpack not the C4 bomb)

No, he mean transfer bomb to another bombsite
(edit: but maybe i understand him incorrect).

Anyway i done that (still needs a trace though)

Just use a stock function c4_backpack_to_another_bombsite()

Returned result:
Code:

-2: less than two bomb target entity on the map
-1: backpack not found or invalid backpack entity
 0: backpack outside bomb target
 1: success

Tested successfully on maps with 1/1 and 3/1 target entity per bombsite.

Code:
#include <amxmodx> #include <engine> new TARGET_CLASSNAME[] = "func_bomb_target" new BACKPACK_MODEL[] = "models/w_backpack.mdl" new bool:g_check_target new bool:g_not_enough_targets public plugin_init() {     register_plugin("Transfer C4 Backpack to Another Bombsite", "0.1", "VEN") //  register_concmd("test_stock", "test_stock")     new entid, count     while ((entid = find_ent_by_class(entid, TARGET_CLASSNAME)))         count++     if (count > 2)         g_check_target = true     else if (count < 2)         g_not_enough_targets = true } stock bool:is_inside_target(Float:point[3], entid) {     new Float:mins[3], Float:maxs[3]     entity_get_vector(entid, EV_VEC_mins, mins)     entity_get_vector(entid, EV_VEC_maxs, maxs)     for (new i = 0; i < 3; ++i) {         if (point[i] < mins[i] || point[i] > maxs[i])             return false     }     return true } stock c4_backpack_to_another_bombsite() {     if (g_not_enough_targets)         return -2 // less than two bomb target entity on the map     new backpack = find_ent_by_model(-1, "weaponbox", BACKPACK_MODEL)     if (!backpack || !is_valid_ent(backpack))         return -1 // backpack not found or invalid backpack entity     new Float:origin[3], entid = -1     entity_get_vector(backpack, EV_VEC_origin, origin)     while ((entid = find_ent_by_class(entid, TARGET_CLASSNAME)) && !is_inside_target(origin, entid)) {}     if (!entid)         return 0 // backpack outside bomb target     new another_target = -1     if (!g_check_target) {         while ((another_target = find_ent_by_class(another_target, TARGET_CLASSNAME))) {             if (another_target != entid)                 break         }     }     else {         new target1[32], target2[32]         entity_get_string(entid, EV_SZ_target, target1, 31)         while ((another_target = find_ent_by_class(another_target, TARGET_CLASSNAME))) {             entity_get_string(another_target, EV_SZ_target, target2, 31)             if (another_target != entid && !equal(target1, target2))                 break         }     }     get_brush_entity_origin(another_target, origin)     entity_set_origin(backpack, origin)     entity_set_vector(backpack, EV_VEC_velocity, Float:{0.0, 0.0, -999999.0})     return 1 // success } //public test_stock() { //  server_print("  %d", c4_backpack_to_another_bombsite()) //}

GHW_Chronic 03-05-2006 20:58

We were both wrong. After re-reading he wants it do that if u plant the bomb at A it will BOOM teleport to B bombsite. (Don't know why.)

This all gives me an extremely unique idea for a plugin.

c0rdawg 03-05-2006 21:53

yes thats what i want, when the bomb is planted, move it to the other bomb site. and thats why i didn't explicity say it so no one would take the idea, but i guess its too late...


All times are GMT -4. The time now is 20:19.

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