/* 
MAIN Kreia's Assorted Robe Collection Functions script...
============================================================================
nP1, is the (P1) script parameter setting for dialogue files
nP2, is the (P2) script parameter setting for dialogue files
nP3, is the (P3) script parameter setting for dialogue files
nP4, is the (P4) script parameter setting for dialogue files
nP5, is the (P5) script parameter setting for dialogue files
sTag is the (String Param) setting for tag fields in dialogue files

Like I'll ever use all of the parameters... still, they're here if anyone else wants to add some joy :D
*/

void main ()
{

int nP1 = GetScriptParameter (1);
int nP2 = GetScriptParameter (2);
int nP3 = GetScriptParameter (3);
int nP4 = GetScriptParameter (4);
int nP5 = GetScriptParameter (5);
string sTag = GetScriptStringParameter();

////////   204TEL - 082 West Residential Intensive Care Spawn   \\\\\\\\\\

if (nP1 == 5)
 {
  if (nP2 == 5) /////   Open Intensive Care Door & Spawn Placeables   \\\\\
	{
	  object oDoor=GetNearestObject(OBJECT_TYPE_DOOR,GetFirstPC());
	  SetLocked(oDoor,FALSE);
	  ActionOpenDoor(oDoor);

    	  location MyLoc1 = Location(Vector(-66.33f,10.50f,-0.00f), 270.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bench", MyLoc1);

	  location MyLoc2 = Location(Vector(-66.33f,12.50f,-0.00f), 270.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bench", MyLoc2);

    	  location MyLoc3 = Location(Vector(-66.33f,14.50f,-0.00f), 270.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bench", MyLoc3);

    	  location MyLoc4 = Location(Vector(-64.62f,15.23f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_plant2", MyLoc4);

    	  location MyLoc5 = Location(Vector(-65.00f,8.40f,2.0f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_swoopmon02", MyLoc5);

    	  location MyLoc6 = Location(Vector(-54.75f,10.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bench", MyLoc6);

    	  location MyLoc7 = Location(Vector(-54.75f,12.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bench", MyLoc7);

    	  location MyLoc8 = Location(Vector(-54.75f,14.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bench", MyLoc8);

    	  location MyLoc9 = Location(Vector(-57.46f,15.23f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_plant2", MyLoc9);

    	  location MyLoc10 = Location(Vector(-57.46f,8.40f,2.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_swoopmon02", MyLoc10);

    	  location MyLoc11 = Location(Vector(-66.33f,1.00f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_kolp1", MyLoc11);

    	  location MyLoc12 = Location(Vector(-66.33f,3.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "pnl_cputercon01", MyLoc12);

    	  location MyLoc13 = Location(Vector(-66.33f,5.90f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_kolp1", MyLoc13);

    	  location MyLoc14 = Location(Vector(-61.50f,0.75f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_plant1", MyLoc14);

    	  location MyLoc15 = Location(Vector(-45.25f,1.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bed1", MyLoc15);

    	  location MyLoc16 = Location(Vector(-46.25f,0.35f,-0.59f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_filecabinet", MyLoc16);

    	  location MyLoc17 = Location(Vector(-48.25f,1.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bed1", MyLoc17);

    	  location MyLoc18 = Location(Vector(-49.25f,0.35f,-0.59f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_filecabinet", MyLoc18);

    	  location MyLoc19 = Location(Vector(-51.25f,1.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bed1", MyLoc19);

    	  location MyLoc20 = Location(Vector(-52.25f,0.35f,-0.59f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_filecabinet", MyLoc20);

    	  location MyLoc21 = Location(Vector(-54.25f,1.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bed1", MyLoc21);

    	  location MyLoc22 = Location(Vector(-55.25f,0.35f,-0.59f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_filecabinet", MyLoc22);

    	  location MyLoc23 = Location(Vector(-57.25f,1.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bed1", MyLoc23);

    	  location MyLoc24 = Location(Vector(-58.25f,0.35f,-0.59f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_filecabinet", MyLoc24);

    	  location MyLoc25 = Location(Vector(-40.90f,7.77f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_desk", MyLoc25);

    	  location MyLoc26 = Location(Vector(-38.82f,1.60f,-0.00f), 315.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_plant_tel01", MyLoc26);

    	  location MyLoc27 = Location(Vector(-38.82f,14.20f,-0.00f), 45.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_plant_tel01", MyLoc27);

    	  location MyLoc28 = Location(Vector(-50.60f,8.65f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_koltank", MyLoc28);

    	  location MyLoc29 = Location(Vector(-50.60f,10.65f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_koltank", MyLoc29);

    	  location MyLoc30 = Location(Vector(-50.60f,12.65f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_koltank", MyLoc30);

    	  location MyLoc31 = Location(Vector(-49.76f,14.65f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_powgen01", MyLoc31);

    	  location MyLoc32 = Location(Vector(-53.55f,6.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_plstccrt", MyLoc32);

    	  location MyLoc33 = Location(Vector(-54.55f,6.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_plstccrt", MyLoc33);

    	  location MyLoc34 = Location(Vector(-55.55f,6.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_plstccrt", MyLoc34);

    	  location MyLoc35 = Location(Vector(-56.55f,6.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_plstccrt", MyLoc35);

    	  location MyLoc36 = Location(Vector(-57.55f,6.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_plstccrt", MyLoc36);

    	  location MyLoc37 = Location(Vector(-41.95f,15.20f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_sign", MyLoc37);

    	  location MyLoc38 = Location(Vector(-38.03f,32.41f,-0.00f), 270.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_partpile", MyLoc38);

	  location MyLoc39 = Location(Vector(-41.87f,29.26f,-0.00f), 78.0);
	  CreateObject(OBJECT_TYPE_PLACEABLE, "kds_khag", MyLoc39);

	  location MyLoc39b = Location(Vector(-41.87f,29.25f,-0.00f), 78.0);
	  CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bldpdllg", MyLoc39b);

    	  location MyLoc40 = Location(Vector(-38.04f,19.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_lockerlg", MyLoc40);

    	  location MyLoc41 = Location(Vector(-38.04f,20.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_lockerlg", MyLoc41);

    	  location MyLoc42 = Location(Vector(-38.04f,21.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_lockerlg", MyLoc42);

    	  location MyLoc43 = Location(Vector(-38.04f,22.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_lockerlg", MyLoc43);

    	  location MyLoc44 = Location(Vector(-38.04f,23.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_lockerlg", MyLoc44);

    	  location MyLoc45 = Location(Vector(-38.04f,24.50f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_lockerlg", MyLoc45);

    	  location MyLoc46 = Location(Vector(-38.04f,27.65f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_workb_rep", MyLoc46);

    	  location MyLoc47 = Location(Vector(-40.00f,32.00f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_kiosk", MyLoc47);

    	  location MyLoc48 = Location(Vector(-51.00f,32.25f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_medcan", MyLoc48);

    	  location MyLoc49 = Location(Vector(-51.00f,29.50f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_medcan", MyLoc49);

    	  location MyLoc50 = Location(Vector(-51.00f,21.50f,-0.00f), 360.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_medcan", MyLoc50);

    	  location MyLoc51 = Location(Vector(-51.00f,18.75f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_medcan", MyLoc51);

    	  location MyLoc52 = Location(Vector(-50.50f,23.50f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_metalbox", MyLoc52);

    	  location MyLoc53 = Location(Vector(-50.50f,26.50f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_metalbox", MyLoc53);

    	  location MyLoc54 = Location(Vector(-43.11f,31.75f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_metalbox", MyLoc54);

    	  location MyLoc55 = Location(Vector(-46.11f,31.75f,-0.00f), 180.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_metalbox", MyLoc55);

    	  location MyLoc56 = Location(Vector(-44.50f,16.74f,-0.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "plc_blockage", MyLoc56);

    	  location MyLoc57 = Location(Vector(-43.00f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc57);

    	  location MyLoc58 = Location(Vector(-43.50f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc58);

    	  location MyLoc59 = Location(Vector(-44.00f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc59);

    	  location MyLoc60 = Location(Vector(-44.50f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc60);

    	  location MyLoc61 = Location(Vector(-45.00f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc61);

    	  location MyLoc62 = Location(Vector(-45.50f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc62);

    	  location MyLoc63 = Location(Vector(-46.00f,16.74f,-3.00f), 90.0);
          CreateObject(OBJECT_TYPE_PLACEABLE, "kds_smdoor", MyLoc63);

	  location MyLoc64 = Location(Vector(-44.64f,25.38f,-0.00f), 270.0);
	  CreateObject(OBJECT_TYPE_CREATURE, "kds_drdprobe", MyLoc64);
	}
 }

///////////////  204TEL - Medical Storage & Maintenance Options   \\\\\\\\\\\\\

if (nP1 == 1)
 {
  if (nP2 == 1) /////   Access Storage Area   \\\\\
	{
	  int nId1 = 0;
	  object oMsd = GetObjectByTag("kds_smdoor");

	  while (GetIsObjectValid(oMsd))
	   {
	     DestroyObject(oMsd);
	     oMsd = GetObjectByTag("kds_smdoor", ++nId1);
	   }

	  int nId2 = 0;
	  object oBlk = GetObjectByTag("Blockage");

	  while (GetIsObjectValid(oBlk))
	   {
	     DestroyObject(oBlk);
	     oBlk = GetObjectByTag("Blockage", ++nId2);
	   }

	   /////   Change Droid into a BadAss (yeah right)  \\\\\
	   object oNPC= GetObjectByTag("kds_drdprobe");
	   ChangeToStandardFaction(oNPC, 1);
	}
 }

//////////////////////////////   204TEL - Kolto Tanks   \\\\\\\\\\\\\\\\\\\\\\\\

if (nP1 == 2)
 {
  if (nP2 == 1) /////   Activate Kolto Tank   \\\\\
	 {
    	   location MyLoc65 = Location(Vector(-48.60f,10.65f,1.00f), 180.0);
           CreateObject(OBJECT_TYPE_PLACEABLE, "kds_pc_kolto", MyLoc65);
	 }

  if (nP2 == 2) /////   De-Activate Kolto Tank   \\\\\
	 {
	   object oKlt = GetObjectByTag("kds_pc_kolto");

	   if (GetIsObjectValid(oKlt))
	   {
	     DestroyObject(oKlt);
	   }
	 }

  if (nP2 == 3) /////   Kolto Heal PC/Party   \\\\\
	 {
	   object oNpc1 = GetPartyMemberByIndex(0);
	   object oNpc2 = GetPartyMemberByIndex(1);
	   object oNpc3 = GetPartyMemberByIndex(2);
	   int int1 = (GetMaxHitPoints(oNpc1) - GetCurrentHitPoints(oNpc1));

	   if ((int1 > 0))
	    {
	      if (GetIsObjectValid(oNpc1))
		 {
		   ApplyEffectToObject(0, EffectHeal(int1), oNpc1, 0.0);
		 }
	    }
	   int1 = (GetMaxHitPoints(oNpc2) - GetCurrentHitPoints(oNpc2));
	   if ((int1 > 0))
	    {
	      if (GetIsObjectValid(oNpc2))
		 {
		   ApplyEffectToObject(0, EffectHeal(int1), oNpc2, 0.0);
		 }
	    }
	   int1 = (GetMaxHitPoints(oNpc3) - GetCurrentHitPoints(oNpc3));
	   if ((int1 > 0))
	    {
	      if (GetIsObjectValid(oNpc3))
		 {
		   ApplyEffectToObject(0, EffectHeal(int1), oNpc3, 0.0);
		 }
	    }
	  }
 }

////////////   EbonHawke Invis Placeables & Dark Shroud Cutscene Stuff  \\\\\\\\\\

if (nP1 == 1)
 {
  if (nP2 == 2) /////   Spawn Placeables for Camera   \\\\\
	 {
    	   location MyLoc66 = Location(Vector(49.67f,29.98f,1.80f), 155.0);
           CreateObject(OBJECT_TYPE_PLACEABLE, "kds_invis1", MyLoc66);

	   location MyLoc67 = Location(Vector(36.80f,40.71f,1.80f), 135.0);
           CreateObject(OBJECT_TYPE_PLACEABLE, "kds_invis2", MyLoc67);
	 }

  if (nP2 == 3) /////   Destroy Placeables for Camera   \\\\\
	 {
	   object oInv1 = GetObjectByTag("kds_invis1");

	   if (GetIsObjectValid(oInv1))
	   {
	     DestroyObject(oInv1);
	   }
	   object oInv2 = GetObjectByTag("kds_invis2");

	   if (GetIsObjectValid(oInv2))
	   {
	     DestroyObject(oInv2);
	   }
	 }

  if (nP2 == 4) /////   Give PC Dark Shroud & Cleanup Inventory   \\\\\
	 {
	   object oPC=GetFirstPC();

	   CreateItemOnObject("kreia_shroud", oPC, 1);

	   /////   Destroy Shroud Components after creation   \\\\\
	   DestroyObject(GetObjectByTag ("kds_materials"));
	   DestroyObject(GetObjectByTag ("kds_mech_jrnl"));
	   DestroyObject(GetObjectByTag ("kds_mech_parts"));
	 }
 }

////////////////////////////   Experience Point Awards   \\\\\\\\\\\\\\\\\\\\\\\\

if (nP1 == 3)
 {
  if (nP2 == 1) /////   Award PC 250 Experience Points   \\\\\
	 {
	   GiveXPToCreature(GetFirstPC(),250);
	 }

  if (nP2 == 2) /////   Award PC 500 Experience Points   \\\\\
	 {
	   GiveXPToCreature(GetFirstPC(),500);
	 }

  if (nP2 == 3) /////   Award PC 1,000 Experience Points   \\\\\
	 {
	   GiveXPToCreature(GetFirstPC(),1000);
	 }
 }
}