Topic Development / Scenario & Object Development / [QUESTION]How to set Clonk respawn depending on team id?
I need to make clonks from team with id1 spawn on [125, 100],[125, 210],[125, 320],[125, 430] when clonks from team with id2 will spawn on [675, 100],[675, 210],[675, 320],[675, 430]
I have tried different ways to make it, but it wasn't working, so I have removed this useless code. Can anybody help me?
Update 1:
Here is my code:
protected func InitializePlayer(int plr)
{
return RelaunchPlayer(plr);
}
protected func RelaunchPlayer(int plr)
{
var clonk = GetCrew(plr);
clonk->DoEnergy(1000);
var pos = [[125, 100],[125, 210],[125, 320],[125, 430],[675, 100],[675, 210],[675, 320],[675, 430]];
var random=Random(GetLength(pos));
var x = pos[random][0], y = pos[random][1];
var relaunch = CreateObject(RelaunchContainer, x, y, clonk->GetOwner());
relaunch->StartRelaunch(clonk);
return;
}
func KillsToRelaunch() { return 0; }
func RelaunchWeaponList() { return [TeleGlove, JarOfWinds]; }
You may ignore Weapon List because maybe I will make every clonk get Jar of Winds on spawn.
Gamemode is Last Man Standing, first team(id1) spawns on left side, second team(id2) - on right. And as you can see, I don't use JoinPlayer.
I have tried different ways to make it, but it wasn't working, so I have removed this useless code. Can anybody help me?
Update 1:
Here is my code:
protected func InitializePlayer(int plr)
{
return RelaunchPlayer(plr);
}
protected func RelaunchPlayer(int plr)
{
var clonk = GetCrew(plr);
clonk->DoEnergy(1000);
var pos = [[125, 100],[125, 210],[125, 320],[125, 430],[675, 100],[675, 210],[675, 320],[675, 430]];
var random=Random(GetLength(pos));
var x = pos[random][0], y = pos[random][1];
var relaunch = CreateObject(RelaunchContainer, x, y, clonk->GetOwner());
relaunch->StartRelaunch(clonk);
return;
}
func KillsToRelaunch() { return 0; }
func RelaunchWeaponList() { return [TeleGlove, JarOfWinds]; }
You may ignore Weapon List because maybe I will make every clonk get Jar of Winds on spawn.
Gamemode is Last Man Standing, first team(id1) spawns on left side, second team(id2) - on right. And as you can see, I don't use JoinPlayer.
func RelaunchPlayer(int iPlr)
{
var clonk = CreateObject(Clonk, 10,10, iPlr);
clonk->MakeCrewMember(iPlr);
SetCursor(iPlr, clonk);
var y1 = [100, 210, 320, 430];
var y2 = [100, 210, 320, 430];
var rnd = Random(4);
if (GetTeamByIndex(iPlr) == 0)
clonk->SetPosition(125, y1[rnd]);
else
clonk->SetPosition(675, y2[rnd]);
Log("Clonk from team %d spawned on X: %d Y: %d.", GetTeamByIndex(iPlr)+1, clonk->GetX(), clonk->GetY());
}
IDK whether you want the positions beeing randomly choosen like that. Otherwise you need to describe it more.
{
var clonk = CreateObject(Clonk, 10,10, iPlr);
clonk->MakeCrewMember(iPlr);
SetCursor(iPlr, clonk);
var y1 = [100, 210, 320, 430];
var y2 = [100, 210, 320, 430];
var rnd = Random(4);
if (GetTeamByIndex(iPlr) == 0)
clonk->SetPosition(125, y1[rnd]);
else
clonk->SetPosition(675, y2[rnd]);
Log("Clonk from team %d spawned on X: %d Y: %d.", GetTeamByIndex(iPlr)+1, clonk->GetX(), clonk->GetY());
}
IDK whether you want the positions beeing randomly choosen like that. Otherwise you need to describe it more.
Thank you for answering. But it doesn't work... Next time I should show my code and describe map. So here is my code:
protected func InitializePlayer(int plr)
{
return RelaunchPlayer(plr);
}
protected func RelaunchPlayer(int plr)
{
var clonk = GetCrew(plr);
clonk->DoEnergy(1000);
var pos = [[125, 100],[125, 210],[125, 320],[125, 430],[675, 100],[675, 210],[675, 320],[675, 430]];
var random=Random(GetLength(pos));
var x = pos[random][0], y = pos[random][1];
var relaunch = CreateObject(RelaunchContainer, x, y, clonk->GetOwner());
relaunch->StartRelaunch(clonk);
return;
}
func KillsToRelaunch() { return 0; }
func RelaunchWeaponList() { return [TeleGlove, JarOfWinds]; }
You may ignore Weapon List because maybe I will make every clonk get Jar of Winds on spawn.
Gamemode is Last Man Standing, first team(id1) spawns on left side, second team(id2) - on right. And as you can see, I don't use JoinPlayer.
I hope this information will be enough, if not, ask me ;)
protected func InitializePlayer(int plr)
{
return RelaunchPlayer(plr);
}
protected func RelaunchPlayer(int plr)
{
var clonk = GetCrew(plr);
clonk->DoEnergy(1000);
var pos = [[125, 100],[125, 210],[125, 320],[125, 430],[675, 100],[675, 210],[675, 320],[675, 430]];
var random=Random(GetLength(pos));
var x = pos[random][0], y = pos[random][1];
var relaunch = CreateObject(RelaunchContainer, x, y, clonk->GetOwner());
relaunch->StartRelaunch(clonk);
return;
}
func KillsToRelaunch() { return 0; }
func RelaunchWeaponList() { return [TeleGlove, JarOfWinds]; }
You may ignore Weapon List because maybe I will make every clonk get Jar of Winds on spawn.
Gamemode is Last Man Standing, first team(id1) spawns on left side, second team(id2) - on right. And as you can see, I don't use JoinPlayer.
I hope this information will be enough, if not, ask me ;)
Mh. I can't find anything that strikes my eye. Does the Log report errors? Also, does something happen at all?
Nothing strikes my eye too. Log doesn't report anything just say " 0 warnings, 2 errors" when I use Armin's code. And when clonk spawn it spawn on right place but it don't get any items. So I think to solve the problem, I will need to make "JoinPlayer" function and add Armin's "Relaunch Player". What do you think?
> just say " 0 warnings, 2 errors"
Check your Clonk.log to see the error messages.
Seems like my Clonk.log doesn't update...
C:\Users\*MyUserName*\AppData\Roaming\OpenClonk\Clonk.log shows me logs, that were last time editen in 2011(probably first time when I was playing OpenClonk with my friend)
Anyway, I have realised, that it doesn't show any errors when I place Armin's code to my map, but it spawn 2 clonks(1 on right place, another on random place) and then I have fixed it and got 2 unknown for me errors. As I remeber, when I fixed it, everything was ok except of 2 mystic errors and that clonks were spawning without menu where they can choose a weapon
P.S. Sorry if my english is bad
C:\Users\*MyUserName*\AppData\Roaming\OpenClonk\Clonk.log shows me logs, that were last time editen in 2011(probably first time when I was playing OpenClonk with my friend)
Anyway, I have realised, that it doesn't show any errors when I place Armin's code to my map, but it spawn 2 clonks(1 on right place, another on random place) and then I have fixed it and got 2 unknown for me errors. As I remeber, when I fixed it, everything was ok except of 2 mystic errors and that clonks were spawning without menu where they can choose a weapon
P.S. Sorry if my english is bad
There should be a log somewhere. Just search for OpenClonk.log using the regular Windows file search.
You might need to create a new Clonk when the player relaunches.
var clonk = GetCrew(plr);
if (!clonk)
{
clonk = CreateObject(Clonk, 0, 0, plr);
clonk->MakeCrewMember(plr);
}
Thank you! Now it works!
Update: LOL actually it doesn't work. I need to test everything careful.
Update: LOL actually it doesn't work. I need to test everything careful.
Lol. We with my friend started testing it and clonk started spawning on same side of map :\
Seems like next time I need to test everything more careful...
So I think that we need to make something like that:
protected func RelaunchPlayer(int plr)
{
var clonk = GetCrew(plr);
if (!clonk)
{
clonk = CreateObject(Clonk, 0, 0, plr);
clonk->MakeCrewMember(plr);
}
SetCursor(plr, clonk);
var y = [100, 210, 320, 430];
var rnd = Random(4);
if (GetTeamByIndex(plr) == 0)
clonk->SetPosition(685, y[rnd]);
else
clonk->SetPosition(125, y[rnd]);
Log("Clonk from team %d spawned on X: %d Y: %d.", GetTeamByIndex(plr)+1, clonk->GetX(), clonk->GetY());
clonk->CreateContents(JarOfWinds);
}
And as I understand if game gets team by index, it spawn clonk on 125.
So we need to add something to use index, maybe something like that:
GetTeamByIndex == 1;
if (TeamByIndex(plr) == 2)
clonk->SetPosition(685, y[rnd]);
else
clonk->SetPosition(125, y[rnd]);
But the game don't know "TeamByIndex"...
Seems like next time I need to test everything more careful...
So I think that we need to make something like that:
protected func RelaunchPlayer(int plr)
{
var clonk = GetCrew(plr);
if (!clonk)
{
clonk = CreateObject(Clonk, 0, 0, plr);
clonk->MakeCrewMember(plr);
}
SetCursor(plr, clonk);
var y = [100, 210, 320, 430];
var rnd = Random(4);
if (GetTeamByIndex(plr) == 0)
clonk->SetPosition(685, y[rnd]);
else
clonk->SetPosition(125, y[rnd]);
Log("Clonk from team %d spawned on X: %d Y: %d.", GetTeamByIndex(plr)+1, clonk->GetX(), clonk->GetY());
clonk->CreateContents(JarOfWinds);
}
And as I understand if game gets team by index, it spawn clonk on 125.
So we need to add something to use index, maybe something like that:
GetTeamByIndex == 1;
if (TeamByIndex(plr) == 2)
clonk->SetPosition(685, y[rnd]);
else
clonk->SetPosition(125, y[rnd]);
But the game don't know "TeamByIndex"...
GetTeamByIndex
would be the wrong choice.You can get the team of a player with GetPlayerTeam.
So something like
if (GetPlayerTeam(plr) == 1)
clonk->SetPosition(685, ...);
else
clonk->SetPosition(125, ...);
should work
Topic Development / Scenario & Object Development / [QUESTION]How to set Clonk respawn depending on team id?
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill