Skip to content
Permalink
Browse files

Vendor: Allow rebuy

Added a callback QueryRebuy(int for_player, object base) in the vendor library. If an object that will be sold returns true in that function then the object will not be added to the base material of the selling player.
Currently the only objects that are sellable are Diamond, GoldBar, Nugget, Ruby. They cannot be rebought, just as in the previous implementation.
  • Loading branch information
gitMarky committed Apr 11, 2016
1 parent 43d6fcd commit 89718f35a43c86471d2e6df37edc430a165ea8d1
@@ -13,6 +13,7 @@ public func Place(int amount, proplist area, ...)
}

public func IsValuable() { return true; }
public func QueryRebuy() { return true; }

local Name = "$Name$";
local Description = "$Description$";
@@ -9,6 +9,7 @@ protected func Hit()
public func IsFoundryProduct() { return true; }
public func GetFuelNeed() { return 100; }
public func IsValuable(){ return true; }
public func QueryRebuy(){ return true; }

local Name = "$Name$";
local Description = "$Description$";
@@ -15,6 +15,7 @@ protected func Hit(x, y)

public func IsFoundryIngredient() { return true; }
public func IsValuable(){ return true; }
public func QueryRebuy(){ return true; }


local Collectible = 1;
@@ -41,6 +41,7 @@ func FxSparkleTimer(target, effect, effect_time)
}

func IsValuable() { return true; }
func QueryRebuy() { return true; }

func OnSale(int to_player, object sale_base)
{
@@ -111,6 +111,12 @@ func DoSell(object obj, int wealth_player)
// Give the player the cash
DoWealth(wealth_player, this->GetSellValue(obj));
Sound("UI::Cash", {player = wealth_player});

// Add the item to the homebase material.
if (!obj->~QueryRebuy(wealth_player, this))
{
this->ChangeBuyableAmount(wealth_player, obj, +1);
}

// OnSale callback to object e.g. for goal updates
obj->~OnSale(wealth_player, this);

0 comments on commit 89718f3

Please sign in to comment.
You can’t perform that action at this time.