********************************************************************
*This Script was created by Alex Twigg. 
*Permission must be granted by the author to edit this script.
*For questions, contact alex_twigg2000@yahoo.com
********************************************************************


*I decided to put a brief word in here. This script can look quite complex, but realy it isn't at all.
*The "Borg Injection Script" simply injects an animated sprite that injects a norn and it's symbiotic agent.
*This Symbiotic agent is the core of the Borg Norn. All of it's scripts focus on the norn it was created with.
*I came up with this idea simply because I was not very good when I started scripting. (I got my OVs and MVs all wrong.)

*There are both advantages and disatvantages to this system.
*The main advantage is that if the script goes wrong at any point, then only one norn is disconected, not all of them.
*The main disadvantage is that if you have lots of borg norn active, it may slow the game down.

*As far as I know, there is only one error as such in the script, but it is not a scripting error.
*Sometimes the norn simply try to teleport so part of their body is stuck in a wall. I have MOSTLY corrected this.


inst
new: comp 3 2 66515 "bgprt2" 10 0 6000
attr 0
bhvr 0
mvto 1360 6330
tick 1
new: simp 2 3 56515 "blank" 1 0 0
attr 64


scrp 3 2 66515 9
	inst
	gene load ownr 1 "queen.borg"
	slow
	sndc "bgpt"
	anim [1 2 3 4]
	over
	new: crea 4 ownr 1 2 0
	mvft 1464 6459
	born
	accg game "c3_creature_accg"
	bhvr game "c3_creature_bhvr"
	attr game "c3_creature_attr"
	perm game "c3_creature_perm"
	hist name gtos 0 "Queen"
	ages 4
	vocb
	setv ov99 666
	sezz "We Are Borg!"
	seta va00 targ
	setv va01 posx
	setv va02 posy
	subv va01 70
	subv va02 80
	new: simp 2 3 56517 "blank" 1 0 0
	gene load ownr 2 "drone.borg"
	seta va99 targ
	attr 64
	new: simp 2 3 56517 "blank" 1 0 0
	seta va98 targ
	gene load ownr 3 "scout.borg"
	attr 64
	new: simp 2 3 56517 "blank" 1 0 0
	seta va97 targ
	gene load ownr 4 "tactical.borg"
	attr 64
	new: simp 2 2 56515 "bgshield2" 16 0 5000
	pose 15
	mvto va01 va02
	seta ov00 va00
	setv ov07 1
	setv ov08 5000
	seta ov50 va99
	seta ov51 va98
	seta ov52 va97
	setv ov09 0
	setv ov99 0
	setv ov98 0
	setv ov97 0
	setv ov96 0
	seta va00 targ
	attr 16
	tick 1
	targ va00
	targ ownr
	anim [5 6 7 8 9]
	over
	wait 20
	kill targ
endm

scrp 2 2 56515 9
	inst
	setv mv09 0
	enum 2 2 56515
		doif targ ne null
			doif ov07 eq 1
				addv mv09 1
			endi
		endi
	next
	doif mv09 eq 1
		targ mv00
		doif targ ne null
			zomb 0
		endi
		doif mv08 gt 100
			doif mv08 gt 5000
				setv mv08 5000
			endi
***************
*Shield Script*
***************
			doif mv07 ne 3
				targ mv00
				doif targ ne null
					doif movs eq 0
						doif chem 197 gt 0.1
							targ ownr
							sndc "bgsh"
							anim [1 2 3 4 5 6 7]
							over
							etch 4 0 0
								doif targ ne mv00
									seta va00 targ
									doif relx ownr targ gt 0
										velo 30 -10
									elif relx ownr targ lt 1
										velo -30 -20
									endi
									sndc "punc"
									stim writ va00 0 2
								endi
							next
							targ ownr
							anim [8 9 10 11 12 13 14 15]
							subv mv08 100
							targ ov00
							chem 197 -1
						endi
					endi
				endi
			endi
*******************
*End Shield Script*
*******************

**********************
*Teleportation Script*
**********************
			targ mv00
			doif targ ne null
				doif chem 214 gt 0.1 and movs eq 0
					doif mv07 ne 4
						rtar 0 0 0
						gsub teleM
					elif mv07 eq 4
						rtar 2 2 56515
						doif ov07 eq 1
							gsub teleM
						endi
						doif mv07 eq 1
							enum 2 2 56515
								doif targ ne null
									doif ov07 eq 4
										setv ov08 500
										targ ov00
										doif targ ne null
											chem 214 1
										endi
									endi
								endi
							next
						endi
					endi
				endi
			endi

**************************
*End Teleportation Script*
**************************


*********************
*Assimilation Script*
*********************
			targ mv00
			doif targ ne null
				doif chem 186 gt 0.3 and movs eq 0
					doif mv07 eq 1 or mv07 eq 4
						doif totl 2 2 56515 lt 2
							gsub assim
						endi
					elif mv07 eq 2 or mv07 eq 3
						doif totl 2 2 56515 gt 1
							gsub assim
						endi
					endi
				endi
			endi




*Technology Gathering Script*
			doif mv07 eq 3
				targ mv00
				doif targ ne null
					targ held
					doif targ ne null
						doif type targ eq 5 or type targ eq 6
							seta mv16 targ
							targ mv00
							doif targ ne null
								setv va00 rand 2858 2143
								setv va01 6185
								subv va00 80
								setv va02 posx
								setv va03 posy
								gsub teleA
								gsub teleB
								wait 5
								mvsf va00 6290
								subv mv08 250
								wait 10
								chem 214 1
								targ mv16
								doif targ ne null
									tint 127 200 127 187 100
								endi
								targ mv00
								doif targ ne null
									drop
								endi
							endi
						endi
					endi
				endi
			endi
*End Technology Gathering Script*


*Queen Retention Script*
			targ mv00
			doif targ ne null
				doif mv07 eq 1
					chem 185 1
				endi
			endi
			setv va44 0
			enum 2 2 56515
				doif targ ne null
					doif ov07 eq 1
						addv va44 1
					endi
				endi
			next
			doif va44 ne 1
				new: comp 3 2 66515 "bgprt2" 10 0 6000
				attr 0
				bhvr 0
				mvto 1360 6330
				tick 1
				new: simp 2 3 56515 "blank" 1 0 0
				attr 64
				targ ownr
			endi

*End Queen Retention Script*


******************************
*Non Borg Hive Removal Script*
******************************
			targ mv00
			doif targ ne null
				doif chem 185 eq 0
					hist name gtos 0 "Rogue Borg"
					setv ov99 0
					targ ownr
					kill targ
					stop
				elif dead eq 1
					targ ownr
					kill targ
					stop
				endi
			elif targ eq null
				targ ownr
				kill targ
				stop
			endi
**********************************
*End non borg hive removal script*
**********************************
			targ mv00
			doif targ ne null
				doif mv08 lt 5000
					addv mv08 1
				endi
				setv va01 posx
				setv va02 posy
				subv va01 89
				subv va02 90
				targ ownr
				mvto va01 va02
				setv mv09 0
			endi
*Dead Battery Script*
		elif mv08 lt 100
			loop
				targ mv00
				doif targ ne null
					zomb 1
					addv mv08 1
					wait 5
					doif mv08 eq 1
						sezz "Power Cell Empty"
					elif mv08 eq 50
						sezz "Recharge 50% complete"
					elif mv08 eq 99
						sezz "Recharge Complete"
					endi
					addv mv08 1
				endi
			untl mv08 gt 100
			zomb 0
		endi
*End Dead Battery Script*

**************
*Sub Routines*
**************

*Teleport Sprite Inject A*
		subr teleA
			new: simp 3 2 56515 "bgprt2" 11 0 5000
			setv va04 va00
			setv va05 va01
			subv va04 80
			subv va05 105
			mvto va04 va05
			tick 1
			targ mv00
		retn
*End Teleport Sprite Inject A*

*Teleport Sprite Inject B*
		subr teleB
			new: simp 3 2 56515 "bgprt2" 11 0 5000
			subv va02 80
			subv va03 105
			mvto va02 va03
			tick 1
			targ mv00
		retn
*End Teleport Sprite Inject B*

*Subroutine Teleport Main*
		subr teleM
			doif targ ne null
				setv va00 posr
				setv va01 posb
				subv va01 10
				rtar 2 3 56515
				doif targ ne null
					setv va04 va00
					setv va05 va01
					subv va04 116
					subv va05 152
					doif tmvt va04 va05 eq 1
						targ mv00
						doif targ ne null
							doif tmvf va00 va01 eq 1
								setv va02 posx
								setv va03 posy
								gsub teleA
								gsub teleB
								wait 5
								mvft va00 va01
								chem 214 -1
								subv mv08 200
								doif mv07 eq 2
									setv va00 0
									loop
										addv va00 1
										wait 3
									untl va00 eq 100
								endi
							endi
						endi
					endi
				endi
			endi
		retn

*Assimilation Sub Routine*
		subr assim
			rtar 4 0 0
			doif targ ne null
				doif ov99 ne 666 and movs eq 0 and ov99 ne 999
					pose 75
					setv va00 dftx
					setv va01 dfty
					subv va01 10
					setv ov99 999
					seta mv16 targ
					doif mv07 eq 1
						gene cros ownr 5 mv50 2 mv16 0 0 0 0 0
					elif mv07 eq 2
						gene cros ownr 5 mv51 3 mv16 0 0 0 0 0
					elif mv07 eq 3
						gene cros ownr 5 mv52 4 mv16 0 0 0 0 0
					elif mv07 eq 4
						gene cros ownr 5 mv51 3 mv16 0 0 0 0 0
					endi
					targ mv00
					doif targ ne null
						setv va02 posx
						setv va03 posy
						wait 5
						doif tmvf va00 va01 eq 1
							rtar 2 3 56515
							doif targ ne null
								setv va04 va00
								setv va05 va01
								subv va04 116
								subv va05 152
								doif tmvt va04 va05 eq 1
									gsub teleA
									gsub teleB
									wait 5
									mvft va00 va01
									targ mv16
									doif targ ne null
										zomb 1
										motr 0
										wait 1
										pose 102
										wait 1
										dirn 1
										zomb 0
										targ mv00
										doif targ ne null
											zomb 1
											motr 0
											wait 1
											pose 102
											wait 1
											dirn 1
											zomb 0
											sezz "Assimilation Initiated"
											wait 40
										endi
										newc 4 ownr 5 0 0
										seta mv17 targ
										accg game "c3_creature_accg"
										bhvr game "c3_creature_bhvr"
										attr game "c3_creature_attr"
										perm game "c3_creature_perm"
										doif mv07 eq 1 or mv07 eq 4
											hist name gtos 0 "Drone"
										elif mv07 eq 2
											hist name gtos 0 "Scout"
										elif mv07 eq 3
											hist name gtos 0 "Tactical"
										endi
										setv ov99 666
										zomb 1
										motr 0
										wait 1
										pose 102
										wait 1
										dirn 1
										zomb 0
										setv va91 11
										addv va91 gnus
										emit va91 0.5
										vocb
										drea 1
										targ mv00
										doif targ ne null
											sezz "Assimilation 25% Complete"
											wait 40
											sezz "Assimilation 50% Complete"
											wait 20
										endi
										targ mv16
										doif targ ne null
											kill targ
										endi
										targ mv17
										doif targ ne null
											doif tmvf va00 va01 eq 1
												mvft va00 va01
											endi
										endi
										targ mv00
										doif targ ne null
											wait 20
											sezz "Assimilation 75% Complete"
											wait 40
											sezz "Assimilation Complete"
											motr 1
										endi
										targ mv17
										doif targ ne null
											aslp 0
											motr 1
											born
										endi
										new: simp 2 2 56515 "bgshield2" 16 0 5000
										pose 15
										seta ov00 mv17
										mvto va00 va01
										setv va00 mv07
										doif va00 lt 4
											addv va00 1
										elif va00 eq 4
											subv va00 2
										endi
										setv ov07 va00
										setv ov08 6000
										setv ov99 0
										setv ov98 0
										setv ov97 0
										setv ov96 0
										attr 16
										tick 1
										targ mv00
										chem 186 -1
										doif mv07 eq 1 or mv07 eq 4
											divv mv08 2
										else
											setv mv08 0
										endi
									endi
								endi
							endi
						endi
					endi
				endi
			endi
		retn
	elif mv09 eq 0
		targ mv00
		doif targ ne null
			zomb 1
		endi
	endi
endm


**************************
*Teleporter Sprite Script*
**************************
scrp 3 2 56515 9
	sndc "bgte"
	anim [0 1 2 3 4 5 6 7 8 9 10]
	over
	wait 20
	kill targ
endm

****************
*Removal Script*
****************

rscr
enum 3 2 66515
	kill targ
next
scrx 3 2 66515 9
enum 2 2 56515
	kill targ
next
scrx 2 2 56515 9
enum 4 0 0
	setv ov99 0
next
endm