|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
const MISSION_ACTIONS = array( |
|
4
|
|
|
'LeaveSector', |
|
5
|
|
|
'EnterSector', |
|
6
|
|
|
'WalkSector', |
|
7
|
|
|
'JoinAlliance', |
|
8
|
|
|
'LeaveAlliance', |
|
9
|
|
|
'DisbandAlliance', |
|
10
|
|
|
'KickPlayer', |
|
11
|
|
|
'PlayerKicked', |
|
12
|
|
|
'BuyDrink' |
|
13
|
|
|
); |
|
14
|
|
|
|
|
15
|
|
|
//REQUIREMENTS |
|
16
|
|
|
//if you use an array as a requirement and the requirement name represents an array, it will check every value and all must pass |
|
17
|
|
|
//if you use an array as a requirement and the requirement name is not an array, only one of the checks must pass |
|
18
|
|
|
//ie 'Completed Missions' => array(2,3) means the player must have completed BOTH missions |
|
19
|
|
|
//ie 'Ship ID' => array(1,2) means the player must be in EITHER ship id 1 or 2 |
|
20
|
|
|
//STEPS |
|
21
|
|
|
/*key types: |
|
22
|
|
|
*'KillName' - kill 'Detail' Player/NPC |
|
23
|
|
|
*'KillNPCs' - kill 'Detail' NPCs |
|
24
|
|
|
*'KillPlayers' - kill 'Detail' Players |
|
25
|
|
|
*'KillSpawn' - Spawn 'Detail' Type NPC and kill it, DB field Progress with then be NPC_ID, also requires a 'Level' element, use -1 for normal |
|
26
|
|
|
'Trade' - |
|
27
|
|
|
^'Visit' - Examine 'Detail' location |
|
28
|
|
|
*'DrinkAmount' - Buy 'Detail' drinks at a bar |
|
29
|
|
|
*'Drink' - Buy 'Detail' drink name at a bar |
|
30
|
|
|
*'Move' - Move 'Detail' sectors anywhere |
|
31
|
|
|
*'MoveSector' - Move to 'Detail' sector |
|
32
|
|
|
*'MoveRacial' - Move to galaxy containing 'Detail' race HQ (use racial id) |
|
33
|
|
|
*'MoveGal' - Move to 'Detail' galaxy |
|
34
|
|
|
'ClearNPC' - Clear 'Detail' stacks of NPC forces in sector (use MoveSector) command to tell them which sector, also stored as mission_sector in DB |
|
35
|
|
|
*'StartPortRaid' - start raiding 'detail' ports |
|
36
|
|
|
*'RaidPort' - raid 'detail' ports |
|
37
|
|
|
'Bring' - bring 'detail' to starting sector |
|
38
|
|
|
|
|
39
|
|
|
Replacements: |
|
40
|
|
|
<Race> - Current race name |
|
41
|
|
|
<Starting Sector> - Sector where mission was accepted |
|
42
|
|
|
<Sector> - Random sector for mission. |
|
43
|
|
|
|
|
44
|
|
|
* = implemented |
|
45
|
|
|
^ = partial implementaion |
|
46
|
|
|
Visit - done for 'Bar' |
|
47
|
|
|
*/ |
|
48
|
|
|
|
|
49
|
|
|
// NOTE: Array keys are the mission ID and should not be changed! |
|
50
|
|
|
const MISSIONS = array( |
|
51
|
|
|
0 => array( |
|
52
|
|
|
'Name' => 'Drunk Guy', |
|
53
|
|
|
'Offerer' => 'Drunk', |
|
54
|
|
|
'Time Limit' => 0, |
|
55
|
|
|
'HasX' => array( |
|
56
|
|
|
'Type' => 'Locations', |
|
57
|
|
|
'X' => 'Bar' |
|
58
|
|
|
), |
|
59
|
|
|
'Steps' => array( |
|
60
|
|
|
array( |
|
61
|
|
|
'Step' => 'EnterSector', |
|
62
|
|
|
'PickSector' => array( |
|
63
|
|
|
'Type' => 'Locations', |
|
64
|
|
|
'X' => RACE_SALVENE + LOCATION_GROUP_RACIAL_HQS |
|
65
|
|
|
), |
|
66
|
|
|
'Detail' => array( |
|
67
|
|
|
'SectorID' => '<Sector>' |
|
68
|
|
|
), |
|
69
|
|
|
'Text' => '*Hiccup* Hey! I need you to...*Hiccup* do me a favor. All the Salvene Swamp Water in this bar is awful! Go to the Sal...*Hiccup*...the Salvene HQ, they\'ll know a good bar.', |
|
70
|
|
|
'Task' => 'Go to the Salvene HQ at [sector=<Sector>]' |
|
71
|
|
|
), |
|
72
|
|
|
array( |
|
73
|
|
|
'Step' => 'EnterSector', |
|
74
|
|
|
'PickSector' => array( |
|
75
|
|
|
'Type' => 'Locations', |
|
76
|
|
|
'X' => 'Bar' |
|
77
|
|
|
), |
|
78
|
|
|
'Detail' => array( |
|
79
|
|
|
'SectorID' => '<Sector>' |
|
80
|
|
|
), |
|
81
|
|
|
'Text' => 'Here we are! The Salvene HQ! You ask around a bit and find that the bar in [sector=<Sector>] does the best Salvene Swamp Water around!', |
|
82
|
|
|
'Task' => 'Go to the bar at [sector=<Sector>] and buy a Salvene Swamp Water from the bartender. This may take many tries.' |
|
83
|
|
|
), |
|
84
|
|
|
array( |
|
85
|
|
|
'Step' => 'BuyDrink', |
|
86
|
|
|
'Detail' => array( |
|
87
|
|
|
'SectorID' => '<Sector>', |
|
88
|
|
|
'Drink' => 'Salvene Swamp Water' |
|
89
|
|
|
), |
|
90
|
|
|
'Text' => 'Here we are! Now let\'s get this Salvene Swamp Water.', |
|
91
|
|
|
'Task' => 'Go to the bar at [sector=<Sector>] and buy a Salvene Swamp Water from the bartender. This may take many tries.' |
|
92
|
|
|
), |
|
93
|
|
|
array( |
|
94
|
|
|
'Step' => 'EnterSector', |
|
95
|
|
|
'Detail' => array( |
|
96
|
|
|
'SectorID' => '<Starting Sector>' |
|
97
|
|
|
), |
|
98
|
|
|
'Text' => 'Finally! A true Salvene Swamp Water, let\'s return to that drunk!', |
|
99
|
|
|
'Task' => 'Return to [sector=<Starting Sector>] to claim your reward.' |
|
100
|
|
|
), |
|
101
|
|
|
array( |
|
102
|
|
|
'Step' => 'Claim', |
|
103
|
|
|
'Rewards' => array( |
|
104
|
|
|
'Credits' => 500000, |
|
105
|
|
|
'Experience' => 1000, |
|
106
|
|
|
'Text' => '*Hiccup* For your...service *Hiccup* to me, take these *Hiccup* 500,000 credits and 1,000 experience *Hiccup*!' |
|
107
|
|
|
), |
|
108
|
|
|
'Detail' => array( |
|
109
|
|
|
'SectorID' => '<Starting Sector>' |
|
110
|
|
|
), |
|
111
|
|
|
'Text' => 'You hand the Salvene Swamp water to the drunk!' |
|
112
|
|
|
) |
|
113
|
|
|
) |
|
114
|
|
|
) |
|
115
|
|
|
); |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Callback for array_walk_recursive in SmrPlayer::rebuildMission. |
|
119
|
|
|
* Searches for placeholders in template and replaces them with values |
|
120
|
|
|
* derived from the supplied data. |
|
121
|
|
|
*/ |
|
122
|
|
|
function replaceMissionTemplate(&$template, $key, array $data) : void { |
|
|
|
|
|
|
123
|
|
|
if (!is_string($template)) { |
|
124
|
|
|
return; |
|
125
|
|
|
} |
|
126
|
|
|
$search = ['<Race>', '<Sector>', '<Starting Sector>']; |
|
127
|
|
|
$replace = [$data['player']->getRaceID(), $data['mission']['Sector'], $data['mission']['Starting Sector']]; |
|
128
|
|
|
$template = str_replace($search, $replace, $template); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
function checkMissionRequirements(array $values, array $requirements) : bool { |
|
132
|
|
|
foreach ($requirements as $reqName => $reqValue) { |
|
133
|
|
|
if ($values[$reqName] != $reqValue) { |
|
134
|
|
|
return false; |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
return true; |
|
138
|
|
|
} |
|
139
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.