author | Wuzzy <almikes@aol.com> |
Wed, 16 Nov 2016 16:35:43 +0100 | |
changeset 11892 | 0526a26ddd6e |
parent 9810 | 54c0fdec4600 |
child 11952 | 63988f36debf |
permissions | -rw-r--r-- |
9578
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
1 |
function saveCompletedStatus(planetNum) |
9636
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
2 |
-- 1 2 3 4 5 6 7 |
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
3 |
-- order: moon01, fruit01, fruit02, ice01, desert01, death01, final |
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
4 |
local status = "0000000" |
9578
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
5 |
if tonumber(GetCampaignVar("MainMissionsStatus")) then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
6 |
status = GetCampaignVar("MainMissionsStatus") |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
7 |
end |
9718
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
8 |
|
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
9 |
if planetNum == 1 then |
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
10 |
status = "1"..status:sub(2) |
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
11 |
elseif planetNum == status:len() then |
9578
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
12 |
status = status:sub(1,planetNum-1).."1" |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
13 |
else |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
14 |
status = status:sub(1,planetNum-1).."1"..status:sub(planetNum+1) |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
15 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
16 |
SaveCampaignVar("MainMissionsStatus",status) |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
17 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
18 |
|
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
19 |
function getCompletedStatus() |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
20 |
local allStatus = "" |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
21 |
if tonumber(GetCampaignVar("MainMissionsStatus")) then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
22 |
allStatus = GetCampaignVar("MainMissionsStatus") |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
23 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
24 |
local status = { |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
25 |
moon01 = false, |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
26 |
fruit01 = false, |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
27 |
fruit02 = false, |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
28 |
ice01 = false, |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
29 |
desert01 = false, |
9636
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
30 |
death01 = false, |
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
31 |
final = false |
9578
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
32 |
} |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
33 |
if allStatus ~= "" then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
34 |
if allStatus:sub(1,1) == "1" then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
35 |
status.moon01 = true |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
36 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
37 |
if allStatus:sub(2,2) == "1" then |
9802
00216d609140
desert01 fixed destructible terrain marks and cosmos marks for completed main missions
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9783
diff
changeset
|
38 |
status.fruit01 = true |
9578
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
39 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
40 |
if allStatus:sub(3,3) == "1" then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
41 |
status.fruit02 = true |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
42 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
43 |
if allStatus:sub(4,4) == "1" then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
44 |
status.ice01 = true |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
45 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
46 |
if allStatus:sub(5,5) == "1" then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
47 |
status.desert01 = true |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
48 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
49 |
if allStatus:sub(6,6) == "1" then |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
50 |
status.death01 = true |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
51 |
end |
9636
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
52 |
if allStatus:sub(7,7) == "1" then |
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
53 |
status.final = true |
e1921235fc78
cosmos, after death01 dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9630
diff
changeset
|
54 |
end |
9578
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
55 |
end |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
56 |
return status |
16139270448f
save main missions' status
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff
changeset
|
57 |
end |
9582
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
58 |
|
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
59 |
function initCheckpoint(mission) |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
60 |
local checkPoint = 1 |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
61 |
if GetCampaignVar("CurrentMission") ~= mission then |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
62 |
SaveCampaignVar("CurrentMission", mission) |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
63 |
SaveCampaignVar("CurrentMissionCheckpoint", 1) |
9782
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
64 |
SaveCampaignVar("HogsPosition", "") |
9582
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
65 |
else |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
66 |
checkPoint = tonumber(GetCampaignVar("currentMissionCheckpoint")) |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
67 |
end |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
68 |
return checkPoint |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
69 |
end |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
70 |
|
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
71 |
function saveCheckpoint(cp) |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
72 |
SaveCampaignVar("CurrentMissionCheckpoint", cp) |
bf314b2258b3
less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9578
diff
changeset
|
73 |
end |
9630 | 74 |
|
75 |
-- saves what bonuses are available |
|
76 |
-- times is how many times the bonus will be available, this will be mission specific |
|
77 |
function saveBonus(index, times) |
|
78 |
-- 1 2 3 |
|
79 |
-- order: desert03, fruit03, death02 |
|
80 |
local bonus = "000" |
|
81 |
if tonumber(GetCampaignVar("SideMissionsBonuses")) then |
|
82 |
bonus = GetCampaignVar("SideMissionsBonuses") |
|
83 |
end |
|
9718
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
84 |
if index == 1 then |
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
85 |
bonus = times..bonus:sub(2) |
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9636
diff
changeset
|
86 |
elseif index == bonus:len() then |
9630 | 87 |
bonus = bonus:sub(1,index-1)..times |
88 |
else |
|
89 |
bonus = bonus:sub(1,index-1)..times..bonus:sub(index+1) |
|
90 |
end |
|
91 |
SaveCampaignVar("SideMissionsBonuses",bonus) |
|
92 |
end |
|
93 |
||
94 |
function getBonus(index) |
|
95 |
local bonus = 0 |
|
96 |
if tonumber(GetCampaignVar("SideMissionsBonuses")) then |
|
97 |
bonusString = GetCampaignVar("SideMissionsBonuses") |
|
98 |
bonus = bonusString:sub(index,index) |
|
99 |
end |
|
100 |
return bonus |
|
101 |
end |
|
9782
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
102 |
|
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
103 |
-- splits number by delimiter |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
104 |
function split(s, delimiter) |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
105 |
local res = {} |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
106 |
local first = "" |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
107 |
for i=1,s:len() do |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
108 |
if s:sub(1,1) == delimiter then |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
109 |
table.insert(res, tonumber(first)) |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
110 |
first = "" |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
111 |
else |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
112 |
first = first..s:sub(1,1) |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
113 |
end |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
114 |
s = s:sub(2) |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
115 |
end |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
116 |
if first:len() > 0 then |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
117 |
table.insert(res, tonumber(first)) |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
118 |
end |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
119 |
return res |
6c3cad32d4f4
fixed getting device crates with rc plane,end game when device crates destroyed,save/load hero position for checkpoint 5 in desert01
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9718
diff
changeset
|
120 |
end |