{$CLEO .cs}

0001: wait 0 ms	

while true
	0001: wait 500 ms	


	// ACHIEVEMENT_01 - Unlock all trophies.
	05F5: call_scm_func @getIsAllTrophiesUnlocked 0 ret_to 0@
	if
		0@ == true
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 1
	end


	// ACHIEVEMENT_02 - Knock off 15 stores.
	05F5: call_scm_func @getStoresKnockedOff 0 ret_to 0@
	if
		0@ >= 15
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 2
	end


	// ACHIEVEMENT_03 - Complete Vigilante Mission level 12.
	05F5: call_scm_func @getHighestLevelVigilanteMission 0 ret_to 0@
	if
		0@ >= 12
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 3
	end


	// ACHIEVEMENT_04 - Attain 100 wanted stars.
	05F5: call_scm_func @getWantedStarsAttained 0 ret_to 0@
	if
		0@ >= 100
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 4
	end


	// ACHIEVEMENT_05 - Perform 100 headshots.
	05F5: call_scm_func @getHeadsPopped 0 ret_to 0@
	if
		0@ >= 100
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 5
	end


	// ACHIEVEMENT_06 - Perform a 30 second wheelie.
	05F5: call_scm_func @getLongestWheelie 0 ret_to 0@
	if
		0@ >= 30
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 6
	end


	// ACHIEVEMENT_07 - Drop off 25 passengers driving the taxi.
	05F5: call_scm_func @getPassengersDroppedOffWithTaxi 0 ret_to 0@
	if
		0@ >= 25
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 7
	end


	// ACHIEVEMENT_08 - Extinguish 10 fires.
	05F5: call_scm_func @getFiresExtinguished 0 ret_to 0@
	if
		0@ >= 10
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 8
	end


	// ACHIEVEMENT_09 - Deliver 10 pizzas.
	05F5: call_scm_func @getPizzasDelivered 0 ret_to 0@
	if
		0@ >= 10
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 9
	end


	// ACHIEVEMENT_10 - Cause $1,000,000 in property damage.
	05F5: call_scm_func @getPropertyDestroyed 0 ret_to 0@
	if
		0@ >= 1000000
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 10
	end


	// ACHIEVEMENT_11 - Own 10 properties.
	05F5: call_scm_func @getNumPropertyOwned 0 ret_to 0@
	if
		0@ >= 10
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 11
	end


	// ACHIEVEMENT_12 - Destroy 100 road vehicles.
	05F5: call_scm_func @getCarsExploded 0 ret_to 0@
	if
		0@ >= 100
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 12
	end


	// ACHIEVEMENT_13 - Achieve a six-star wanted level.
	if
		010F:   player $player_char wanted_level > 5
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 13
	end

	// ACHIEVEMENT_14 - Complete Paramedic Mission level 12.
	05F5: call_scm_func @getHighestLevelAmbulanceMission 0 ret_to 0@
	if
		0@ >= 12
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 14
	end


	// ACHIEVEMENT_15 - Use a Police Bribe to reduce your wanted level.
	05F5: call_scm_func @getIsBribeUsed 0 ret_to 0@
	if
		0@ == true
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 15
	end


	// ACHIEVEMENT_16 - Win the RC Bandit Race.
	if
		$8241 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 16
	end


	// ACHIEVEMENT_17 - Earn a high score of 5 with the Keepie-Uppy beach ball.
	05F5: call_scm_func @getBeachBallScore 0 ret_to 0@
	if
		0@ >= 5
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 17
	end


	// ACHIEVEMENT_18 - Complete all assassination contracts.
	if and
		$298 == 1
		$299 == 1
		$300 == 1
		$301 == 1
		$302 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 18
	end


	// ACHIEVEMENT_19 - Earn the Stuff of Legends media attention rank.
	05F5: call_scm_func @getHighestChaseValue 0 ret_to 0@
	if
		0@ == true
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 19
	end


	// ACHIEVEMENT_20 - Snipe a seagull.
	05F5: call_scm_func @getSeagullsKilled 0 ret_to 0@
	if
		0@ >= 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 20
	end


	// ACHIEVEMENT_21 - Complete 36 Unique Jumps.
	05F5: call_scm_func @getUniqueJumpsIsComplete 0 ret_to 0@
	if
		0@ == true
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 21
	end


	// ACHIEVEMENT_22 - Complete the "Riot" mission.
	if
		$227 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 22
	end


	// ACHIEVEMENT_23 - Complete the "All Hands on Deck!" mission.
	if
		$233 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 23
	end


	// ACHIEVEMENT_24 - Complete the "Supply & Demand" mission.
	if
		$238 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 24
	end


	// ACHIEVEMENT_25 - Complete the "Trojan Voodoo" mission.
	if
		$282 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 25
	end


	// ACHIEVEMENT_26 - Complete the "Publicity Tour" mission.
	if
		$290 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 26
	end


	// ACHIEVEMENT_27 - Complete the "Hog Tied" mission.
	if
		$277 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 27
	end
		
	// ACHIEVEMENT_28 - Retrieve every wanted vehicle at Sunshine Auto's Import Garage.
	if and
		$1125 == 1 // DELUXO
		$1126 == 1 // SABRETUR
		$1127 == 1 // SANDKING
		$1128 == 1 // HOTRING
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 28
	end


	// ACHIEVEMENT_29 - Earn the Butcher criminal rating.
	05F5: call_scm_func @getCriminalRatingNumber 0 ret_to 0@
	if
		0@ >= 10000
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 29
	end


	// ACHIEVEMENT_30 - Earn the Godfather criminal rating.
	05F5: call_scm_func @getCriminalRatingNumber 0 ret_to 0@
	05F5: call_scm_func @getDisplayMoney 0 ret_to 1@
	if and
		0@ >= 1000000
		1@ > 10000000
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 30
	end


	// ACHIEVEMENT_31 - Complete the "Keep Your Friends Close..." mission.
	if
		$270 == 1
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 31
	end


	// ACHIEVEMENT_32 - Earn 100% completion.
	05F5: call_scm_func @getPercentageProgress 0 ret_to 0@
	if
		0@ >= 100.0
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 32
	end


	// ACHIEVEMENT_33 - Find 50 hidden packages.
	05F5: call_scm_func @getCollectablesCollected 0 ret_to 0@
	if
		0@ >= 50
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 33
	end


	// ACHIEVEMENT_34 - Find 100 hidden packages.
	05F5: call_scm_func @getCollectablesCollected 0 ret_to 0@
	if
		0@ >= 100
	then
		0667: SET_ACHIEVEMENT_UNLOCKED 34
	end

	// testing stuff
	// 01E3: text_1number_styled 'REWARD' 1@ 6000 ms 6
	
	//for 1@ = 1 to 34
	//	0666: SET_ACHIEVEMENT 1@ true
	//end
end




//-----------------------------------------------------------------------------------
:getArrayElement
{
	05F5: call_scm_func @getArrayElement 3 array_addr 0x00 sizeof_element 0x00 element 0 ret_to 1@
}
const
	// Parameters
	array_addr = 0@
	sizeof_element = 1@
	element = 2@
	// Variables
	result = 3@
end
var
	0@: int
	1@: int
	2@: int
	3@: int
end

3@ = 2@
3@ *= 1@
3@ += 0@
05F6: ret 1 3@

//-----------------------------------------------------------------------------------
:getIsAllTrophiesUnlocked
{
	05F5: call_scm_func @getIsAllTrophiesUnlocked 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

0@ = false

for 1@ = 2 to 34
	if
		0668: IS_ACHIEVEMENT_UNLOCKED 1@
	then
		0@ = true
	else
		05F6: ret 1 false
	end
end

05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getStoresKnockedOff
{
	05F5: call_scm_func @getStoresKnockedOff 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x97F898 size 4 virtual_protect 0
0092: 0@ = float_to_integer 0@
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getHighestLevelVigilanteMission
{
	05F5: call_scm_func @getHighestLevelVigilanteMission 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x94DD60 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getWantedStarsAttained
{
	05F5: call_scm_func @getWantedStarsAttained 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x9B5EB8 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getHeadsPopped
{
	05F5: call_scm_func @getHeadsPopped 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x9B6E38 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getLongestWheelie
{
	05F5: call_scm_func @getLongestWheelie 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x97530C size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getPassengersDroppedOffWithTaxi
{
	05F5: call_scm_func @getPassengersDroppedOffWithTaxi 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0xA0D1DC size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getFiresExtinguished
{
	05F5: call_scm_func @getFiresExtinguished 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x9B6A84 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getPizzasDelivered
{
	05F5: call_scm_func @getPizzasDelivered 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x978780 size 4 virtual_protect 0
0092: 0@ = float_to_integer 0@
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getPropertyDestroyed
{
	05F5: call_scm_func @getPropertyDestroyed 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x975404 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getNumPropertyOwned
{
	05F5: call_scm_func @getNumPropertyOwned 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x978E08 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getCarsExploded
{
	05F5: call_scm_func @getCarsExploded 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0xA0D388 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getHighestLevelAmbulanceMission
{
	05F5: call_scm_func @getHighestLevelAmbulanceMission 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x978DB8 size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getIsBribeUsed
{
	05F5: call_scm_func @getIsBribeUsed 0 ret_to 1@
}

if
	$105 == 1
then
	05F6: ret 1 true
else
	if or
		Pickup.Picked_up($110)
		Pickup.Picked_up($111)
		Pickup.Picked_up($112)
		Pickup.Picked_up($113)
		Pickup.Picked_up($114)
		Pickup.Picked_up($115)
	then
		if
			Player.Defined($PLAYER_CHAR)
		then
			05F6: ret 1 true
		end
	end
	
	if
		Pickup.Picked_up($116)
	then
		if
			Player.Defined($PLAYER_CHAR)
		then
			05F6: ret 1 true
		end
	end
	
	if or
		Pickup.Picked_up($117)
		Pickup.Picked_up($118)
		Pickup.Picked_up($119)
		Pickup.Picked_up($120)
		Pickup.Picked_up($121)
		Pickup.Picked_up($122)
	then
		if
			Player.Defined($PLAYER_CHAR)
		then
			05F6: ret 1 true
		end
	end
end

05F6: ret 1 false

//-----------------------------------------------------------------------------------
:getBeachBallScore
{
	05F5: call_scm_func @getBeachBallScore 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05F5: call_scm_func @getArrayElement 3 0x9B6E20 4 3 ret_to 0@
05E0: 0@ = read_memory 0@ size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getHighestChaseValue
{
	05F5: call_scm_func @getHighestChaseValue 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: float
end

05E0: 0@ = read_memory 0x978E0C size 4 virtual_protect 0
//0092: 0@ = float_to_integer 0@

if
	0@ >= 1800.0
then
	05F6: ret 1 true
else
	05F6: ret 1 false
end
05F6: ret 1 false

//-----------------------------------------------------------------------------------
:getSeagullsKilled
{
	05F5: call_scm_func @getSeagullsKilled 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x97869C size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getUniqueJumpsIsComplete
{
	05F5: call_scm_func @getUniqueJumpsIsComplete 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x974B48 size 4 virtual_protect 0
05E0: 1@ = read_memory 0x978530 size 4 virtual_protect 0
if
	0@ == 1@
then
	05F6: ret 1 true
else
	05F6: ret 1 false
end
05F6: ret 1 false

//-----------------------------------------------------------------------------------
:getCriminalRatingNumber
{
	05F5: call_scm_func @getCriminalRatingNumber 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E2: call_function 0x4CD97B num_params 0 pop 0 0@
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getDisplayMoney
{
	05F5: call_scm_func @getDisplayMoney 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x94ADCC size 4 virtual_protect 0
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getPercentageProgress
{
	05F5: call_scm_func @getPercentageProgress 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	totalProgressInGame = 0@
	progressMade = 1@
	v3 = 2@
	result = 3@
end
var
	0@: float
	1@: float
	2@: float
	3@: float
	4@: int
end

05E0: 0@ = read_memory 0x974B0C size 4 virtual_protect 0
05E0: 1@ = read_memory 0x9B6CDC size 4 virtual_protect 0
05E0: 4@ = read_memory 0x68DD68 size 1 virtual_protect 0

if
	0@ <> 0
then
	if
		4@ == 1
	then
		2@ = 0@
	else
		2@ = 0@
		2@ -= 1.0
	end
	
	3@ = 1@
	3@ *= 100.0
	3@ /= 2@
else
	3@ = 0.0
end

if
	3@ > 100.0
then
	3@ = 100.0
end

05F6: ret 1 3@

//-----------------------------------------------------------------------------------
:getCollectablesCollected
{
	05F5: call_scm_func @getCollectablesCollected 0 ret_to 1@
}
const
	// Parameters
	// 
	// Variables
	result = 0@
end
var
	0@: int
end

05E0: 0@ = read_memory 0x94ADD0 size 4 virtual_protect 0
05F6: ret 1 0@