The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
special forces attacking npc with karma < 0
Author Message
Berkley
Journeyman
*

Posts: 54
Likes Given: 28
Likes Received: 2 in 2 posts
Joined: Jul 2015
Reputation: 0



Post: #1
special forces attacking npc with karma < 0
Hello,

i'm looking for a script, that makes every npc ranger in yell distance of my player char attacking every monster with Karma less 0 which is in yell distance too.

Is that possible?

best regards, Lars
11-18-2015 10:50 PM
Find all posts by this user Like Post Quote this message in a reply
rastrero
Master
**

Posts: 250
Likes Given: 41
Likes Received: 28 in 24 posts
Joined: Jan 2016
Reputation: 3



Post: #2
RE: special forces attacking npc with karma < 0
Edit.
hmm wait i think I did not understand what u wanted.

Is this?

[function f_special_force_order_attack]
forchars 16 // chars and npcs 16 tiles distance
if (<karma>>=2000) //blue karma npc
f_special_forces
endif
endfor

[function f_special_forces]
ref12=<uid>
forchars 16 // chars and npcs 16 tiles distance
if (<karma><=0)
ref12.attack <uid>
return 1 //stop checking to attack only one.
endif
endfor
(This post was last modified: 01-19-2016 05:44 AM by rastrero.)
01-19-2016 03:54 AM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes rastrero's post
Kanibal
Master
**

Posts: 255
Likes Given: 6
Likes Received: 30 in 28 posts
Joined: Jun 2012
Reputation: 0



Post: #3
RE: special forces attacking npc with karma < 0
Code:
[FUNCTION f_special_forces_attack]
forchars <serv.distanceyell>
  if (<npc> && <brain> && <karma> >= 0)
    ref1=<uid>
    forchars <serv.distanceyell>
      if (<karma> < 0)
        ref1.attack <uid>
      endif
    endfor
  endif
endfor

Grandmaster Localhost Admin
(This post was last modified: 01-19-2016 06:39 AM by Kanibal.)
01-19-2016 06:37 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
[+] 2 users Like Kanibal's post
rastrero
Master
**

Posts: 250
Likes Given: 41
Likes Received: 28 in 24 posts
Joined: Jan 2016
Reputation: 3



Post: #4
RE: special forces attacking npc with karma < 0
ok ok ok take it easy! haha
01-19-2016 09:12 AM
Find all posts by this user Like Post Quote this message in a reply
Berkley
Journeyman
*

Posts: 54
Likes Given: 28
Likes Received: 2 in 2 posts
Joined: Jul 2015
Reputation: 0



Post: #5
RE: special forces attacking npc with karma < 0
Perfect, many thanks for your help!!

i added this in my sphere_events_human.scp

Now every Ranger i placed in game attacks every red (under 800 Karma) npc in near of the player. So Rangers can protect players automatically in special Areas.

Best regards, Lars
(This post was last modified: 01-31-2016 06:15 AM by Berkley.)
01-31-2016 05:25 AM
Find all posts by this user Like Post Quote this message in a reply
Kanibal
Master
**

Posts: 255
Likes Given: 6
Likes Received: 30 in 28 posts
Joined: Jun 2012
Reputation: 0



Post: #6
RE: special forces attacking npc with karma < 0
It will be better to use <tag.ranger> == 1 instead of <TITLE> == ranger

Grandmaster Localhost Admin
(This post was last modified: 01-31-2016 08:11 AM by Kanibal.)
01-31-2016 08:06 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Kanibal's post
rastrero
Master
**

Posts: 250
Likes Given: 41
Likes Received: 28 in 24 posts
Joined: Jan 2016
Reputation: 3



Post: #7
RE: special forces attacking npc with karma < 0
agree
02-01-2016 04:09 AM
Find all posts by this user Like Post Quote this message in a reply
Berkley
Journeyman
*

Posts: 54
Likes Given: 28
Likes Received: 2 in 2 posts
Joined: Jul 2015
Reputation: 0



Post: #8
RE: special forces attacking npc with karma < 0
Thank you again.

btw, how do i make delays?

example given this should run every 3 seconds:

for
do something
endfor
02-02-2016 03:08 AM
Find all posts by this user Like Post Quote this message in a reply
Kanibal
Master
**

Posts: 255
Likes Given: 6
Likes Received: 30 in 28 posts
Joined: Jun 2012
Reputation: 0



Post: #9
RE: special forces attacking npc with karma < 0
(02-02-2016 03:08 AM)Berkley Wrote:  btw, how do i make delays?

Use Timer
Code:
On=@Timer
Do something...
Timer=3

Grandmaster Localhost Admin
02-02-2016 05:14 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Kanibal's post
Berkley
Journeyman
*

Posts: 54
Likes Given: 28
Likes Received: 2 in 2 posts
Joined: Jul 2015
Reputation: 0



Post: #10
RE: special forces attacking npc with karma < 0
thanks again Kanibal.

After some testing the best working code i found is that:

ON=@NPCSeeNewPlayer
forchars <serv.distanceyell>
if (<npc> && <brain> && (<OBODY> == c_ranger)||<OBODY> == c_ranger_f))
ref687=<uid>
forchars <serv.distanceyell>
if (<karma> < -799)
ref687.attack <uid>
endif
endfor
endif
Timer=2.0
endfor

best regards, Lars
02-02-2016 10:52 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 3 Guest(s)