[FUNCTION F_CHECK_PEACEDDISTANCE]
REF1=<TAG0.PEACED.PLAYER> //player that peaced me
IF (!(<REF1>))
TAG.PEACED.PLAYER=
	IF (!(<ISPLAYER>))
	TAG.NoMoveTill=
	ENDIF
EVENTS -e_peacemaked
ELIF (!(<ISEVENT.e_peacemaked>))
TAG.PEACED.PLAYER=
	IF (!(<ISPLAYER>))
	TAG.NoMoveTill=
	ENDIF
ELIF (<DISTANCE <REF1>> > <EVAL 8+(<REF1.MUSICIANSHIP>/150)>) || (!(<CANSEELOS <REF1>>))
TAG.PEACED.PLAYER=
	IF (!(<ISPLAYER>))
	TAG.NoMoveTill=
	ENDIF
EVENTS -e_peacemaked
ELIF (!(<REF1.ISONLINE>))
TAG.PEACED.PLAYER=
	IF (!(<ISPLAYER>))
	TAG.NoMoveTill=
	ENDIF
EVENTS -e_peacemaked
ELSE
	IF (!(<ISPLAYER>))
	TAG.NoMoveTill=<EVAL <SERV.TIME>+10>
	ENDIF
TIMERF 1,F_CHECK_PEACEDDISTANCE
ENDIF

[FUNCTION NEW_PEACEMAKING]
IF (<FLAGS>&statf_freeze) || (<FLAGS>&statf_dead)
SYSMESSAGE @946,3,1 You can't do much in your current state.
RETURN 1
ELIF (<CTAG0.FIXMUSIC>)
sysmessageloc -1,500119
RETURN 1
ELIF !(<FINDTYPE.t_musical>) && !(<ISGM>)
SYSMESSAGE @0481,3,1 You need to have an instrument with you.
RETURN 1
ENDIF
IF (<ARGO.UID> == <UID>)
LOCAL.CHANCE=<EVAL (<PEACEMAKING>/20)+(<MUSICIANSHIP>/20)>
	IF (<LOCAL.CHANCE> < 5)
	LOCAL.CHANCE=5
	ENDIF
	IF (<LOCAL.CHANCE> >= <R1,100>) || (<ISGM>)
		FORCHARS <EVAL (<MUSICIANSHIP>/150)+8>
			IF (<CANSEELOS>)
				IF (!(<TAG0.IAMACHAMPION>))
					IF !(<ISPLAYER>)
					ACTION=06d
					ELSE
					ACTION=-1
					ENDIF
				TAG.PROVOKER=
				EVENTS -e_provoked
				FLAGS &= ~statf_war
				REMOVEALLMEMS <DEF.memory_war_targ>
				LOCAL.ACERTOU=1
				ENDIF
			ENDIF
		ENDFOR
	ENDIF
ELSE
	IF (<ARGO.ISCHAR>)
		IF (<ARGO.OWNER> == <UID>)
		RETURN 1
		ENDIF
		IF ((!(<ARGO.ISEVENT.E_PEACEMAKED>)) && (!(<ARGO.TAG0.PROVOKER>)))
		LOCAL.REALDIFF=<EVAL (<ARGO.BARDDIFF <UID>>-10)>
		FLOAT.CHANCE=<FLOATVAL (50+(2*(((<PEACEMAKING>/2)+(<MUSICIANSHIP>/2))-<dLOCAL.REALDIFF>)))/100>
			IF (<FLOAT.CHANCE> < <FLOATVAL 0.01>)
			FLOAT.CHANCE=<FLOATVAL 0.01>
			ENDIF
			IF (<FLOAT.CHANCE> > <RANDOMDOUBLE>)
			ARGO.TIMERF 1,F_CHECK_PEACEDDISTANCE
			ARGO.TAG.PEACED.PLAYER=<UID>
			ARGO.EVENTS +E_PEACEMAKED
			ARGO.FLAGS &= ~statf_war
			ARGO.REMOVEALLMEMS memory_war_targ
				IF (!(<ARGO.ISPLAYER>))
				ARGO.ACTION=06d
				ELSE
				ARGO.ACTION=-1
				ENDIF
			LOCAL.ACERTOU=1
			ENDIF
		ELIF (<ARGO.TAG0.PROVOKER>)
		SYSMESSAGELOC -1,1049447
		RETURN 1
		ELSE
		SYSMESSAGELOC -1,1049528
		RETURN 1
		ENDIF
	ENDIF
ENDIF
IF (!(<CTAG0.FIXMUSIC>))
SRC.SKILLGAIN Musicianship <EVAL (<SRC.MUSICIANSHIP>/10)+1>
SRC.SKILLGAIN Peacemaking <EVAL (<SRC.Peacemaking>/10)+1>
CTAG.FIXMUSIC=1
ENDIF
IF (<LOCAL.ACERTOU>)
TIMERF 5,CTAG.FIXMUSIC=
SYSMESSAGELOC 04ec,1049532
ELSE
TIMERF 1,CTAG.FIXMUSIC=
SYSMESSAGE @,,2 500612
ENDIF

[EVENTS E_PEACEMAKED]
ON=@NpcActFight
ACTION -1
RETURN 1

ON=@Attack
ACTION -1
RETURN 1

ON=@HitTry
ACTION -1
RETURN 1

ON=@GetHit
TIMERF 1,ATTACK <SRC>
EVENTS -E_PEACEMAKED

ON=@SkillStart
IF (<ARGN1> == 25)
SYSMESSAGELOC -1,1072060
RETURN 1
ENDIF

ON=@Death
TAG.NoMoveTill=
EVENTS -E_PEACEMAKED

[EOF]