*******************************************************
*** Stuff done to creatures: 0+
*******************************************************


* picking up creatures unzombifies them:
scrp 4 0 0 4
	inst
** unzombify
	doif from eq pntr
		zomb 0
** Make them the NORN
		norn targ
	endi
*	clear immigration status
	targ ownr
*		clear stuff
	setv name "Pray Extra reject" 0
	setv name "Pray Extra foe" 0
*		get moniker
	sets va00 gtos 0

*	check for a warning icon with this moniker in ov03		
	enum 1 2 46
		doif type ov03 eq 2
			doif va00 eq ov03
*			get it's ID (ov02)
				setv va01 ov02
*			flag
				setv va99 1
			endi
		endi
	next
*		if flag set then send shuffle
	doif va99 eq 1
		enum 1 2 46
			mesg wrt+ targ 1000 va01 0 0
		next
	endi

	sets va03 va00
	adds va03 "_quarantine"
	adds va00 "_immigrant"

*		can only accept immigrants (string type)
*	doif type game va00 eq 2
	delg va00
*	endi
*		remove quarantine setting
	delg va03


	rtar 1 1 154
	doif targ eq null
		stop
	endi
	seta va50 targ
	doif touc ownr va50 gt 0
*	creature is touching the chamber, send it a refresh message
		rtar 1 2 208
		doif targ ne null
			mesg writ targ 1065
		endi
	endi
endm

*	creature drop
scrp 4 0 0 5
	inst
	rtar 1 1 154
	doif targ eq null
		stop
	endi
	seta va50 targ
	doif touc ownr va50 gt 0
*	creature is touching the chamber, send it a refresh message
		rtar 1 2 208
		doif targ ne null
			mesg writ targ 1065
		endi
	endi
endm

** creature collision with wall script:
scrp 4 0 0 6
	inst
*	dbg: outs "impact: "
*	dbg: outv _p1_
*	dbg: outs ","
*	dbg: outv _p2_
*	dbg: outs ""
* stim IMPACT:
* work out a sensible speed you collided at:
	doif _p1_ > _p2_
		setv va00 _p1_
	else
		setv va00 _p2_
	endi
	divv va00 50
	doif va00 > 10
		setv va00 10
	endi

* hard landing?
	doif va00 >= .5

*** Regarding the following lines of comments and code for waking up sleeping Norns.
*** It appears to me that this collision script won't even be fired if the Norn is dreaming.

* watch this one as it could wake up creatures inside the incubator
* when they're being hatched:
		doif aslp = 1
* if you collide you wake up:
			aslp 0
		endi
* do n impact stims depending on the velocity you hit with:
		doif va00 >= 1.0
			reps va00
				stim writ ownr 39 1
			repe
		endi
	endi
* bounce a little bit:
	doif _p2_ > 10
		setv va01 0
		subv va01 _p2_
		divv va01 5
		setv vely va01
	endi
endm


** bump script
scrp 4 0 0 7
	inst
	doif movs = 0
* disapoint to discourage
		stim writ targ 0 1
	endi
endm



********** Creature - deactivate - slap - [0]
scrp 4 0 0 0
	forf from

* if dead stop:
	doif dead ne 0
		stop
	endi
	doif from eq pntr
*IF the message came from pointer give a POINTERSLAP stim
		stim writ targ 3 1
*		injr -1 10
	else
*ELSE give a CREATURESLAP stim
		stim writ targ 4 1
	endi
*IF unconcious stop
	doif uncs ne 0
		stop
	endi
	doif aslp ne 0
		aslp 0
	endi
*ELSE make some sounds
	doif gnus ne 2
		setv va00 rand 0 4
		doif va00 lt 3
			snde "ow!1"
		endi
		doif va00 eq 3
			snde "ow!2"
		endi
		doif va00 eq 4
			snde "ow!3"
		endi
	else
		snde "glaf"
	endi

	doif rand 1 5 eq 5
		like from
	endi
endm

* this script should never be called as 
* the activate 1 and activate 2 doing scripts
* both send message 1 to the "done to" creature
* so we just assert to show something strange
* has happened
* The script is here so BHVR doesn't give
* an error
scrp 4 0 0 2
	dbg: asrt 0 = 1
endm

********* Creature - activate - tickle [1]
scrp 4 0 0 1

	forf from

* if dead stop:
	doif dead ne 0
		stop
	endi

	doif from eq pntr
*IF the message came from the pointer then give POINTERPAT stim
		stim writ targ 1 1
	else
*ELSE give a CREATUREPAT stim
		stim writ targ 2 1
	endi
*IF unconcious stop
	doif uncs ne 0
		stop
	endi
	doif aslp gt 0
		aslp 0
	endi

** if tickled by a creture of opposide sex stim so
	inst
	doif from ne null
		setv va00 fmly
		setv va01 gnus
		setv va02 spcs
		targ from
		doif fmly eq va00 and gnus eq va01
			doif spcs ne va02
** tickled by opposite
				stim writ ownr 46 1
			else
				stim writ ownr 47 1
			endi
		endi
		targ ownr
	endi
	slow


*ELSE if pain is less than 16
	doif driv 0 lt 0.1
**and anger is less than 20 make a giggle
		doif driv 12 lt 0.1
* turn towards camera and act surprised:
			dirn 1
			pose 0
			face 4

			doif gnus eq 1
				wait 3
				setv va00 rand 0 4
				doif va00 lt 3
					snde "gig1"
				endi
				doif va00 eq 3
					snde "gig2"
				endi
				doif va00 eq 4
					snde "gig3"
				endi
			else
				doif gnus eq 2
					wait 3
					snde "glaf"
				else
					wait 3
					snde "elaf"
				endi
			endi
		endi
	endi

	doif rand 1 5 eq 5
		like from
	endi
endm



********CREATURE - has been hit - [3]
scrp 4 0 0 3
	forf from

* if dead stop:
	doif dead ne 0
		stop
	endi

	doif from eq pntr
*IF the message came from pointer give a POINTERSLAP stim
		stim writ targ 3 1
	else
*ELSE give a CREATURESLAP stim
* this stim is done in the hit script and the strength depends
* on the strength of the creature:
*		stim writ targ 4 1
	endi
*IF unconcious stop, if asleep wake up:
	doif uncs ne 0
		stop
	endi
	doif aslp ne 0
		aslp 0
	endi
*ELSE make some sounds
	doif gnus ne 2
		setv va00 rand 0 4
		doif va00 lt 3
			snde "ow!1"
		endi
		doif va00 eq 3
			snde "ow!2"
		endi
		doif va00 eq 4
			snde "ow!3"
		endi
	else
* grendel sound
		snde "glaf"
	endi

	doif rand 1 5 eq 5
		like from
	endi

endm


rscr
scrx 4 0 0 0
scrx 4 0 0 1
scrx 4 0 0 2
scrx 4 0 0 4
scrx 4 0 0 6
endm