Mission Engine - Introductory Mission Code

&lt;?php class IntroMission extends Mission {	// Mission meta description public $mission_name = "First mission"; public $mission_description = "Get your tools ready - you'll need them.";

// This function is called when the mission is started function mission_start {		$this-&gt;say("good day, traveler"); // Each "say" action takes a time proportional to the number of character to display // While it is performed, "--- is typing..." is displayed $this-&gt;say("you seem a bit lost, here..."); // Actions are performed sequentially // here the previous "say" must be finished before this one starts to execute $this-&gt;say("are you looking for something?"); $this-&gt;wait_for_action(REPLY, 'mission_start_2'); // action arguments are binary constants - one for every type of action logged }

function mission_start_2 {		$this-&gt;say("that's what I thought"); $this-&gt;say("we all are"); $this-&gt;say("Actually..."); $this-&gt;say("I may be able to help you a bit"); $this-&gt;say("but first, let me equip you with some tools that could prove handy"); $this-&gt;go_to_url($this-&gt;player-&gt;home_site); // Changes the URL displayed within the game to the home site of the player // (displayed with the hackit bar, below it)

$this-&gt;say("see the bar on the top now?"); $this-&gt;say("it's a handy tool, that may help you to find what you are looking for"); $this-&gt;say("but before you try to use it out on the rest of the web, you may want to practice a bit"); $this-&gt;say("try it on the current page"); $this-&gt;say("try to hack it - the button is on the top left");

$this-&gt;mission_start2_hinted = false; $this-&gt;wait_for_action(HACK, 'home_hacked'); $this-&gt;wait_for_action(~(HACK &amp; INTERFACE_ACTIONS), 'mission_start2_other'); // Catch everything else, except actions related // to interface (like closing a hack result window) }

function mission_start2_other {		if(!$this-&gt;mission_start2_hinted) { // Only say this once $this-&gt;say("you can have fun with other stuff, of course"); $this-&gt;say("but I'd recommend starting with hacking &lt;a href='".$this-&gt;player-&gt;home_site."'&gt;this site&lt;/a&gt;"); $this-&gt;say("(and then the HackIt button on the top left)"); }		return false; // Returning a false value does not make the action progress // (the defined wait_for_action are not cleared) }

function home_hacked($action_results) {		if($this-&gt;session-&gt;current_url != $this-&gt;player-&gt;home_site) { // Player hacked another website $this-&gt;mission_start2_other; return false; }

if(!$action_results-&gt;is_success) { // Hack failed $this-&gt;say("almost"); $this-&gt;say("try again - you're getting there"); return false; }		$this-&gt;say("well done."); $this-&gt;say("that was the easy part, though."); $this-&gt;say("ready for more?"); $this-&gt;wait_for_action(REPLY, 'getting_an_isp_website'); }

function getting_an_isp_website {		$this-&gt;say("yes, once you have started, it's hard to stop..."); $this-&gt;say("we'll need to give you a bit more horsepower."); $this-&gt;say("have you noticed that when you try to hack, you spend hack points?"); $this-&gt;wait_for_action(REPLY, 'getting_an_isp_website2'); }

function getting_an_isp_website2 {		$this-&gt;say("this is because it takes a lot of power to hack"); $this-&gt;say("when you hack more websites, you get more horsepower (and thus more points)"); $this-&gt;say("so"); $this-&gt;say("let's try to hack something that will provide us with A LOT of horsepower"); $this-&gt;say("something good for this - an internet provider!"); $this-&gt;say("go to the website of an internet access provider that you know"); $this-&gt;say("like the company you use to connect to the Internet, for example ;p"); $this-&gt;say("enter the name or address in the field on the bar and press enter"); $this-&gt;say("it's next to the the number of hack points"); $this-&gt;wait_for_action(GO_TO_URL, 'getting_an_isp_website_finding_it'); }

function getting_an_isp_website_finding_it {		if(!$this-&gt;session-&gt;url_has_tag("internet")) { // "internet" has to be one of the delicious tags (not only the first tag, no restriction) $this-&gt;say("nope, not that one"); return false }

$this-&gt;say("like that one, yes"); $this-&gt;say("now try to hack it"); $this-&gt;wait_for_action(HACK, 'getting_an_isp_website_hacking_it'); }

function home_getting_an_isp_website_hacking_it($action_results) {		if(!$this-&gt;session-&gt;url_has_tag("internet")) { // Player hacked another website $this-&gt;say("nope, not that one"); return false }		$this-&gt;give_reward(6, "max_hack_points"); // Add one point to the maximum of hack points $this-&gt;give_reward(4, "max_scan_points"); // Same thing with scan points $this-&gt;replenish_hackscan_points; $this-&gt;say("well done"); $this-&gt;say("you impress me"); $this-&gt;say("I guess I can let you explore around then"); $this-&gt;say("oh - an advice"); $this-&gt;say("if you'd like to get more help"); $this-&gt;say("this forum is very useful"); $this-&gt;go_to_url("http://community.hackit.cx/"); $this-&gt;say("feel free to post right now, actually"); $this-&gt;say("I'd also be happy to read suggestions to improve the training I just gave you"); $this-&gt;say("happy hacking... ^_^"); } }

?&gt;