Raised This Month: $32 Target: $400
 8% 

Auto attracting enemies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sanvaquero
Junior Member
Join Date: Feb 2019
Old 02-14-2019 , 09:09   Auto attracting enemies
Reply With Quote #1

Hello.
I would like to ask how should looks a code of automatic attracting opponents located in a particular radius.
sanvaquero is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-14-2019 , 09:19   Re: Auto attracting enemies
Reply With Quote #2

Check whatever you want in a radius and do whatever you want.
__________________
eat1k is offline
sanvaquero
Junior Member
Join Date: Feb 2019
Old 02-15-2019 , 09:11   Re: Auto attracting enemies
Reply With Quote #3

Maybe I'll explain it differently, one player is a zombie and the other is a human. If a man is at a certain distance from the zombies, he will be attracted to it with a certain strength.
sanvaquero is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-15-2019 , 09:51   Re: Auto attracting enemies
Reply With Quote #4

Attracted? You mean pulled to him?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-15-2019 , 10:21   Re: Auto attracting enemies
Reply With Quote #5

Get the origin of both players, substract them and then divide by the distance between the players. Now multiply this by the "strength" and then set the velocity of the player that must be pulled to the value you just calculated.
__________________
HamletEagle is offline
sanvaquero
Junior Member
Join Date: Feb 2019
Old 02-15-2019 , 19:17   Re: Auto attracting enemies
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
Get the origin of both players, substract them and then divide by the distance between the players. Now multiply this by the "strength" and then set the velocity of the player that must be pulled to the value you just calculated.
How it should look like, for example?
sanvaquero is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-15-2019 , 19:59   Re: Auto attracting enemies
Reply With Quote #7

https://forums.alliedmods.net/showthread.php?t=299720
__________________








CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-16-2019 , 03:57   Re: Auto attracting enemies
Reply With Quote #8

Quote:
Originally Posted by sanvaquero View Post
How it should look like, for example?
If you don't want to make any effort, you should not be posting in scripting help. It's not a make it for me section, but rather "help me make it" section.
I described what you have to do step by step.
Try to make it yourself and in case you get stuck at some point ask here again(also post the code you made).
Where are you having troubles? Getting player origins? Getting the distance? Setting velocity? Search for each individual part you don't know how to implement.
__________________

Last edited by HamletEagle; 02-16-2019 at 03:58.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-16-2019 , 07:01   Re: Auto attracting enemies
Reply With Quote #9

This, its done via entity think (zombie brain) check if the zombie has a user nearby..
PHP Code:
public zombie_brain(id)
{
   new 
Float:fOrigin[3];
   
pev(idpev_originfOrigin)

   new 
players[32], pnum;
   
get_players(playerspnum"a");

   for(new 
iFloat:fOrigin2[3]; pnumi++)
   {
        
pev(players[i], pev_originfOrigin2);
        if(((
fOrigin[0] + 500.0) > fOrigin2[0] > (fOrigin[0] - 500.0)) && ((fOrigin[1] + 500.0) > fOrigin2[1] > (fOrigin[1] - 500.0))) {
             
// your code here
          
}
      }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-16-2019 at 07:03.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-16-2019 , 08:08   Re: Auto attracting enemies
Reply With Quote #10

You could also use find_sphere_class, would be easier to understand for him.
__________________
HamletEagle is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:13.


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