/*********************************************************************************************/ void z_Hostage::Created(GameObject *obj) { Commands->Enable_HUD_Pokable_Indicator(obj,true); Commands->Set_Player_Type(obj,-2); Commands->Clear_Weapons(obj); Commands->Innate_Disable(obj); Commands->Start_Timer(obj,this,1.0f,788); AllowPoke = true; Following = false; FollowID = 0; Pokerguy = 0; PokerTeam = Get_Int_Parameter("PokerTeam"); HostageID = Commands->Get_ID(obj); HostageHealth = Get_Float_Parameter("Hostage_Health"); HostageShield = Get_Float_Parameter("Hostage_Shield"); Set_Max_Health(obj,HostageHealth); Set_Max_Shield_Strength(obj,HostageShield); Commands->Set_Shield_Strength(obj,HostageShield); Commands->Set_Health(obj,HostageHealth); } void z_Hostage::Poked(GameObject *obj,GameObject *poker) { if ((AllowPoke) && (Commands->Get_Player_Type(poker) == PokerTeam)) { Pokerguy = poker; FollowID = Commands->Get_ID(poker); Commands->Enable_HUD_Pokable_Indicator(obj,false); Commands->Set_Player_Type(obj,Get_Int_Parameter("Hostage_Team")); Commands->Start_Timer(obj,this,0.5,789); AllowPoke = false; Following = true; Commands->Give_Money(Pokerguy,100.0f,0); int RandomNum = Commands->Get_Random_Int(1,5); if (RandomNum == 1 || RandomNum == 2) { Create_2D_WAV_Sound_Player(poker,"youlead.wav"); Send_Message_Player(poker,243,0,0,"Hostage: Ok you lead the way."); } else { Create_2D_WAV_Sound_Player(poker,"getouttahere.wav"); Send_Message_Player(poker,243,0,0,"Hostage: Let's get the hell outta here."); } } } void z_Hostage::Timer_Expired(GameObject *obj, int number) { if (number == 789)//this is the number we have been waiting for { if (Commands->Find_Object(FollowID))//w00t we found our hero to the rescue { GameObject *GotoObject = Commands->Find_Object(FollowID); ActionParamsStruct params; params.Set_Basic(this,100,100); params.Set_Goto_Following(GotoObject,1.0f,1.5f,true);//void Set_Goto_Following(GameObject *Target,float speed,float arrivedistance,bool following); Commands->Action_Goto(obj,params); Following = true; Commands->Start_Timer(obj,this,1.0f,789);//our hero is alive so we continue following Commands->Give_Money(Pokerguy,1.0f,0); } else//pokern00b died or left the game, stop following { Pokerguy = 0; FollowID = 0;//setting FollowID to 0 Following = false;//not following anymore AllowPoke = true;//poking is allowed again because the person poking the hostage died or left Commands->Enable_HUD_Pokable_Indicator(obj,true);//can poke again so adjust the indicators Commands->Set_Player_Type(obj,-2);//unteam the hostage so they are not attacked by bots anymore } } else if (number == 788) { float hlth = Commands->Get_Health(obj); hlth += Get_Float_Parameter("Health_Regen_Ammount"); float armr = Commands->Get_Shield_Strength(obj); armr += Get_Float_Parameter("Health_Regen_Ammount"); if (hlth > Commands->Get_Max_Health(obj)) { hlth = Commands->Get_Max_Health(obj); } if (armr > Commands->Get_Max_Shield_Strength(obj)) { armr = Commands->Get_Max_Shield_Strength(obj); } Commands->Set_Health(obj,hlth); Commands->Set_Shield_Strength(obj,armr); Commands->Start_Timer(obj,this,1.0f,788); } } void z_Hostage::Custom(GameObject *obj,int message,int param,GameObject *sender) { if (message == Get_Int_Parameter("Rescue_Message")) { if (param == 1) { Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("Controller_ID")),Get_Int_Parameter("Rescue_Message"),1,0.0f);//lets tell the controller a hostage was rescued Commands->Give_Money(Pokerguy,250.0f,0); Commands->Give_Points(Pokerguy,100.0f,0); Commands->Destroy_Object(obj);//destroy hostage, rescued, good work :P } } } void z_Hostage::Killed(GameObject *obj,GameObject *shooter) { if (Commands->Find_Object(Get_Int_Parameter("Controller_ID"))) { if (Commands->Is_A_Star(shooter)) { Commands->Give_Money(shooter,-100.0f,0); Commands->Give_Points(shooter,-100.0f,0); } Commands->Send_Custom_Event(obj, Commands->Find_Object(Get_Int_Parameter("Controller_ID")),Get_Int_Parameter("HostageDead_Message"),1,0.0);//hosty died, tell controller to increment deaths } } void z_Hostage::Register_Auto_Save_Variables() { Auto_Save_Variable(1,4,&HostageID); Auto_Save_Variable(2,4,&FollowID); } /*********************************************************************************************/ void z_Hostage_Controller::Created(GameObject *obj) { Commands->Start_Timer(obj,this,10.0f,800); Commands->Set_Player_Type(obj,-2); Set_Damage_Points(obj,0.0f); Attach_Script_Once(obj,"M00_Damage_Modifier_DME","0.00,1,1,0,0"); Commands->Enable_Vehicle_Transitions(obj,false); Commands->Enable_HUD_Pokable_Indicator(obj,false); hostagerescues = 0; hostagedeaths = 0; } void z_Hostage_Controller::Custom(GameObject *obj,int message,int param,GameObject *sender) { if (message == Get_Int_Parameter("Rescue_Message")) { if (param == 1) { hostagerescues++; Commands->Create_2D_WAV_Sound("rescued.wav"); Send_Message(255,255,255,"A hostage has been rescued!"); FDSMessage(StrFormat("A hostage has been rescued!"),"_ALERT"); } } else if (message == Get_Int_Parameter("HostageDead_Message")) { if (param == 1) { hostagedeaths++; Commands->Create_2D_WAV_Sound("hosdown.wav"); Send_Message(255,255,255,"Hostage down!"); FDSMessage(StrFormat("Hostage down."),"_ALERT"); } } if (hostagerescues == Get_Int_Parameter("Required_Rescues")) { hostagerescues = 0; Commands->Create_2D_WAV_Sound("rescued.wav"); int hostyteam = Get_Int_Parameter("Hostage_Team"); if (hostyteam == 0) { Commands->Start_Timer(obj,this,3.0f,787); hostagerescues = 0; } else if (hostyteam == 1) { Commands->Start_Timer(obj,this,3.0f,786); hostagerescues = 0; } } if (hostagedeaths == Get_Int_Parameter("Max_Hosty_Deaths")) { int hostyteam = Get_Int_Parameter("Hostage_Team"); if (hostyteam == 0) { Commands->Start_Timer(obj,this,3.0f,785); hostagedeaths = 0; } else if (hostyteam == 1) { Commands->Start_Timer(obj,this,3.0f,784); hostagedeaths = 0; } } } void z_Hostage_Controller::Timer_Expired(GameObject *obj, int number) { if (number == 787) { Console_Input("win 0"); Console_Input("win 0"); Console_Input("win 0"); Console_Input("amsg Good work Soviets: Mission Accomplished! All hostages were rescued!"); FDSMessage(StrFormat("Soviets have won the game, all hostages were rescued."),"_ALERT"); } else if (number == 786) { Console_Input("win 1"); Console_Input("win 1"); Console_Input("win 1"); Console_Input("amsg Good work Allies: Mission Accomplished! All hostages were rescued!"); FDSMessage(StrFormat("Allies have won the game, all hostages were rescued."),"_ALERT"); } if (number == 785) { Console_Input("win 1"); Console_Input("win 1"); Console_Input("win 1"); Console_Input("amsg All hostages were terminated, your mission failed Nod!"); FDSMessage(StrFormat("Allies have won the game, maximum hostage deaths was reached."),"_ALERT"); } else if (number == 784) { Console_Input("win 0"); Console_Input("win 0"); Console_Input("win 0"); Console_Input("amsg All hostages were terminated, your mission failed GDI!"); FDSMessage(StrFormat("Soviets have won the game, maximum hostage deaths was reached."),"_ALERT"); } else if (number == 800) { char msg[200]; char msg2[200]; char msg3[200]; sprintf(msg2,"msg This map requires %d number of rescues or %d number of hostage deaths.",Get_Int_Parameter("Required_Rescues"),Get_Int_Parameter("Max_Hosty_Deaths")); sprintf(msg,"msg Number of hostage rescues so far: %d.",hostagerescues); sprintf(msg3,"msg Number of hostage deaths so far: %d.",hostagedeaths); Console_Input(msg2);Console_Input(msg);Console_Input(msg3); Commands->Start_Timer(obj,this,61.0f,800); } } void z_Hostage_Controller::Register_Auto_Save_Variables() { Auto_Save_Variable(1,4,&hostagerescues); Auto_Save_Variable(2,4,&hostagedeaths); } /*********************************************************************************************/ void z_Hostage_Rescue_Zone::Entered(GameObject *obj,GameObject *enter) { int team = Get_Int_Parameter("Hostage_Team"); if ((Commands->Get_Player_Type(enter) == team) && (!Commands->Is_A_Star(enter))) { if ((strcmp(Commands->Get_Preset_Name(enter),(Get_Parameter("Hostage_Preset"))) == 0) || (strcmp(Commands->Get_Preset_Name(enter),(Get_Parameter("Hostage_Preset2"))) == 0) || (strcmp(Commands->Get_Preset_Name(enter),(Get_Parameter("Hostage_Preset3"))) == 0) || (strcmp(Commands->Get_Preset_Name(enter),(Get_Parameter("Hostage_Preset4"))) == 0) || (strcmp(Commands->Get_Preset_Name(enter),(Get_Parameter("Hostage_Preset5"))) == 0)) { Commands->Send_Custom_Event(obj,enter,(Get_Int_Parameter("Rescue_Message")),1,0.0f); } } } /*********************************************************************************************/