; "Common" random encounters. 2 or 3 of these should show up on every map. 
; "Old Bones" random encounter. The player comes across the bones of a less fortunate adventurer. Clerics can cast Speak with Dead
; to gain a bit of knowledge about the surrounding area.
SCENE 9000, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0 
@scenestart
ACTOR 1, "Bones", joshMiscellaneous, 22, 40, 95
N: The bones of an unfortunate adventurer lay on the ground before you
RETURN
; "Friendly Animal" random encounter. The player comes across a non hostile animal. Druids can use Speak with Animals to
; gain a bit of knowledge about the surrounding area.
SCENE 9001, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0
@scenestart
SET hasTalked, "0"
CALL 9990@npcgen, joshAnimals, animals, 0, "Friendly Animal", 2
N: A docile animal greets you.
SET num.DevTableId, 04
SET str.DevTableRowId, #<str.mapName>
RETURN
; "Buried Treasure" random encounter. They find some buried treasure.
; Use dev table 01 for random level scaled treasure.
SCENE 9002, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0
@scenestart
CALL 9990@randtreasure
WAIT 2
N: A sparkle on the ground catches your eye.
WAIT 2
H: Ooh, what's this?
WAIT 2
N: You found a #<treasureName>!
RETURN
; "Magical Herbs" random encounter. This should be rarer than the other encounters. Player finds a random stat seed.
SCENE 9003, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0
@scenestart
SET herbType, "%R6"
COMPARE #<herbType>, "1"
IF= @herb1
COMPARE #<herbType>, "2"
IF= @herb2
COMPARE #<herbType>, "3"
IF= @herb3
COMPARE #<herbType>, "4"
IF= @herb4
COMPARE #<herbType>, "5"
IF= @herb5
COMPARE #<herbType>, "6"
IF= @herb6
@herb1
SET item.id, "221"
GIVE I221
GOTO @herbfind
@herb2
SET item.id, "222"
GIVE I222
GOTO @herbfind
@herb3
SET item.id, "223"
GIVE I223
GOTO @herbfind
@herb4
SET item.id, "224"
GIVE I224
GOTO @herbfind
@herb5
SET item.id, "225"
GIVE I225
GOTO @herbfind
@herb6
SET item.id, "226"
HOST_GIVE I226
GOTO @herbfind
RETURN
@herbfind
N: While investigating the surrounding area, something catches your eye.
H: Now this is a find! I had no idea these grew here!
N: You find a #<item.name>!
RETURN
; "Walking Wounded" random encounter. The player comes across a NPC in need of medical attention.
; Helping them by either tossing them a healing potion or casting a healing spell on them grants a reward.
; There is a 50/50 chance of the NPC actually being a doppelganger
SCENE 9004, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0
@scenestart
SET isDoppelganger %R2
CALL 9990@npcgen, joshTownsfolk, humans, 0, "Injured Traveler", 4
WAIT 1
4: Please, can you help me? Something attacked me and left me for dead!
MENU "(WIS)(KNOWLEDGE) Inspect their wound.=@knowledge", "(WIS)(PERCEPTION) Try to gauge whether they're telling the truth.=@perception", "Do nothing.=@nothing"
GOTO @nothing
@knowledge
COMPARE #<isDoppelganger>, "2"
IF= @doppelknowledge
GOTO @humanknowledge
@perception
COMPARE #<isDoppelganger>, "2"
IF= @doppelperception
GOTO @humanperception
@nothing
RETURN
@doppelknowledge
	CALL 9990@skillcheck, knowledge, #<num.hostWIS>, 0, 15
	COMPARE #<finalResult>, "2"
	IF= @dopknocritsucceeded
	COMPARE #<finalResult>, "1"
	IF= @dopknosucceeded
	COMPARE #<finalResult>, "0"
	IF= @dopknofailed
@humanknowledge
	CALL 9990@skillcheck, knowledge, #<num.hostWIS>, 0, 15
	COMPARE #<finalResult>, "2"
	IF= @humknocritsucceeded
	COMPARE #<finalResult>, "1"
	IF= @humknosucceeded
	COMPARE #<finalResult>, "0"
	IF= @humknofailed
@doppelperception
	CALL 9990@skillcheck, perception, #<num.hostWIS>, 0, 15
	COMPARE #<finalResult>, "2"
	IF= @doppercritsucceeded
	COMPARE #<finalResult>, "1"
	IF= @doppersucceeded
	COMPARE #<finalResult>, "0"
	IF= @dopperfailed
@humanperception
	CALL 9990@skillcheck, perception, #<num.hostWIS>, 0, 15
	COMPARE #<finalResult>, "2"
	IF= @humpercritsucceeded
	COMPARE #<finalResult>, "1"
	IF= @humpersucceeded
	COMPARE #<finalResult>, "0"
	IF= @humperfailed
@dopknocritsucceeded
	WAIT 2
		N: As you inspect the wound, you notice something seems off.
	WAIT 2
		N: The wound seems to be a fake crafted with raw meat and pomegranate juice.
	WAIT 2
		H: Wait a minute! You're not wounded!
		H: I've heard of this.
		H: Doppelgangers fake being wounded to ambush people and replace them!
		4: Damn! #<g.hes> onto me!
	GOTO @dopreward
@dopknosucceeded
	WAIT 2
		N: As you inspect the wound, you notice something seems off.
	WAIT 2
		N: The wound, while grisly at first glance, seems to be an elaborate fake. 
	WAIT 2
		H: Wait a minute! You're not wounded!
		H: I've heard of this.
		H: Doppelgangers fake being wounded to ambush people and replace them!
		4: Damn! #<g.hes> onto me!
	GOTO @dopreward
@dopknofailed
	WAIT 2
		N: The wound appears to be serious. The traveler needs immediate medical attention.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@doppercritsucceeded
	WAIT 2
		N: Something about the way this traveler carries themselves is off.
	WAIT 2
		N: They seem to forget which limb is supposed to be the injured one occasionally.
	WAIT 2
		H: Wait a minute! You're not wounded!
		H: I've heard of this.
		H: Doppelgangers fake being wounded to ambush people and replace them!
		4: Damn! #<g.hes> onto me!
	GOTO @dopreward
@doppersucceeded
	WAIT 2
		N: Something about the way this traveler carries themselves is off.
	WAIT 2
		N: They don't seem to have much trouble putting weight on the injured limb.
	WAIT 2
		H: Wait a minute! You're not wounded!
		H: I've heard of this.
		H: Doppelgangers fake being wounded to ambush people and replace them!
		4: Damn! #<g.hes> onto me!
	GOTO @dopreward
@dopperfailed
	WAIT 2
		N: The traveler appears to be in a great deal of pain.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@humknocritsucceeded
	WAIT 2
		N: The wound appears to be serious. The traveler needs immediate medical attention.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@humknosucceeded
	WAIT 2
		N: The wound appears to be serious. The traveler needs immediate medical attention.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@humknofailed
	WAIT 2
		N: The wound appears to be serious. The traveler needs immediate medical attention.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@humpercritsucceeded
	WAIT 2
		N: The traveler appears to be in a great deal of pain.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@humpersucceeded
	WAIT 2
		N: The traveler appears to be in a great deal of pain.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@humperfailed
	WAIT 2
		N: The traveler appears to be in a great deal of pain.
	WAIT 2
		4: If you have any potions or spells that could heal me, I'd appreciate it.
RETURN
@dopreward
	MUSIC "#silence"
	MOVE 4, -10, 90, 2
	CALL 9990@randtreasure
		N: In their hurry to flee, the doppelganger drops #<treasureName>.
	WAIT 5
END
; "Environmental Hazard" random encounter. Pass an Athleticism check or take some damage from a trap or other hazard.
;SCENE 9006, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0
; "Mugging" random encounter. A level-scaled bandit accosts the player character trying to rob them. Defeat or pass an Intrigue check for a reward, if you die you lose half 
; of your gold.
SCENE 9007, #<scene.bkgnd>, SCENE, "-", #<scene.fx>, #<scene.weather>, 0
@scenestart
	ACTOR 5, "Mugger", josh56, 1, 30, 95
	SEL 5
	POSE 1, 4, 4
		5: Stand and deliver! Half your gold and I let you live.
	MENU "(WIS/STR)(INTRIGUE) Try to scare him off.=@intimidate", "(FIGHT) Draw your weapon.=@fight", "Pay him off.=@pay"
GOTO @fight
@intimidate
		H: In a hurry to die, are you?
	COMPARE #<num.hostWIS>, #<num.hostSTR>
	IF> @wishigher
	IF= @wishigher
	IF< @strhigher
@wishigher
CALL 9990@skillcheck, intrigue, #<num.hostWIS>, 0, 15
COMPARE #<finalResult>, "2"
IF= @intimcritsucceeded
COMPARE #<finalResult>, "1"
IF= @intimsucceeded
COMPARE #<finalResult>, "0"
IF= @intimfailed
END
@strhigher
CALL 9990@skillcheck, intrigue, #<num.hostSTR>, 0, 15
COMPARE #<finalResult>, "2"
IF= @intimcritsucceeded
COMPARE #<finalResult>, "1"
IF= @intimsucceeded
COMPARE #<finalResult>, "0"
IF= @intimfailed
END
@intimcritsucceeded
		N: (CRITICAL SUCCESS) The bandit turns tail and flees.
	MOVE 5, -20, 95, 2
	GOTO @reward
@intimsucceeded
		N: (SUCCESS) The bandit turns tail and flees.
	MOVE 5, -20, 95, 2
	GOTO @reward
@intimfailed
		N: (FAILED) The bandit draws his weapon.
		4: Making this harder for both of us, then?
	WAIT 2
	MOVE 5, -20, 95, 1
		GOTO @fight
@fight
	MUSIC "battle1.mid"
	SET levelScale, #<num.hostLevel>
	DIV levelScale, 5
	ADD levelScale, 470
	COMPARE #<levelScale>, "488"
	IF> @maxbandit
	FIGHT2 #<levelScale>
	IF ALIVE, @reward
	GOTO @dead
@maxbandit
	FIGHT2 488
	IF DEAD @dead
	GOTO @reward
@dead
	MUSIC "#silence"
	WAIT 5
	MOVE 5, 20, 95, 1
		5: So you're as stupid as you are weak. I'll be taking this now.
	SET halfGold, #<num.hostGP>
	DIV halfGold, 2
	HOST_TAKE G#<halfGold>
	MOVE 5, -20, 95
	CALL 9990@deathwarp
END
@pay
		5: Smart of you, if not very brave.
	SET halfGold, #<num.hostGP>
	DIV halfGold, 2
	HOST_TAKE G#<halfGold>
	MOVE 5, -20, 95
END
@reward
	MUSIC "#silence"
	CALL 9990@randtreasure
		N: In his rush to flee, the bandit drops a #<treasureName>!
END
; Area-specific non-combat encounters.

