FightForGidl: New technology: Ranged weapon load speed increase.

shapetextures
Sven Eberhardt 2015-12-09 01:00:03 -05:00
parent ab47831ab5
commit 87c49451e4
6 changed files with 64 additions and 3 deletions

View File

@ -83,10 +83,10 @@ public func UpdateCaption(string title, bool available, int item_idx)
public func ClickCaption() { return true; } // nothing to be done here (maybe expand/collapse in the future)
public func UpdateBuyEntry(id buy_def, bool available, int price, int callback_idx, bool was_last_selection, int extra_width, string hotkey)
public func UpdateBuyEntry(id buy_def, bool available, int price, int callback_idx, bool was_last_selection, int extra_width, string hotkey, string graphics)
{
if (!menu) return false;
var custom_entry = {Bottom = "+2em", Right = Format("+%dem", 2+extra_width), Symbol = buy_def }, fontclr, bgclr, bgclr_hover;
var custom_entry = {Bottom = "+2em", Right = Format("+%dem", 2+extra_width), Symbol = buy_def, GraphicsName=graphics }, fontclr, bgclr, bgclr_hover;
if (available)
{
fontclr = 0x00ff00;

View File

@ -0,0 +1,8 @@
[DefCore]
id=Homebase_Icon
Version=7,0
Category=C4D_StaticBack
Picture=0,0,64,64
Width=64
Height=64
Offset=-32,-32

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -13,6 +13,9 @@ local techs;
local is_selling; // temp to prevent recursion from object removal
// Technology fields - queried by objects using them
local tech_load_speed_multiplier = 100;
static g_quickbuy_items;
// Types for purchasable stuff
@ -55,6 +58,7 @@ public func Construction(...)
AddCaption("$Technology$");
AddHomebaseItem(new ITEMTYPE_Technology { item = Icon_World,cost = 100, tech = "AdvancedWeapons" });
AddHomebaseItem(new ITEMTYPE_Technology { item = Homebase_Icon, graphics="LoadSpeed", cost = 100, tech = "LoadSpeed" });
AddHomebaseItem(new ITEMTYPE_Technology { item = Icon_World,cost = 1000, tech = "MasterWeapons", requirements = ["AdvancedWeapons"] });
AddCaption("$Upgrades$");
@ -94,7 +98,7 @@ public func UpdateIndexedItem(int index)
if (entry.is_caption)
return buy_menu->UpdateCaption(entry.title, available, index);
else
return buy_menu->UpdateBuyEntry(entry.item, available, entry.cost, index, index == last_buy_idx, entry.extra_width, entry.hotkey);
return buy_menu->UpdateBuyEntry(entry.item, available, entry.cost, index, index == last_buy_idx, entry.extra_width, entry.hotkey, entry.graphics);
}
return false;
}
@ -250,8 +254,20 @@ private func GainTechnology(proplist entry)
private func GainAdvancedWeapons(proplist entry)
{
// All done by requirements
return true;
}
private func GainLoadSpeed(proplist entry)
{
// Increase player's load speed
tech_load_speed_multiplier = 30;
// Update all current weapons
for (var weapon in FindObjects(Find_Owner(GetOwner()), Find_Func("Gidl_IsRangedWeapon")))
weapon->Gidl_UpdateLoadTimes();
return true;
}
public func Definition(def)
{
// Arrays in static const are broken

View File

@ -0,0 +1,37 @@
/* Apply upgrades to ranged weapons */
#appendto Bow
#appendto Musket
#appendto GrenadeLauncher
#appendto Javelin
public func Initialize(...)
{
var r = _inherited(...);
this.gidl_base_animation_set = this.animation_set;
Gidl_UpdateLoadTimes();
return r;
}
public func Entrance(...)
{
Gidl_UpdateLoadTimes();
return _inherited(...);
}
private func Gidl_UpdateLoadTimes()
{
if (!Contained()) return false;
var base = g_homebases[Contained()->GetOwner()];
if (base)
{
var base_set = this.gidl_base_animation_set, new_set;
this.animation_set = new_set = new base_set {};
if (GetType(base_set.LoadTime)) new_set.LoadTime = base_set.LoadTime * base.tech_load_speed_multiplier / 100;
if (GetType(base_set.LoadTime2)) new_set.LoadTime2 = base_set.LoadTime2 * base.tech_load_speed_multiplier / 100; // Bow: add arrow
if (GetType(base_set.ShootTime)) new_set.ShootTime = base_set.ShootTime * base.tech_load_speed_multiplier / 100;
}
return true;
}
public func Gidl_IsRangedWeapon() { return true; }