Weapon pick on respawn in scenario scripts (#358)

floating-point
Maikel de Vries 2010-08-14 13:52:17 +02:00
parent 88f534771c
commit fa19041b63
11 changed files with 92 additions and 100 deletions

View File

@ -17,13 +17,12 @@ protected func Initialize()
}
// Gamecall from Mircomelee rule, on respawning.
protected func OnPlrRelaunch(int plr)
protected func OnPlayerRelaunch(int plr)
{
var clonk = GetCrew(plr);
clonk->Contents()->RemoveObject();
var relaunch = CreateObject(Goal_Relaunch, LandscapeWidth() / 2, LandscapeHeight() / 2, clonk->GetOwner());
clonk->Enter(relaunch);
relaunch->~WeaponMenu(clonk);
var relaunch = CreateObject(RelaunchContainer, LandscapeWidth() / 2, LandscapeHeight() / 2, clonk->GetOwner());
relaunch->StartRelaunch(clonk);
return;
}
@ -51,25 +50,17 @@ global func CreateChestContents(id obj_id)
{
if (!this)
return;
var obj = CreateObject(obj_id);
if (obj_id == Bow)
{
var bow = CreateObject(Bow, 0, 0, NO_OWNER);
bow->CreateContents(Arrow);
bow->Enter(this);
}
else if (obj_id == Musket)
{
var bow = CreateObject(Musket, 0, 0, NO_OWNER);
bow->CreateContents(LeadShot);
bow->Enter(this);
}
else
this->CreateContents(obj_id);
obj->CreateContents(Arrow);
if (obj_id == Musket)
obj->CreateContents(LeadShot);
obj->Enter(this);
return;
}
// GameCall from MicroMelee_Relaunch
func OnClonkLeftRelaunchObject(clonk)
func OnClonkLeftRelaunch(clonk)
{
clonk->SetPosition(RandomX(30, LandscapeWidth() - 30), -20);
}

View File

@ -18,7 +18,7 @@ protected func Initialize()
}
// Gamecall from Mircomelee rule, on respawning.
protected func OnPlrRelaunch(int plr)
protected func OnPlayerRelaunch(int plr)
{
var clonk = GetCrew(plr);
clonk->SetPosition(Random(LandscapeWidth()),10);
@ -44,20 +44,12 @@ global func CreateChestContents(id obj_id)
{
if (!this)
return;
var obj = CreateObject(obj_id);
if (obj_id == Bow)
{
var bow = CreateObject(Bow, 0, 0, NO_OWNER);
bow->CreateContents(Arrow);
bow->Enter(this);
}
else if (obj_id == Musket)
{
var bow = CreateObject(Musket, 0, 0, NO_OWNER);
bow->CreateContents(LeadShot);
bow->Enter(this);
}
else
this->CreateContents(obj_id);
obj->CreateContents(Arrow);
if (obj_id == Musket)
obj->CreateContents(LeadShot);
obj->Enter(this);
return;
}

View File

@ -95,19 +95,11 @@ global func CreateChestContents(id obj_id)
{
if (!this)
return;
var obj = CreateObject(obj_id);
if (obj_id == Bow)
{
var bow = CreateObject(Bow, 0, 0, NO_OWNER);
bow->CreateContents(Arrow);
bow->Enter(this);
}
else if (obj_id == Musket)
{
var bow = CreateObject(Musket, 0, 0, NO_OWNER);
bow->CreateContents(LeadShot);
bow->Enter(this);
}
else
this->CreateContents(obj_id);
obj->CreateContents(Arrow);
if (obj_id == Musket)
obj->CreateContents(LeadShot);
obj->Enter(this);
return;
}

View File

@ -62,5 +62,5 @@ public func FxIntFadeOutTimerEffect(string new_effect_name) {
}
func Definition(def) {
SetProperty("Name", "$Name$", def);
SetProperty("Name", "Object Fade", def);
}

View File

@ -36,14 +36,13 @@ CreateObject(BrickEdge,305,240)->SetP(2);
}
// Gamecall from Mircomelee rule, on respawning.
protected func OnPlrRelaunch(int plr)
// Gamecall from LastManStanding goal, on respawning.
protected func OnPlayerRelaunch(int plr)
{
var clonk = GetCrew(plr);
clonk->Contents()->RemoveObject();
var relaunch = CreateObject(Goal_Relaunch, LandscapeWidth() / 2, LandscapeHeight() / 2, clonk->GetOwner());
clonk->Enter(relaunch);
relaunch->~WeaponMenu(clonk);
var relaunch = CreateObject(RelaunchContainer, LandscapeWidth() / 2, LandscapeHeight() / 2, clonk->GetOwner());
relaunch->StartRelaunch(clonk);
return;
}
@ -72,28 +71,20 @@ global func CreateChestContents(id obj_id)
{
if (!this)
return;
var obj = CreateObject(obj_id);
if (obj_id == Bow)
{
var bow = CreateObject(Bow, 0, 0, NO_OWNER);
bow->CreateContents(Arrow);
bow->Enter(this);
}
else if (obj_id == Musket)
{
var bow = CreateObject(Musket, 0, 0, NO_OWNER);
bow->CreateContents(LeadShot);
bow->Enter(this);
}
else
this->CreateContents(obj_id);
obj->CreateContents(Arrow);
if (obj_id == Musket)
obj->CreateContents(LeadShot);
obj->Enter(this);
return;
}
// GameCall from MicroMelee_Relaunch
func OnClonkLeftRelaunchObject(clonk)
func OnClonkLeftRelaunch(object clonk)
{
clonk->SetPosition(RandomX(30, LandscapeWidth() - 30), -20);
}
func KillsToRelaunch() { return 0; }
func WeaponList(){ return [Bow,Arrow,Shield,Sword,Club,Javelin,DynamiteBox]; }
func RelaunchWeaponList(){ return [Bow,Shield,Sword,Club,Javelin,Musket]; }

View File

@ -1,5 +1,5 @@
[DefCore]
id=Goal_Relaunch
id=RelaunchContainer
Version=4,10,0,0
Category=C4D_StaticBack
ClosedContainer=2

View File

@ -1,2 +0,0 @@
DE:Auswählen
US:Select

View File

@ -1,79 +1,101 @@
/*
/*--
Relaunch container
Author: Maikel
This container holds the clonk after relaunches, so the player will be able to choose some weapons.
*/
This container holds the clonk after relaunches.
* The time the clonk is held can be specified with SetRelaunchTime(int time);
* After that time the clonk is released and OnClonkLeftRelaunch(object clonk) is called in the scenario script.
* Optionally the clonk can choose a weapon if GetRelaunchWeaponList in the scenario script returns a valid id-array.
--*/
local time;
local menu;
local choses;
private func WeaponList()
protected func Initialize()
{
return GameCall("GetMicroMeleeWeaponList");
time = 36 * 10;
return;
}
public func WeaponMenu(object clonk)
// Sets the time, in seconds, the clonk is held in the container.
public func SetRelaunchTime(int to_time)
{
time = to_time * 36;
return;
}
// Returns the time, in seconds the clonk is held.
public func GetRelaunchTime() { return time / 36; }
// Retrieve weapon list from scenario.
private func WeaponList() { return GameCall("RelaunchWeaponList"); }
public func StartRelaunch(object clonk)
{
if (!clonk)
return;
clonk->Enter(this);
if (!menu)
{
var weapons = WeaponList();
if(weapons)
{
menu = clonk->CreateRingMenu(Clonk, 0, 0, this);
menu = clonk->CreateRingMenu(Clonk, this);
for (var weapon in weapons)
menu->AddItem(weapon);
menu->Show();
}
}
AddEffect("IntTimeLimit", this, 100, 10, this);
AddEffect("IntTimeLimit", this, 100, 36, this);
return true;
}
func FxIntTimeLimitTimer(target, num, time)
func FxIntTimeLimitTimer(target, num, fxtime)
{
var clonk = Contents();
if (time > 350)
if (fxtime >= time)
{
RelaunchClonk();
if(menu) menu->Close();
PlayerMessage(clonk->GetOwner(), "");
this->RemoveObject();
return -1;
}
PlayerMessage(clonk->GetOwner(), Format("%d seconds remaining.", (350 - time) / 35));
if (WeaponList())
PlayerMessage(clonk->GetOwner(), Format("$MsgWeapon$", (time - fxtime) / 36));
else
PlayerMessage(clonk->GetOwner(), Format("$MsgRelaunch$", (time - fxtime) / 36));
return 1;
}
public func Selected(object menu, object selector)
{
if(!selector) return 0;
if (!selector)
return false;
for(var i = 0; i<(selector->GetAmount()); i++)
for (var i = 0; i < selector->GetAmount(); i++)
{
var newobj = CreateObject(selector->GetSymbol());
if (newobj->GetID() == Bow)
newobj->CreateContents(Arrow);
if (newobj->GetID() == Musket)
newobj->CreateContents(LeadShot);
newobj->Enter(Contents());
}
menu->Show();
if (choses > 0)
{
RelaunchClonk();
this->RemoveObject();
return 1;
}
choses++;
return 0;
RelaunchClonk();
return true;
}
private func RelaunchClonk()
{
var clonk = Contents();
clonk->Exit();
GameCall("OnClonkLeftRelaunchObject", clonk);
GameCall("OnClonkLeftRelaunch", clonk);
if (menu)
menu->Close();
PlayerMessage(clonk->GetOwner(), "");
RemoveObject();
return;
}
func Definition(def) {
SetProperty("Name", "relaunch", def);
protected func Definition(def)
{
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1,3 @@
Name=Relaunch container
MsgRelaunch=You will be relaunched in %d seconds.
MsgWeapon=You have %d seconds to choose a weapon.

View File

@ -0,0 +1,3 @@
Name=Relaunch container
MsgRelaunch=You will be relaunched in %d seconds.
MsgWeapon=You have %d seconds to choose a weapon.

View File

@ -57,7 +57,7 @@ protected func InitializePlayer(int plr)
// Join plr.
JoinPlayer(plr);
// Scenario script callback.
GameCall("OnPlrRelaunch", plr);
GameCall("OnPlayerRelaunch", plr);
return _inherited(plr, ...);
}
@ -83,7 +83,7 @@ protected func RelaunchPlayer(int plr, int killer)
SetCursor(plr, clonk);
JoinPlayer(plr);
// Scenario script callback.
GameCall("OnPlrRelaunch", plr);
GameCall("OnPlayerRelaunch", plr);
// Show scoreboard for a while.
DoScoreboardShow(1, plr + 1);
Schedule(Format("DoScoreboardShow(-1, %d)", plr + 1), 35 * MIME_ShowBoardTime);