forked from Mirrors/openclonk
Add weapon speed setting to enemy spawn
parent
eee5a5d663
commit
d4b036b541
|
@ -30,7 +30,6 @@ private func FindInventoryWeapon(effect fx)
|
|||
fx.weapon = fx.Target->FindContents(Bow);
|
||||
fx.strategy = this.ExecuteRanged;
|
||||
fx.projectile_speed = 100;
|
||||
fx.aim_wait = 0;
|
||||
fx.ammo_check = this.HasArrows;
|
||||
fx.ranged=true;
|
||||
return true;
|
||||
|
@ -259,7 +258,7 @@ private func ExecuteRanged(effect fx)
|
|||
if (fx.post_aim_weapon)
|
||||
{
|
||||
// wait max one second after shot (otherwise may be locked in wait animation forever if something goes wrong during shot)
|
||||
if (FrameCounter() - fx.post_aim_weapon_time < 36)
|
||||
if (FrameCounter() - fx.post_aim_weapon_time <= (fx.post_aim_weapon->~GetShootTime() ? ? 35))
|
||||
if (this->IsAimingOrLoading(fx)) return true;
|
||||
fx.post_aim_weapon = nil;
|
||||
}
|
||||
|
@ -343,7 +342,7 @@ private func ExecuteRanged(effect fx)
|
|||
x = Sin(shooting_angle, 1000, 10);
|
||||
y = -Cos(shooting_angle, 1000, 10);
|
||||
fx.aim_weapon->ControlUseHolding(fx.Target, x,y);
|
||||
if (fx.Target->IsAiming() && fx.time >= fx.aim_time + fx.aim_wait)
|
||||
if (fx.Target->IsAiming() && fx.time >= fx.aim_time + fx.aim_weapon->GetReloadTime())
|
||||
{
|
||||
//Log("Throw angle %v speed %v to reach %d %d", shooting_angle, fx.projectile_speed, tx-GetX(), ty-GetY());
|
||||
fx.aim_weapon->ControlUseStop(fx.Target, x,y);
|
||||
|
|
|
@ -36,7 +36,7 @@ local SingleWeaponAttackMode = {
|
|||
// (the jump animation skipping pickup is weird anyway, but it works for now)
|
||||
var is_carry_heavy_workaround = fx.attack_mode.Weapon->~IsCarryHeavy() && !fx.Target->Contained() && fx.Target->GetAction() == "Walk";
|
||||
if (is_carry_heavy_workaround) fx.Target->SetAction("Jump");
|
||||
var weapon = fx.Target->CreateContents(fx.attack_mode.Weapon);
|
||||
var weapon = fx.default_weapon = fx.Target->CreateContents(fx.attack_mode.Weapon);
|
||||
if (is_carry_heavy_workaround) fx.Target->SetAction("Walk");
|
||||
if (weapon)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ private func ExecuteRanged(effect fx)
|
|||
if (fx.post_aim_weapon)
|
||||
{
|
||||
// Wait max one second after shot (otherwise may be locked in wait animation forever if something goes wrong during shot).
|
||||
if (FrameCounter() - fx.post_aim_weapon_time < 36)
|
||||
if (FrameCounter() - fx.post_aim_weapon_time <= (fx.post_aim_weapon->~GetShootTime() ?? 35))
|
||||
if (this->IsAimingOrLoading(fx))
|
||||
return true;
|
||||
fx.post_aim_weapon = nil;
|
||||
|
@ -94,7 +94,7 @@ private func ExecuteRanged(effect fx)
|
|||
x = Sin(shooting_angle, 1000, 10);
|
||||
y = -Cos(shooting_angle, 1000, 10);
|
||||
fx.aim_weapon->ControlUseHolding(fx.Target, x, y);
|
||||
if (fx.Target->IsAiming() && fx.time >= fx.aim_time + fx.aim_wait)
|
||||
if (fx.Target->IsAiming() && fx.time >= fx.aim_time + fx.aim_weapon->GetReloadTime())
|
||||
{
|
||||
fx.aim_weapon->ControlUseStop(fx.Target, x, y);
|
||||
// Assign post-aim status to allow slower shoot animations to pass.
|
||||
|
|
|
@ -589,7 +589,6 @@ private func FindInventoryWeaponGrenadeLauncher(effect fx)
|
|||
{
|
||||
fx.strategy = this.ExecuteRanged;
|
||||
fx.projectile_speed = 75;
|
||||
fx.aim_wait = 85;
|
||||
fx.ammo_check = this.HasBombs;
|
||||
fx.ranged = true;
|
||||
fx.can_attack_structures = true;
|
||||
|
@ -608,7 +607,6 @@ private func FindInventoryWeaponBlunderbuss(effect fx)
|
|||
{
|
||||
fx.strategy = this.ExecuteRanged;
|
||||
fx.projectile_speed = 200;
|
||||
fx.aim_wait = 85;
|
||||
fx.ammo_check = this.HasAmmo;
|
||||
fx.ranged = true;
|
||||
fx.ranged_direct = true;
|
||||
|
@ -627,7 +625,6 @@ private func FindInventoryWeaponBow(effect fx)
|
|||
{
|
||||
fx.strategy = this.ExecuteRanged;
|
||||
fx.projectile_speed = 100;
|
||||
fx.aim_wait = 0;
|
||||
fx.ammo_check = this.HasArrows;
|
||||
fx.ranged = true;
|
||||
var arrow = fx.weapon->Contents(0) ?? FindObject(Find_Container(fx.Target), Find_Func("IsArrow"));
|
||||
|
@ -645,7 +642,6 @@ private func FindInventoryWeaponJavelin(effect fx)
|
|||
{
|
||||
fx.strategy = this.ExecuteRanged;
|
||||
fx.projectile_speed = fx.Target.ThrowSpeed * fx.weapon.shooting_strength / 100;
|
||||
fx.aim_wait = 16;
|
||||
fx.ranged=true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ public func SpawnClonk(array pos, proplist clonk_data, proplist enemy_def, array
|
|||
// Reward for killing enemy
|
||||
clonk.Bounty = clonk_data.Bounty;
|
||||
// AI
|
||||
AI->AddAI(clonk);
|
||||
var fx_ai = AI->AddAI(clonk);
|
||||
AI->SetMaxAggroDistance(clonk, Max(LandscapeWidth(), LandscapeHeight()));
|
||||
var guard_range = clonk_data.GuardRange;
|
||||
if (!guard_range)
|
||||
|
@ -425,6 +425,11 @@ public func SpawnClonk(array pos, proplist clonk_data, proplist enemy_def, array
|
|||
AI->SetAttackMode(clonk, clonk_data.AttackMode.Identifier);
|
||||
}
|
||||
AI->SetAttackPath(clonk, clonk_attack_path);
|
||||
// Attack speed on weapon
|
||||
if (clonk_data.AttackSpeed != 100 && fx_ai && fx_ai.default_weapon)
|
||||
{
|
||||
fx_ai.default_weapon->~SetSpeedMultiplier(clonk_data.AttackSpeed);
|
||||
}
|
||||
// Return clonk to be added to spawned enemy list
|
||||
return clonk;
|
||||
}
|
||||
|
@ -534,6 +539,7 @@ public func GetAIClonkEditorProps()
|
|||
props.Speed = { Name="$Speed$", EditorHelp="$SpeedHelp$", Type="int", Min=5 };
|
||||
props.Energy = { Name="$Energy$", EditorHelp="$EnergyHelp$", Type="int", Min=1, Max=100000 };
|
||||
props.Backpack = { Name="$Backpack$", EditorHelp="$BackpackHelp$", Type="bool" };
|
||||
props.AttackSpeed = { Name="$AttackSpeed$", EditorHelp="$AttackSpeedHelp$", Type="int", Min = 1, Max = 20000 };
|
||||
this.AIClonkEditorProps = { Type="proplist", Name=Clonk->GetName(), EditorProps=props, Priority=100 };
|
||||
}
|
||||
return this.AIClonkEditorProps;
|
||||
|
@ -551,6 +557,7 @@ public func GetAIClonkDefaultPropValues(string attack_mode)
|
|||
Speed = 100,
|
||||
Energy = 50,
|
||||
Backpack = false,
|
||||
AttackSpeed = 100,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -59,4 +59,6 @@ ThisSequenceSpawnersHelp=Alle innerhalb dieser Aktion gestarteten Spawner.
|
|||
SpecificSpawner=Bestimmter Spawner
|
||||
SpecificSpawnerHelp=Objektauswahl fuer bestimmten Spawner.
|
||||
AllEnemiesKilled=Gegnerspawn getoetet
|
||||
AllEnemiesKilledHelp=Wahr wenn alle Gegner aus einem oder mehreren aktivierten Gegnerspawns getoetet wurden.
|
||||
AllEnemiesKilledHelp=Wahr wenn alle Gegner aus einem oder mehreren aktivierten Gegnerspawns getoetet wurden.
|
||||
AttackSpeed=Angriffsgeschwindigkeit
|
||||
AttackSpeedHelp=Nur Fernkampfwaffen: Anpassung der Schuss- und Nachladegeschwindigkeit in Prozent des Standardwertes. Grosse Werte bedeuten schnelleres Schiessen und Nachladen.
|
|
@ -59,4 +59,6 @@ ThisSequenceSpawnersHelp=All previously activated enemy spawns from this action
|
|||
SpecificSpawner=Specific spawn
|
||||
SpecificSpawnerHelp=Object selection for specific enemy spawner.
|
||||
AllEnemiesKilled=Enemy spawn killed
|
||||
AllEnemiesKilledHelp=True if all enemies from one or more previously activated enemy spawn objects have been killed or removed.
|
||||
AllEnemiesKilledHelp=True if all enemies from one or more previously activated enemy spawn objects have been killed or removed.
|
||||
AttackSpeed=Attack speed
|
||||
AttackSpeedHelp=Ranged weapons only: Adjustment of shoot and reload speed in percent of the default value. Large values mean faster shooting and reloading.
|
||||
|
|
|
@ -22,6 +22,18 @@ public func Initialize(...)
|
|||
return _inherited(...);
|
||||
}
|
||||
|
||||
public func GetReloadTime()
|
||||
{
|
||||
// Get weapon reload time after speed adjustments
|
||||
return animation_set.LoadTime;
|
||||
}
|
||||
|
||||
public func GetShootTime()
|
||||
{
|
||||
// Get shoot time after speed adjustments
|
||||
return animation_set.ShootTime;
|
||||
}
|
||||
|
||||
public func SetSpeedMultiplier(int new_multiplier)
|
||||
{
|
||||
// Updates the weapon speed
|
||||
|
|
Loading…
Reference in New Issue