Code Search for Developers
 
 
  

mission_check.lua from palisma2d at Krugle


Show mission_check.lua syntax highlighted

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
-- Quest Dialog File: This file decides which dialog to display based off of given missions      --
-- from an Entity                                                                                --
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------

console.Exec( "echo Loading a mission check file..." );


-- Definitions --
NOTASSIGNED = -1;
INPROGRESS  = 0;
COMPLETED   = 1; 
FAILED      = 2;
REWARDED    = 3;


-- Make sure the player is binded --
player.Init();

-- Function to discard the mission
function GiveReward( missionName )
--{
	dofile( missionName .. "_reward.lua" );
	player.SetMissionStatus( missionName, REWARDED );
--}
end

--[[---------------------------------------------------------------
--		Decides which dialog to play for the NPC
--		If a mission has been completed, it will run the
--		associated reward script.
--]]---------------------------------------------------------------
function GiveMission( mission_names )
--{
	--
	-- Test Missions --
	local i = 1;
	while (i <= #mission_names) 
	do

		console.Exec( "echo Mission " .. mission_names[i] .. " is " .. player.CheckMissionStatus(mission_names[i]) );
		-- If this mission has not been assigned, assign it
 		-- and pick the proper dialog to display
		if (not player.HasMission(mission_names[i]) )
		then
			-- Give the Player a new mission
			dialog.Create();
			dialog.LoadDialog( mission_names[i] .. ".dialog" );
			break;

		-- Mission is not done yet!
		elseif ( player.CheckMissionStatus(mission_names[i]) == INPROGRESS )
		then
			-- Display the inprogress dialog
			dialog.Create();
			dialog.LoadDialog( mission_names[i] .."_inprogress.dialog" );
			break;
			
		-- Mission has been completed, now give the player a reward!!!
		elseif ( player.CheckMissionStatus(mission_names[i]) == COMPLETED )
		then
			-- Give the player a reward
			GiveReward( mission_names[i] );		
			
		-- the Mission was a failer, most likely ask him to do it again
		elseif ( player.CheckMissionStatus(mission_names[i]) == FAILED )
		then
			-- Display the failed
			dialog.Create();
			dialog.LoadDialog( mission_names[i] .."_failed.dialog" );
			break;
		end

		-- Mission is marked as REWARDED so we skip it
		i= i+1;
		
	end
--}
end



See more files for this project here

palisma2d

The University of Wisconsin-Parkside Developers Union first product. More info to come. Code name Palisma.

Project homepage: http://code.google.com/p/palisma2d/
Programming language(s): C,C++
License: gpl2

  hitman_mission/
    hitman.dialog
    hitman.lua
    hitman.msn
    hitman_inprogress.dialog
    hitman_reward.dialog
    hitman_reward.lua
    hitman_setup.lua
  test_mission/
    HitPotSetup.lua
    m_hitPot.dialog
    m_hitPot.lua
    m_hitPot.msn
    m_hitPot_inprogress.dialog
    m_hitPot_reward.lua
    reward.dialog
  mission_check.lua