This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Script Request: end the game when team 2(Bot) is eliminated

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Locked
User avatar
The_JOKER
Fighter
Fighter
Posts: 38
Joined: Mon Jul 18, 2016 2:35 am
Title: I'm Korean JOKER :)
SFD Account: JOKER_Korea
SFD Alias: JOKER
Started SFD: April 2016
Location: South Korea
Gender:
Age: 25
Contact:

Script Request: end the game when team 2(Bot) is eliminated

Post by The_JOKER » Sun Jun 04, 2017 3:22 am

I need a full script that check if team 2(or Bot) is eliminated and end the game, when triggered by script trigger or area trigger

need that script to make wave surviving game

Also, I need script that end the game when all players dead(except bot)
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

Post by JakSparro98 » Sun Jun 04, 2017 3:59 pm

The_JOKER wrote:
Sun Jun 04, 2017 3:22 am
I need a full script that check if team 2(or Bot) is eliminated and end the game, when triggered by script trigger or area trigger

need that script to make wave surviving game

Also, I need script that end the game when all players dead(except bot)

Code: Select all

public void CheckStatus(TriggerArgs arg){
bool PlayerAlive=false;
bool BotsAlive=false;
	foreach(IPlayer temp in Game.GetPlayers())
 	{
		if(temp.IsBot && !temp.IsDead)
			BotsAlive=true;
		
		else if(!temp.IsDead)
			PlayerAlive=true;
	}
	//when bots are eliminated
	if(!BotsAlive)
	{
		Game.SetGameOver("bots dead");
		
	}
	//when there aren't players alive
	if(!PlayerAlive)
	{
		Game.SetGameOver("players dead");
		
	}

}
Let me know if it's what you wanted or if you need something else.
1 x

User avatar
The_JOKER
Fighter
Fighter
Posts: 38
Joined: Mon Jul 18, 2016 2:35 am
Title: I'm Korean JOKER :)
SFD Account: JOKER_Korea
SFD Alias: JOKER
Started SFD: April 2016
Location: South Korea
Gender:
Age: 25
Contact:

Post by The_JOKER » Mon Jun 05, 2017 4:45 am

JakSparro98 wrote:
Sun Jun 04, 2017 3:59 pm

Code: Select all

public void CheckStatus(TriggerArgs arg){
bool PlayerAlive=false;
bool BotsAlive=false;
	foreach(IPlayer temp in Game.GetPlayers())
 	{
		if(temp.IsBot && !temp.IsDead)
			BotsAlive=true;
		
		else if(!temp.IsDead)
			PlayerAlive=true;
	}
	//when bots are eliminated
	if(!BotsAlive)
	{
		Game.SetGameOver("bots dead");
		
	}
	//when there aren't players alive
	if(!PlayerAlive)
	{
		Game.SetGameOver("players dead");
		
	}

}
Let me know if it's what you wanted or if you need something else.
Thank you, This is what I wanted.
By the way I need one more script,
can you make script that activate trigger (Like Camera area trigger, Timer trigger) when Game ends?
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

Post by JakSparro98 » Mon Jun 05, 2017 2:46 pm

The_JOKER wrote:
Mon Jun 05, 2017 4:45 am
Thank you, This is what I wanted.
By the way I need one more script,
can you make script that activate trigger (Like Camera area trigger, Timer trigger) when Game ends?
Replace the code with this one:

Code: Select all

int ActivateOnce=0;
public void CheckStatus(TriggerArgs arg){
bool PlayerAlive=false;
bool BotsAlive=false;
	foreach(IPlayer temp in Game.GetPlayers())
 	{
		if(temp.IsBot && !temp.IsDead)
			BotsAlive=true;
		
		else if(!temp.IsDead)
			PlayerAlive=true;
	}
	//when bots are eliminated
	if(!BotsAlive)
	{
		Game.SetGameOver("bots dead");	
	}
	//when there aren't players alive
	if(!PlayerAlive)
	{
		Game.SetGameOver("players dead");
		
	}

	if((!BotsAlive || !PlayerAlive) && ActivateOnce==0)
	{
	ActivateOnce=1;
			foreach(IObjectTrigger temp in Game.GetObjectsByCustomID("ToActivate"))
			{
			temp.Trigger();
			}
	}
}
Then you need to add ToActivate as CustomID to all triggers you want to activate.
Keep in mind that the triggers will be activated once, when all players are all died or when the bots are.
0 x

User avatar
The_JOKER
Fighter
Fighter
Posts: 38
Joined: Mon Jul 18, 2016 2:35 am
Title: I'm Korean JOKER :)
SFD Account: JOKER_Korea
SFD Alias: JOKER
Started SFD: April 2016
Location: South Korea
Gender:
Age: 25
Contact:

Post by The_JOKER » Mon Jun 05, 2017 4:09 pm

JakSparro98 wrote:
Mon Jun 05, 2017 2:46 pm
Replace the code with this one:

Code: Select all

int ActivateOnce=0;
public void CheckStatus(TriggerArgs arg){
bool PlayerAlive=false;
bool BotsAlive=false;
	foreach(IPlayer temp in Game.GetPlayers())
 	{
		if(temp.IsBot && !temp.IsDead)
			BotsAlive=true;
		
		else if(!temp.IsDead)
			PlayerAlive=true;
	}
	//when bots are eliminated
	if(!BotsAlive)
	{
		Game.SetGameOver("bots dead");	
	}
	//when there aren't players alive
	if(!PlayerAlive)
	{
		Game.SetGameOver("players dead");
		
	}

	if((!BotsAlive || !PlayerAlive) && ActivateOnce==0)
	{
	ActivateOnce=1;
			foreach(IObjectTrigger temp in Game.GetObjectsByCustomID("ToActivate"))
			{
			temp.Trigger();
			}
	}
}
Then you need to add ToActivate as CustomID to all triggers you want to activate.
Keep in mind that the triggers will be activated once, when all players are all died or when the bots are.
Thank you, you helped me a lot making my first surviving map!
I will add you at the Credits on gameover ;)
0 x

Locked