forked from Mirrors/openclonk
fix parkour in combination with new relaunch rule
parent
a863845ed4
commit
cb68f9b26b
|
@ -20,7 +20,7 @@ protected func Initialize()
|
|||
// Rules
|
||||
GetRelaunchRule()
|
||||
->SetDefaultRelaunchCount(nil)
|
||||
->EnablePlayerRestart();
|
||||
->AllowPlayerRestart();
|
||||
CreateObject(Rule_ObjectFade)->DoFadeTime(5 * 36);
|
||||
CreateObject(Rule_KillLogs);
|
||||
CreateObject(Rule_Gravestones);
|
||||
|
|
|
@ -10,7 +10,7 @@ func Initialize()
|
|||
GetRelaunchRule()->SetRelaunchCount(nil);
|
||||
GetRelaunchRule()->SetRespawnDelay(8);
|
||||
GetRelaunchRule()->SetLastWeaponUse(false);
|
||||
GetRelaunchRule()->EnablePlayerRestart();
|
||||
GetRelaunchRule()->AllowPlayerRestart();
|
||||
// Mirror map objects by moving them to the other side, then re-running object initialization
|
||||
for (var o in FindObjects(Find_NoContainer(), Find_Not(Find_Category(C4D_Goal | C4D_Rule))))
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ func DoInit(int first_player)
|
|||
->SetInventoryTransfer(true)
|
||||
->SetLastClonkRespawn(true)
|
||||
->SetFreeCrew(true)
|
||||
->EnablePlayerRestart()
|
||||
->AllowPlayerRestart()
|
||||
->SetBaseRespawn(true)
|
||||
->SetRespawnDelay(0);
|
||||
|
||||
|
|
|
@ -56,7 +56,9 @@ protected func Initialize(...)
|
|||
|
||||
private func EnsureRestartRule()
|
||||
{
|
||||
GetRelaunchRule()->EnablePlayerRestart();
|
||||
var relaunch = GetRelaunchRule();
|
||||
relaunch->AllowPlayerRestart();
|
||||
relaunch->SetPerformRestart(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -447,7 +449,8 @@ protected func OnClonkDeath(object clonk, int killed_by)
|
|||
// Respawn actions
|
||||
var cp = FindRespawnCP(plr);
|
||||
UserAction->EvaluateAction(on_respawn, this, clonk, plr);
|
||||
if (cp) cp->OnPlayerRespawn(new_clonk, plr);
|
||||
if (cp)
|
||||
cp->OnPlayerRespawn(new_clonk, plr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -471,7 +474,8 @@ protected func JoinPlayer(int plr)
|
|||
private func FindRespawnCP(int plr)
|
||||
{
|
||||
var respawn_cp = respawn_list[plr];
|
||||
if (!respawn_cp) respawn_cp = respawn_list[plr] = cp_list[0];
|
||||
if (!respawn_cp)
|
||||
respawn_cp = respawn_list[plr] = cp_list[0];
|
||||
return respawn_cp;
|
||||
}
|
||||
|
||||
|
@ -547,19 +551,19 @@ private func UpdateScoreboard(int plr)
|
|||
/*-- Direction indication --*/
|
||||
|
||||
// Effect for direction indication for the clonk.
|
||||
protected func FxIntDirNextCPStart(object target, effect)
|
||||
protected func FxIntDirNextCPStart(object target, effect fx)
|
||||
{
|
||||
var arrow = CreateObjectAbove(GUI_GoalArrow, 0, 0, target->GetOwner());
|
||||
arrow->SetAction("Show", target);
|
||||
effect.arrow = arrow;
|
||||
fx.arrow = arrow;
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
protected func FxIntDirNextCPTimer(object target, effect)
|
||||
protected func FxIntDirNextCPTimer(object target, effect fx)
|
||||
{
|
||||
var plr = target->GetOwner();
|
||||
var team = GetPlayerTeam(plr);
|
||||
var arrow = effect.arrow;
|
||||
var arrow = fx.arrow;
|
||||
// Find nearest CP.
|
||||
var nextcp;
|
||||
for (var cp in FindObjects(Find_ID(ParkourCheckpoint), Find_Func("FindCPMode", PARKOUR_CP_Check | PARKOUR_CP_Finish), Sort_Distance(target->GetX() - GetX(), target->GetY() - GetY())))
|
||||
|
@ -604,9 +608,9 @@ protected func FxIntDirNextCPTimer(object target, effect)
|
|||
return FX_OK;
|
||||
}
|
||||
|
||||
protected func FxIntDirNextCPStop(object target, effect)
|
||||
protected func FxIntDirNextCPStop(object target, effect fx)
|
||||
{
|
||||
effect.arrow->RemoveObject();
|
||||
fx.arrow->RemoveObject();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
|
||||
// Determines whether the inventory of the crew member is transfered upon respawn.
|
||||
local inventory_transfer = false;
|
||||
|
||||
// Determines whether a crew member needs to be bought.
|
||||
local free_crew = true;
|
||||
|
||||
//Determines whether the clonk will be respawned at the base
|
||||
// Determines whether the clonk will be respawned at the base.
|
||||
local respawn_at_base = false;
|
||||
//Determines whether only the last clonk gets respawned
|
||||
// Determines whether only the last clonk gets respawned.
|
||||
local respawn_last_clonk = false;
|
||||
|
||||
local default_relaunch_count = nil;
|
||||
|
@ -24,13 +22,14 @@ local disable_last_weapon = false;
|
|||
local last_used_player_weapons = [];
|
||||
local relaunch_time = 36 * 10;
|
||||
local hold = false;
|
||||
local restart_player = false;
|
||||
local allow_restart_player = false;
|
||||
local respawn_script_players = false;
|
||||
local perform_restart = true;
|
||||
|
||||
public func Activate(int plr)
|
||||
{
|
||||
// Only restart player if enabled unless this is a definition call.
|
||||
if (this != Rule_Relaunch && !restart_player)
|
||||
if (this != Rule_Relaunch && !allow_restart_player)
|
||||
return MessageWindow(this.Description, plr);
|
||||
// Notify scenario.
|
||||
if (GameCall("OnPlayerRestart", plr))
|
||||
|
@ -47,7 +46,8 @@ public func Activate(int plr)
|
|||
protected func Initialize()
|
||||
{
|
||||
ScheduleCall(this, this.CheckDescription, 1, 1);
|
||||
if(GetScenarioVal("Mode", "Game") == "Melee") default_relaunch_count = 5;
|
||||
if (GetScenarioVal("Mode", "Game") == "Melee")
|
||||
default_relaunch_count = 5;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -152,15 +152,15 @@ public func SetLastClonkRespawn(bool b)
|
|||
return this;
|
||||
}
|
||||
|
||||
public func EnablePlayerRestart()
|
||||
public func AllowPlayerRestart()
|
||||
{
|
||||
restart_player = true;
|
||||
allow_restart_player = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public func DisablePlayerRestart()
|
||||
public func DisallowPlayerRestart()
|
||||
{
|
||||
restart_player = false;
|
||||
allow_restart_player = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -169,6 +169,11 @@ public func GetLastClonkRespawn()
|
|||
return respawn_last_clonk;
|
||||
}
|
||||
|
||||
public func SetPerformRestart(bool on)
|
||||
{
|
||||
perform_restart = on;
|
||||
}
|
||||
|
||||
public func InitializePlayer(int plr)
|
||||
{
|
||||
_inherited(plr, ...);
|
||||
|
@ -179,12 +184,12 @@ public func InitializePlayer(int plr)
|
|||
|
||||
public func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
if (clonk == nil)
|
||||
if (!clonk || !perform_restart)
|
||||
return;
|
||||
var plr = clonk->GetOwner();
|
||||
if (plr == NO_OWNER || (!respawn_script_players && GetPlayerType(plr) == C4PT_Script)) return;
|
||||
if (plr == NO_OWNER || (!respawn_script_players && GetPlayerType(plr) == C4PT_Script)) return;
|
||||
|
||||
if (default_relaunch_count != nil)
|
||||
if (default_relaunch_count != nil)
|
||||
{
|
||||
relaunches[plr]--;
|
||||
if(relaunches[plr] < 0)
|
||||
|
@ -278,7 +283,7 @@ public func DoRelaunch(int plr, object clonk, array position, bool no_creation)
|
|||
else
|
||||
{
|
||||
var base = GetRelaunchBase();
|
||||
if(!base) return;
|
||||
if (!base) return;
|
||||
// Try to buy a crew member at the base.
|
||||
var pay_plr = base->GetOwner();
|
||||
// Payment in neutral bases by clonk owner.
|
||||
|
@ -305,7 +310,7 @@ public func DoRelaunch(int plr, object clonk, array position, bool no_creation)
|
|||
|
||||
if (!GetCursor(plr) || GetCursor(plr) == clonk)
|
||||
SetCursor(plr, new_clonk);
|
||||
new_clonk->DoEnergy(new_clonk.Energy || 100000);
|
||||
new_clonk->DoEnergy(new_clonk.Energy ?? 100000);
|
||||
|
||||
if (relaunch_time)
|
||||
{
|
||||
|
@ -323,6 +328,7 @@ protected func FindRelaunchPos(int plr)
|
|||
return [loc.x, loc.y];
|
||||
}
|
||||
|
||||
|
||||
/*-- Scenario saving --*/
|
||||
|
||||
public func SaveScenarioObject(props, ...)
|
||||
|
@ -340,6 +346,8 @@ public func SaveScenarioObject(props, ...)
|
|||
props->AddCall("BaseRespawn", this, "SetBaseRespawn", respawn_at_base);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*-- Globals --*/
|
||||
|
||||
global func SetRelaunchCount(int plr, int value)
|
||||
|
@ -373,7 +381,8 @@ global func GetRelaunchRule()
|
|||
return FindObject(Find_ID(Rule_Relaunch)) || CreateObject(Rule_Relaunch);
|
||||
}
|
||||
|
||||
/* Editor */
|
||||
|
||||
/*-- Editor --*/
|
||||
|
||||
public func Definition(def)
|
||||
{
|
||||
|
@ -409,6 +418,7 @@ public func Definition(def)
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
/*-- Proplist --*/
|
||||
|
||||
local Name = "$Name$";
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
*/
|
||||
|
||||
|
||||
static checkpoint_locations;
|
||||
static inventorslab_location;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
// Create the parkour goal.
|
||||
|
@ -45,9 +42,9 @@ protected func Initialize()
|
|||
|
||||
// Rules: no power and restart with keeping inventory.
|
||||
CreateObject(Rule_NoPowerNeed);
|
||||
GetRelaunchRule()
|
||||
->EnablePlayerRestart()
|
||||
->SetInventoryTransfer(true);
|
||||
//GetRelaunchRule()
|
||||
// ->AllowPlayerRestart()
|
||||
// ->SetInventoryTransfer(true);
|
||||
|
||||
// Initialize parts of the scenario.
|
||||
var amount = BoundBy(SCENPAR_NrCheckPoints, 6, 20);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
private func Initialize()
|
||||
{
|
||||
GetRelaunchRule()
|
||||
->EnablePlayerRestart();
|
||||
->AllowPlayerRestart();
|
||||
|
||||
// Create dynamite below the first lava basin
|
||||
DrawMaterialQuad("Tunnel",1378,1327-5,1860,1327-5,1860,1330,1387,1330,1);
|
||||
|
|
Loading…
Reference in New Issue