[ Shine ] GiveRes 1.1

KKyleKKyle Michigan Join Date: 2005-07-01 Member: 55067Members
http://steamcommunity.com/sharedfiles/filedetails/?id=354919755&searchtext=giveres
sh_giveres (Console command) and /giveres (Chat command) ~ Current settings: Marines to marines and/or aliens to aliens. No commanders allowed (yet). checks for the reciever and sees if the requested donation is above 100, and give the portion above 100 back to the donater.
local Shine = Shine

local Plugin = {}
Plugin.Version = "1.1"

function Plugin:Initialise()
self:CreateCommands()
self.Enabled = true
return true
end

function Plugin:CreateCommands()
local function GiveRes( Client, TargetClient, Number )
local Giver = Client:GetControllingPlayer()
local Reciever = TargetClient:GetControllingPlayer()
//local TargetName = TargetClient:GetName()
 //Only apply this formula to pres non commanders // If trying to give a number beyond the amount currently owned in pres, do not continue. Or If the reciever already has 100 resources then do not bother taking resources from the giver
  if Giver:GetTeamNumber() ~= Reciever:GetTeamNumber() or Giver:isa("Commander") or Reciever:isa("Commander") or Number > Giver:GetResources() or Reciever:GetResources() == 100 then return end 

 
            //If giving res to a person and that total amount exceeds 100. Only give what can fit before maxing to 100, and not waste the rest.
            if Reciever:GetResources() + Number > 100 then // for example 80 + 30 = 110
            local GiveBack = 0 //introduce x
            GiveBack = Reciever:GetResources() + Number // x = 80 + 30 (110)
            GiveBack = GiveBack - 100  // 110 = 110 - 100 (10)
            Giver:SetResources(Giver:GetResources () - Number + GiveBack) // Sets resources to the value wanting to donate + the portion to give back that's above 100
            Reciever:SetResources(100) // Set res to 100 anyway because the check above says if getres + num > 100. Therefore it would be 100 anyway.
          //  Notify(StringFormat("[GiveRes] %s has reached 100 resources, therefore you've only donated %s",  TargetName, Number) )
           //Shine:Notify(Client, Number, TargetClient, "Successfully donated %s resource(s) to %s", nil)
            return //prevent from going through the process of handing out res again down below(?)
            end
            ////
 //Otherwise if the giver has the amount to give, and the reciever amount does not go beyond 100, complete the trade. (pres)     
 //Shine:Notify(Client, Number, TargetClient, "Successfully donated %s resource(s) to %s", nil)
Giver:SetResources(Giver:GetResources() - Number)
Reciever:SetResources(Reciever:GetResources() + Number)
//Notify(StringFormat("[GiveRes] Succesfully donated %s resource(s) to %s.",  Number, TargetName) )


//Now for some fun and to expand on the potential of giveres within ns2 that ns1 did not reach?
//In particular, team res and commanders. 

//If the giver is a commander to a recieving teammate then take the resources out of team resources rather than personal.

//if Giver:GetTeamNumber() == Reciever:GetTeamNumber() and Giver:isa(Commander) then
end

local GiveResCommand = self:BindCommand( "sh_giveres", "giveres", GiveRes, true)
GiveResCommand:Help( "giveres <name> <amount> ~ (No commanders)" )
GiveResCommand:AddParam{ Type = "client",  NotSelf = true, IgnoreCanTarget = true }
GiveResCommand:AddParam{ Type = "number", Min = 1, Max = 100, Round = true }
end


function Plugin:Cleanup()
	self:Disable()
	self.BaseClass.Cleanup( self )    
	self.Enabled = false
end

Shine:RegisterExtension( "giveres", Plugin )

Comments

  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts
    So... every alien player pools their rez at the start to get a 30 second onos?
  • CalegoCalego Join Date: 2013-01-24 Member: 181848Members, NS2 Map Tester
    Usefulness of the mod doesn't matter to me as much as the comments in the mod code, helpful to a novice like me.
  • BensonBenson Join Date: 2012-03-07 Member: 148303Members, Reinforced - Shadow, WC 2013 - Shadow
    BeigeAlert wrote: »
    So... every alien player pools their rez at the start to get a 30 second onos?

    30 sec onos with no ups/biomass, and no other lifeforms for half the game?? Could be a problem, but definitely a gamble.
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts
    Benson wrote: »
    BeigeAlert wrote: »
    So... every alien player pools their rez at the start to get a 30 second onos?

    30 sec onos with no ups/biomass, and no other lifeforms for half the game?? Could be a problem, but definitely a gamble.

    60 res for onos = 3 players total starting rez pooled over to 1 player, so on a 7v7 or higher, you could have 2 onos right from the get go. Even 1 would be able to completely deny one whole side of the map, especially if they have a gorge to back them up.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    2 Gorge & 2 Onos against lvl 0 marines, yeah, that's gonna end well....
  • ScatterScatter Join Date: 2012-09-02 Member: 157341Members, Squad Five Blue
    Well, I don't really see what the problem is.

    The mod is unlikely to be used on a regular server and will probably end up in a mod pack/siege mod type thing (the author did create siege mod) with a range of balance changes that the person sees fit. This mod now gives a mechanism to give res to other players where before there was no such mechanism.

    Forest for trees etc.



  • ArchieArchie Antarctica Join Date: 2006-09-19 Member: 58028Members, Constellation, Reinforced - Supporter, WC 2013 - Supporter
    edited December 2014
    Thanks man :D! Actually guys/girls this is for siege servers (as scatter said, and as the creator kkyle is working with siegemod.)

    Also this is a mod from NS1 too, it's pretty usefull when you have gorge doing more work like building chambers/hives etc. It's pretty much for the siegemod really, you were originally meant to give one alien all the res to build resource towers right at the start, or get hives. In NS2 unless you are playing on siegemod this isn't a problem.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Why didn't he put that in the OP?

    For siegemod this is perfect, but as he posted it as a general shine plug-in, I assumed, along with others, this was for ns2, and it would be a really bad idea for ns2.

    I haven't played much NS2 lately, only SCC map tests, so I haven't got around to trying siegemod. Have you removed the alien commander and given building responsibility back to Aliens and Gorges in particular?
Sign In or Register to comment.