Added two diplomacy functions to lua
...and sneaked into AUTHORS
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -60,6 +60,7 @@ Also thanks to:
|
|||||||
* Kyrre Soerensen (zypres)
|
* Kyrre Soerensen (zypres)
|
||||||
* Lawrence Wang
|
* Lawrence Wang
|
||||||
* Lesueur Benjamin (Valkirie)
|
* Lesueur Benjamin (Valkirie)
|
||||||
|
* Lukas Franke (abcdefg30)
|
||||||
* Maarten Meuris (Nyerguds)
|
* Maarten Meuris (Nyerguds)
|
||||||
* Mark Olson (markolson)
|
* Mark Olson (markolson)
|
||||||
* Matija Hustic (matija-hustic)
|
* Matija Hustic (matija-hustic)
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ namespace OpenRA.Network
|
|||||||
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
|
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
|
||||||
var newStance = (Stance)order.ExtraData;
|
var newStance = (Stance)order.ExtraData;
|
||||||
|
|
||||||
SetPlayerStance(world, order.Player, targetPlayer, newStance);
|
order.Player.SetStance(targetPlayer, newStance);
|
||||||
|
|
||||||
Game.Debug("{0} has set diplomatic stance vs {1} to {2}",
|
Game.Debug("{0} has set diplomatic stance vs {1} to {2}",
|
||||||
order.Player.PlayerName, targetPlayer.PlayerName, newStance);
|
order.Player.PlayerName, targetPlayer.PlayerName, newStance);
|
||||||
@@ -247,7 +247,7 @@ namespace OpenRA.Network
|
|||||||
// automatically declare war reciprocally
|
// automatically declare war reciprocally
|
||||||
if (newStance == Stance.Enemy && targetPlayer.Stances[order.Player] == Stance.Ally)
|
if (newStance == Stance.Enemy && targetPlayer.Stances[order.Player] == Stance.Ally)
|
||||||
{
|
{
|
||||||
SetPlayerStance(world, targetPlayer, order.Player, newStance);
|
targetPlayer.SetStance(order.Player, newStance);
|
||||||
Game.Debug("{0} has reciprocated",targetPlayer.PlayerName);
|
Game.Debug("{0} has reciprocated",targetPlayer.PlayerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,17 +275,6 @@ namespace OpenRA.Network
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetPlayerStance(World w, Player p, Player target, Stance s)
|
|
||||||
{
|
|
||||||
var oldStance = p.Stances[target];
|
|
||||||
p.Stances[target] = s;
|
|
||||||
target.Shroud.UpdatePlayerStance(w, p, oldStance, s);
|
|
||||||
p.Shroud.UpdatePlayerStance(w, target, oldStance, s);
|
|
||||||
|
|
||||||
foreach (var nsc in w.ActorsWithTrait<INotifyStanceChanged>())
|
|
||||||
nsc.Trait.StanceChanged(nsc.Actor, p, target, oldStance, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetOrderLag(OrderManager o)
|
static void SetOrderLag(OrderManager o)
|
||||||
{
|
{
|
||||||
if (o.FramesAhead != o.LobbyInfo.GlobalSettings.OrderLatency && !o.GameStarted)
|
if (o.FramesAhead != o.LobbyInfo.GlobalSettings.OrderLatency && !o.GameStarted)
|
||||||
|
|||||||
@@ -111,6 +111,17 @@ namespace OpenRA
|
|||||||
return p == null || Stances[p] == Stance.Ally;
|
return p == null || Stances[p] == Stance.Ally;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetStance(Player target, Stance s)
|
||||||
|
{
|
||||||
|
var oldStance = Stances[target];
|
||||||
|
Stances[target] = s;
|
||||||
|
target.Shroud.UpdatePlayerStance(World, this, oldStance, s);
|
||||||
|
Shroud.UpdatePlayerStance(World, target, oldStance, s);
|
||||||
|
|
||||||
|
foreach (var nsc in World.ActorsWithTrait<INotifyStanceChanged>())
|
||||||
|
nsc.Trait.StanceChanged(nsc.Actor, this, target, oldStance, s);
|
||||||
|
}
|
||||||
|
|
||||||
#region Scripting interface
|
#region Scripting interface
|
||||||
|
|
||||||
Lazy<ScriptPlayerInterface> luaInterface;
|
Lazy<ScriptPlayerInterface> luaInterface;
|
||||||
|
|||||||
39
OpenRA.Mods.RA/Scripting/Properties/DiplomacyProperties.cs
Normal file
39
OpenRA.Mods.RA/Scripting/Properties/DiplomacyProperties.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Eluant;
|
||||||
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Scripting;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Scripting
|
||||||
|
{
|
||||||
|
[ScriptPropertyGroup("Diplomacy")]
|
||||||
|
public class DiplomacyProperties : ScriptPlayerProperties
|
||||||
|
{
|
||||||
|
public DiplomacyProperties(ScriptContext context, Player player)
|
||||||
|
: base(context, player) { }
|
||||||
|
|
||||||
|
[Desc("Returns true if the player is allied with the other player.")]
|
||||||
|
public bool IsAlliedWith(Player targetPlayer)
|
||||||
|
{
|
||||||
|
return player.IsAlliedWith(targetPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Desc("Changes the current stance of the player against the target player. " +
|
||||||
|
"Allowed keywords for new stance: Ally, Neutral, Enemy.")]
|
||||||
|
public void SetStance(Player targetPlayer, string newStance)
|
||||||
|
{
|
||||||
|
var emergingStance = Enum<Stance>.Parse(newStance);
|
||||||
|
player.SetStance(targetPlayer, emergingStance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user