SphereCommunity
special forces attacking npc with karma < 0 - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Requests (/Forum-Script-Requests)
+--- Thread: special forces attacking npc with karma < 0 (/Thread-special-forces-attacking-npc-with-karma-0)

Pages: 1 2 3


special forces attacking npc with karma < 0 - Berkley - 11-18-2015 10:50 PM

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


RE: special forces attacking npc with karma < 0 - rastrero - 01-19-2016 03:54 AM

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


RE: special forces attacking npc with karma < 0 - Kanibal - 01-19-2016 06:37 AM

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



RE: special forces attacking npc with karma < 0 - rastrero - 01-19-2016 09:12 AM

ok ok ok take it easy! haha


RE: special forces attacking npc with karma < 0 - Berkley - 01-31-2016 05:25 AM

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


RE: special forces attacking npc with karma < 0 - Kanibal - 01-31-2016 08:06 AM

It will be better to use <tag.ranger> == 1 instead of <TITLE> == ranger


RE: special forces attacking npc with karma < 0 - rastrero - 02-01-2016 04:09 AM

agree


RE: special forces attacking npc with karma < 0 - Berkley - 02-02-2016 03:08 AM

Thank you again.

btw, how do i make delays?

example given this should run every 3 seconds:

for
do something
endfor


RE: special forces attacking npc with karma < 0 - Kanibal - 02-02-2016 05:14 AM

(02-02-2016 03:08 AM)Berkley Wrote:  btw, how do i make delays?

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



RE: special forces attacking npc with karma < 0 - Berkley - 02-02-2016 10:52 PM

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