예제 #1
0
파일: Intro.c 프로젝트: Fulgen301/openclonk
global func FxIntIntroTimer(object target, proplist effect, int time)
{
	if(effect.Time == 40)
	{
		effect.Sister->SetCommand("MoveTo", effect.Sister, effect.Cabin->GetX() + 65 - effect.Sister->GetX(), effect.Cabin->GetY() + 10 - effect.Sister->GetY());
	}

	if(effect.Time == 110)
		effect.Dialog->MessageBoxAll("$MsgIntro1$", effect.Sister);

	if(effect.Time == 150)
	{
		for(var crew in effect.Players)
		{
			crew = crew->Contained();

			crew->SetCommand("Exit", crew);
			crew->AppendCommand("MoveTo", crew, effect.Cabin->GetX() + RandomX(10,40) - crew->GetX(), effect.Cabin->GetY() - crew->GetY());
		}
	}

	if(effect.Time == 200)
		effect.Dialog->MessageBoxAll("$MsgIntro2$", GetCrew(GetPlayerByIndex(Random(GetPlayerCount())), 0));

	if(effect.Time == 270)
	{
		effect.Dialog->MessageBoxAll("$MsgIntro3$", effect.Sister);
	}

	if(effect.Time == 350)
	{
		effect.Sister->SetCommand("MoveTo", effect.Sister, 214 - effect.Sister->GetX(), 540 - effect.Sister->GetY());
	}

	if(effect.Time == 370)
	{
		for(var crew in effect.Players)
		{
			crew = crew->Contained();
			crew->SetCommand("MoveTo", crew, 245 - crew->GetX(), 555 - crew->GetY());
		}
	}

	if(effect.Time == 500)
	{
		effect.Sister->SetCommand("MoveTo", effect.Sister, 214 - effect.Sister->GetX(), 540 - effect.Sister->GetY());
		for(var crew in effect.Players)
			crew->Contained()->SetDir(DIR_Left);
		effect.Dialog->MessageBoxAll("$MsgIntro4$", GetCrew(GetPlayerByIndex(Random(GetPlayerCount())), 0));
	}
예제 #2
0
global func FxCheckForFlagTimer(pTarget, iEffectNumber) {
	// Lost the flag?
	if (!ObjectCount(FLAG))
		// Relaunch!
		GameCall("RelaunchPlayer", GetPlayerByIndex());
	return(1);
}
예제 #3
0
파일: Script.c 프로젝트: lluchs/Clinfinity
/*  Function: PointOut
	Creates a pointer for every player pointing to the calling object.

	Parameters:
	color   - Pointer's color modulation.
	message - A message shown above the pointer. */
global func PointOut(int color, string message) {
	for(var count = GetPlayerCount(), i = 0; i < count; i++) {
		var p = GetPlayerByIndex(i);
		CreatePointer(p, this, color, message);
	}
	return count;
}
예제 #4
0
파일: SeqIntro.c 프로젝트: aburgm/openclonk
func Intro_Stop()
{
	// Lava gets quiet after intro
	var lava = FindObject(Find_ID(BoilingLava));
	if (lava) lava->SetIntensity(25);
	// if players got stuck somewhere, unstick them
	for (var i=0; i<GetPlayerCount(C4PT_User); ++i)
	{
		var plr = GetPlayerByIndex(i, C4PT_User);
		var crew = GetCrew(plr);
		if (crew && !Inside(crew->GetX(),125,170))
		{
			crew->SetPosition(135+Random(25), 860);
		}
		crew->Extinguish();
		crew->DoEnergy(100);
	}
	this.dialogue->SetInteraction(true);
	this.dialogue->AddAttention();
	SetPlayerZoomByViewRange(NO_OWNER, 400,300, PLRZOOM_Set);
	
	// Turn and relocate the airplane to make starting it easier.
	var plane = FindObject(Find_ID(Airplane));
	if (plane)
	{
		plane->FaceLeft();
		plane->SetR(-90);
		plane->SetPosition(1387, 345);
	}
	return true;
}
예제 #5
0
func Intro_PlaneHit()
{
	// Plane hit ground! Continue sequence.
	Sound("Objects::Plane::PlaneCrash", true);
	SetR(-90);
	var particles = Particles_Smoke(true);
	particles.Size = PV_Linear(PV_Random(20, 60), PV_Random(50, 100));
	CreateParticle("Smoke", PV_Random(-30,30), PV_Random(-30,30), PV_Random(-60, 60), PV_Random(-20,0), PV_Random(200, 500), particles, 20);
	particles.Size = PV_Linear(PV_Random(50, 80), PV_Random(100, 200));
	CreateParticle("Smoke", PV_Random(-30,30), PV_Random(-30,30), PV_Random(-20, 20), PV_Random(-20,0), PV_Random(100, 200), particles, 20);
	for (var iplr=0,plr; iplr<GetPlayerCount(C4PT_User); ++iplr)
	{
		plr = GetPlayerByIndex(iplr, C4PT_User);
		var icrew=0,crew;
		while (crew=GetCrew(plr, icrew++))
		{
			crew->Exit(0,-5, 0, Random(1)+1, Random(5)-6);
			crew->SetAction("Tumble");
		}
	}
	SetMeshMaterial("CrashedAirplane");
	this.MeshTransformation=Trans_Mul(Trans_Rotate(10,0,2,1), Airplane.MeshTransformation);
	this.Hit = this.intro_seq.plane_Hit;
	this.intro_seq.plane_crashed = true;
	this.intro_seq->ScheduleNext(50);
	return true;
}
예제 #6
0
func InitializePlayer(int plr)
{
	var i;
	// Script player owns power crystals
	if (GetPlayerType(plr) == C4PT_Script)
	{
		g_crystal_player = plr;
		for (i=0; i<GetPlayerCount(C4PT_User); ++i) SetHostility(plr, GetPlayerByIndex(i, C4PT_User), true, true, true);
		while (GetCrew(plr)) GetCrew(plr)->RemoveObject();
		InitPowerCrystals(plr);
		return true;
	}
	if (g_crystal_player != NO_OWNER) SetHostility(g_crystal_player, plr, true, true, true);
	// First player init base
	if (!g_was_player_init)
	{
		CreateScriptPlayer("POMMES", 0, 0, CSPF_FixedAttributes | CSPF_NoEliminationCheck | CSPF_Invisible);
		InitBase(plr);
		g_was_player_init = true;
	}
	// Position and materials
	var crew;
	for (i=0; crew=GetCrew(plr,i); ++i)
	{
		crew->SetPosition(2100+Random(40), 233-10);
		crew->CreateContents(Shovel);
	}
	return true;
}
예제 #7
0
func Initialize()
{
	// Bin ich der erste?
	if(!FindObject(GetID()))
	{
		SetAction("Master");
		SetPosition(16,16);
		aTools = [0,0,0,0,0,0];
		for(var i = 0; i < 9; i++)
		{
			aTools[i] = CreateObject(GetID(), 26+35*i, 26, -1);
			aTools[i]->SetAction("Tool");
			aTools[i]->SetDir(0);
			aTools[i]->SetPhase(i);
			aTools[i]->LocalN("pMaster") = this;
			aTools[i]->LocalN("iToolID") = i;
		}
		aTools[0]->SetDir(1);
		iMode = -1;
		SetShape();
		if(GetPlayerCount(C4PT_User))
		{
			var iPlr = GetPlayerByIndex(0, C4PT_User);
			SetOwner(iPlr);
			MakeCrewMember(this, iPlr);
			SetFoW(0, iPlr);
			SetCursor(iPlr, this);
		}
	}
예제 #8
0
파일: MatSys.c 프로젝트: lluchs/Clinfinity
/*  Function: CreateMatSys
    Creates a material system for the given player or for every player if iPlr == NO_OWNER.

	Parameters:
	iPlr - The player for whom the material system should be created or NO_OWNER. */
global func CreateMatSys(int iPlr) {
	if(iPlr == NO_OWNER)
		for(var i = 0; i < GetPlayerCount(); i++)
			CreateMatSys(GetPlayerByIndex(i));
	else
		CreateObject(MSYS, 0, 0, iPlr);
}
예제 #9
0
파일: MatSys.c 프로젝트: lluchs/Clinfinity
/*  Function: MatSysGetTeamFill
    
	Parameters:
	plr - A player of the team whose fill level should be returned.
	Key - The material id.

	Returns:
	The combined fill level of all team members. */
global func MatSysGetTeamFill(int plr, id Key) {
	var fill = 0;
	for(var count = GetPlayerCount(), i = 0; i < count; i++) {
		var p = GetPlayerByIndex(i);
		if(!Hostile(plr, p))
			fill += MatSysGetFill(p, Key);
	}
	return fill;
}
예제 #10
0
int PlayerManager::GetClientOfUserId(int userid)
{
	if (userid < 0 || userid > USHRT_MAX)
	{
		return 0;
	}
	
	int client = m_UserIdLookUp[userid];

	/* Verify the userid.  The cache can get messed up with older
	 * Valve engines.  :TODO: If this gets fixed, do an old engine 
	 * check before invoking this backwards compat code.
	 */
	if (client)
	{
		CPlayer *player = GetPlayerByIndex(client);
		if (player && player->IsConnected())
		{
			int realUserId = engine->GetPlayerUserId(player->GetEdict());
			if (realUserId == userid)
			{
				return client;
			}
		}
	}

	/* If we can't verify the userid, we have to do a manual loop */
	CPlayer *player;
	for (int i = 1; i <= m_maxClients; i++)
	{
		player = GetPlayerByIndex(i);
		if (!player || !player->IsConnected())
		{
			continue;
		}
		if (engine->GetPlayerUserId(player->GetEdict()) == userid)
		{
			m_UserIdLookUp[userid] = i;
			return i;
		}
	}

	return 0;
}
예제 #11
0
global func TutorialMessage(string strMessage)
{
	// Message with speech marker
	if (HasSpeech(strMessage))
		// PlayerMessage will handle the speech output (and it won't show the message)
		PlayerMessage(0, strMessage);
	// Normal message display, in addition to speech output
	if (GetLength(strMessage)) strMessage = Format("@%s", strMessage);
	CustomMessage(strMessage, 0, GetPlayerByIndex(0), g_msgoffx, g_msgoffy, 0xffffff, DECO, "Portrait:SCLK::0000ff::1", g_msgpos | MSG_DropSpeech, g_msgwdt);
}
예제 #12
0
protected func Initialize()
{
  _inherited();
  // Alle Verbündeten des Besitzers speichern
  for(var i=0, l=0 ; i < GetPlayerCount() ; i++)
    if(GetPlayerByIndex(i) > -1)
      if(!Hostile(GetOwner(), i))
        {
        Local(l) = i+1;
        l++;
        }
}
예제 #13
0
global func StartSzen()
{
	for(var i = 0; i < GetPlayerCount(C4PT_User); i++)
	{
		GetCursor(GetPlayerByIndex(i,C4PT_User))->~StopClonkEx();
		GameCall("PlayerStart", GetPlayerByIndex(i,C4PT_User));
	}
	GameCall("DoStartSzen", GetPlayerByIndex(i,C4PT_User));

	// Spielziel erzeugen
	if(!FindObject(SCRG)) CreateObject(SCRG);
	
	// Neu Initialisierung
	var story = FindObject(_STY);
	if(GetID() == _STY) story = this;
	if(!story) story = CreateObject(_STY);
	story->~DoStartSzen();

	// Gemeinschaftskonto
	if(!FindObject(TACC) && GetPlayerCount(C4PT_User) > 1) CreateObject(TACC);
}
예제 #14
0
func Initialize()
{
	if (g_camera) FatalError("OMG two cameras!");
	g_camera = this;
	// Make action modifyable
	this.ActMap = {Prototype = Camera.ActMap };
	this.ActMap.Fly = {Prototype = Camera.ActMap.Fly };
	SetAction("Fly");
	for (var i=0; i<GetPlayerCount(C4PT_User); ++i)
		SetPlrView(GetPlayerByIndex(i, C4PT_User), this);
	SetPlayerViewLock(NO_OWNER, true);
}
예제 #15
0
파일: MatSys.c 프로젝트: lluchs/Clinfinity
/*  Function: MatSysDoTeamFill
    Changes the fill level for a given team/id.
    
	Parameters:
	change - The amount of change.
	plr    - A player of the team whose fill level should be changed.
	Key    - The material id.

	Returns:
	The actual change. */
global func MatSysDoTeamFill(int change, int plr, id Key) {
	var orig = change;
	// first, try the given player
	change -= MatSysDoFill(change, plr, Key, true);
	// then, loop through the other players
	for(var count = GetPlayerCount(), i = 0; i < count && change != 0; i++) {
		var p = GetPlayerByIndex(i);
		if(!Hostile(plr, p)) {
			change -= MatSysDoFill(change, p, Key);
		}
	}
	var actual = orig - change;
	MatSysMessage(actual, Key);
	return actual;
}
예제 #16
0
global func DoInitPlayer(int player)
{
	var index = 0;
	while(GetPlayerByIndex(index, C4PT_User) != player && index < GetPlayerCount(C4PT_User)) index++;
	var pClonk = GetHiRank(player);
	SetFoW(1, player);
	SetPlrViewRange(0, pClonk);
	pClonk->SetRelaunch();

	// Storyobject erzeugen
	if(!FindObject(_STY))
	{
		CreateObject(_STY)->~Start();
	}
}
예제 #17
0
파일: SeqIntro.c 프로젝트: aburgm/openclonk
func Intro_17()
{
	this.pilot->SetCommand("MoveTo", nil, 120, 860);
	for (var i=0; i<GetPlayerCount(C4PT_User); ++i)
	{
		var plr = GetPlayerByIndex(i, C4PT_User);
		var crew = GetCrew(plr);
		if (crew)
		{
			crew->SetCommand("MoveTo", nil, 135+Random(25), 860);
		}
	}
	this.timer=0;
	return ScheduleNext(100);
}
예제 #18
0
파일: Script.c 프로젝트: aburgm/openclonk
func MakeHostileToAll(int newplr, int team)
{
	// If the player is in a team, don't change hostility.
	if (team) return;

	// Otherwise, make all other players enemies.
	for (var i = 0; i < GetPlayerCount(); i++)
	{
		var plr = GetPlayerByIndex(i);
		if (plr == newplr) continue;
		
		SetHostility(newplr, plr, true, true);
		SetHostility(plr, newplr, true, true);
	}
}
예제 #19
0
파일: Script.c 프로젝트: 772/openclonk
global func CreateAttackWave(int angle, int rockets, int anglespread)
{
	var radius = Min(LandscapeWidth()/2, LandscapeHeight()/2);
	var rocket_id = Boomattack;
	// boss
	if(rockets == -1)
	{
		rockets = 1;
		rocket_id = BigBoomattack;
	}
	
	for(var i=0; i<rockets; ++i)
	{
		var rocket_angle = angle + Random(anglespread) - anglespread/2;
		var rocket_radius = radius * RandomX(80,100) / 100;
		var x =  Sin(rocket_angle, rocket_radius)+LandscapeWidth()/2;
		var y = -Cos(rocket_angle, rocket_radius)+LandscapeHeight()/2;

		CreateObjectAbove(rocket_id, x, y)->Launch(rocket_angle + 180);
	}
	
	for(var i=0; i<GetPlayerCount(); ++i)
	{
		var owner = GetPlayerByIndex(i);
		var gui_arrow = FindObject(Find_ID(GUI_GoalArrow), Find_Owner(owner));
		if(!gui_arrow)
		{
			gui_arrow = CreateObjectAbove(GUI_GoalArrow,0,0,owner);
			gui_arrow->SetAction("Show", GetCursor(owner));
			gui_arrow->SetClrModulation(RGB(255,0,0));
			gui_arrow->SetObjectBlitMode(GFX_BLIT_Mod2);
		}
		gui_arrow->SetR(angle);
		gui_arrow.Plane = 500;
	}
}
예제 #20
0
void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
{
	CPlayer *pTarget, *pAdmin;
	int max_clients, total = 0;

	max_clients = GetMaxClients();

	if (info->max_targets < 1)
	{
		info->reason = COMMAND_TARGET_NONE;
		info->num_targets = 0;
	}

	if (info->admin == 0)
	{
		pAdmin = NULL;
	}
	else
	{
		pAdmin = GetPlayerByIndex(info->admin);
	}

	if (info->pattern[0] == '#')
	{
		int userid = atoi(&info->pattern[1]);
		int client = GetClientOfUserId(userid);

		/* See if a valid userid matched */
		if (client > 0)
		{
			IGamePlayer *pTarget = GetPlayerByIndex(client);
			if (pTarget != NULL)
			{
				if ((info->reason = FilterCommandTarget(pAdmin, pTarget, info->flags)) == COMMAND_TARGET_VALID)
				{
					info->targets[0] = client;
					info->num_targets = 1;
					strncopy(info->target_name, pTarget->GetName(), info->target_name_maxlength);
					info->target_name_style = COMMAND_TARGETNAME_RAW;
				}
				else
				{
					info->num_targets = 0;
				}
				return;
			}
		}

		/* Do we need to look for a steam id? */
		if (strncmp(&info->pattern[1], "STEAM_", 6) == 0)
		{
			size_t p, len;
			char new_pattern[256];

			strcpy(new_pattern, "STEAM_");
			len = strlen(&info->pattern[7]);
			for (p = 0; p < len; p++)
			{
				new_pattern[6 + p] = info->pattern[7 + p];
				if (new_pattern[6 + p] == '_')
				{
					new_pattern[6 + p] = ':';
				}
			}
			new_pattern[6 + p] = '\0';

			for (int i = 1; i <= max_clients; i++)
			{
				if ((pTarget = GetPlayerByIndex(i)) == NULL)
				{
					continue;
				}
				if (!pTarget->IsConnected() || !pTarget->IsAuthorized())
				{
					continue;
				}
				if (strcmp(pTarget->GetAuthString(), new_pattern) == 0)
				{
					if ((info->reason = FilterCommandTarget(pAdmin, pTarget, info->flags))
						== COMMAND_TARGET_VALID)
					{
						info->targets[0] = i;
						info->num_targets = 1;
						strncopy(info->target_name, pTarget->GetName(), info->target_name_maxlength);
						info->target_name_style = COMMAND_TARGETNAME_RAW;
					}
					else
					{
						info->num_targets = 0;
					}
					return;
				}
			}
		}

		/* See if an exact name matches */
		for (int i = 1; i <= max_clients; i++)
		{
			if ((pTarget = GetPlayerByIndex(i)) == NULL)
			{
				continue;
			}
			if  (!pTarget->IsConnected())
			{
				continue;
			}
			if (strcmp(pTarget->GetName(), &info->pattern[1]) == 0)
			{
				if ((info->reason = FilterCommandTarget(pAdmin, pTarget, info->flags))
					== COMMAND_TARGET_VALID)
				{
					info->targets[0] = i;
					info->num_targets = 1;
					strncopy(info->target_name, pTarget->GetName(), info->target_name_maxlength);
					info->target_name_style = COMMAND_TARGETNAME_RAW;
				}
				else
				{
					info->num_targets = 0;
				}
				return;
			}
		}
	}

	if (strcmp(info->pattern, "@me") == 0 && info->admin != 0)
	{
		info->targets[0] = info->admin;
		info->num_targets = 1;
		strncopy(info->target_name, pAdmin->GetName(), info->target_name_maxlength);
		info->target_name_style = COMMAND_TARGETNAME_RAW;
		return;
	}

	if ((info->flags & COMMAND_FILTER_NO_MULTI) != COMMAND_FILTER_NO_MULTI)
	{
		bool is_multi = false;
		bool bots_only = false;
		int skip_client = -1;

		if (strcmp(info->pattern, "@all") == 0)
		{
			is_multi = true;
			strncopy(info->target_name, "all players", info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_ML;
		}
		else if (strcmp(info->pattern, "@dead") == 0)
		{
			is_multi = true;
			if ((info->flags & COMMAND_FILTER_ALIVE) == COMMAND_FILTER_ALIVE)
			{
				info->num_targets = 0;
				info->reason = COMMAND_TARGET_NOT_ALIVE;
				return;
			}
			info->flags |= COMMAND_FILTER_DEAD;
			strncopy(info->target_name, "all dead players", info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_ML;
		}
		else if (strcmp(info->pattern, "@alive") == 0)
		{
			is_multi = true;
			if ((info->flags & COMMAND_FILTER_DEAD) == COMMAND_FILTER_DEAD)
			{
				info->num_targets = 0;
				info->reason = COMMAND_TARGET_NOT_DEAD;
				return;
			}
			strncopy(info->target_name, "all alive players", info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_ML;
			info->flags |= COMMAND_FILTER_ALIVE;
		}
		else if (strcmp(info->pattern, "@bots") == 0)
		{
			is_multi = true;
			if ((info->flags & COMMAND_FILTER_NO_BOTS) == COMMAND_FILTER_NO_BOTS)
			{
				info->num_targets = 0;
				info->reason = COMMAND_FILTER_NO_BOTS;
				return;
			}
			strncopy(info->target_name, "all bots", info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_ML;
			bots_only = true;
		}
		else if (strcmp(info->pattern, "@humans") == 0)
		{
			is_multi = true;
			strncopy(info->target_name, "all humans", info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_ML;
			info->flags |= COMMAND_FILTER_NO_BOTS;
		}
		else if (strcmp(info->pattern, "@!me") == 0)
		{
			is_multi = true;
			strncopy(info->target_name, "all players", info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_ML;
			skip_client = info->admin;
		}

		if (is_multi)
		{
			for (int i = 1; i <= max_clients && total < info->max_targets; i++)
			{
				if ((pTarget = GetPlayerByIndex(i)) == NULL)
				{
					continue;
				}
				if (FilterCommandTarget(pAdmin, pTarget, info->flags) > 0)
				{
					if ((!bots_only || pTarget->IsFakeClient())
						&& skip_client != i)
					{
						info->targets[total++] = i;
					}
				}
			}

			info->num_targets = total;
			info->reason = (info->num_targets) ? COMMAND_TARGET_VALID : COMMAND_TARGET_EMPTY_FILTER;
			return;
		}
	}

	List<ICommandTargetProcessor *>::iterator iter;
	for (iter = target_processors.begin(); iter != target_processors.end(); iter++)
	{
		ICommandTargetProcessor *pProcessor = (*iter);
		if (pProcessor->ProcessCommandTarget(info))
		{
			return;
		}
	}

	/* Check partial names */
	int found_client = 0;
	CPlayer *pFoundClient = NULL;
	for (int i = 1; i <= max_clients; i++)
	{
		if ((pTarget = GetPlayerByIndex(i)) == NULL)
		{
			continue;
		}

		if (stristr(pTarget->GetName(), info->pattern) != NULL)
		{
			if (found_client)
			{
				info->num_targets = 0;
				info->reason = COMMAND_TARGET_AMBIGUOUS;
				return;
			}
			else
			{
				found_client = i;
				pFoundClient = pTarget;
			}
		}
	}

	if (found_client)
	{
		if ((info->reason = FilterCommandTarget(pAdmin, pFoundClient, info->flags)) 
			== COMMAND_TARGET_VALID)
		{
			info->targets[0] = found_client;
			info->num_targets = 1;
			strncopy(info->target_name, pFoundClient->GetName(), info->target_name_maxlength);
			info->target_name_style = COMMAND_TARGETNAME_RAW;
		}
		else
		{
			info->num_targets = 0;
		}
	}
	else
	{
		info->num_targets = 0;
		info->reason = COMMAND_TARGET_NONE;
	}
}
예제 #21
0
IGamePlayer *PlayerManager::GetGamePlayer(int client)
{
	return GetPlayerByIndex(client);
}