Ankündigung

Einklappen
Keine Ankündigung bisher.

Handelsbutton abfragen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Handelsbutton abfragen

    Kurze Frage, die vermutlich(hoffentlich) eine lange ausführliche Antwort nach sich zieht: Ist es möglich die Funktion hinter den Handelsschaltern in einem Markthaus zu "hacken" um damit irgend etwas auszulösen?
    MfG totalwarANGEL

  • #2
    AW: Handelsbutton abfragen

    bestimmt

    Kommentar


    • #3
      AW: Handelsbutton abfragen

      Danke für die ausführliche Antwort.
      Ich würd ja nicht so dumm fragen, wenn es bei S6 eine GUI-Elements gäbe...
      MfG totalwarANGEL

      Kommentar


      • #4
        AW: Handelsbutton abfragen

        Wie wärs denn mit GUI_Merchant.OfferClicked im lokalen?

        Kommentar


        • #5
          AW: Handelsbutton abfragen

          Klingt plausibel...
          MfG totalwarANGEL

          Kommentar


          • #6
            AW: Handelsbutton abfragen

            Sei mal so nett und schreibe, was draus wird.

            Kommentar


            • #7
              AW: Handelsbutton abfragen

              Ich war jetzt selber neugierig. Die GUI_Merchant-Funktionen kannst du vergessen. Je nachdem was du vorhast, könnte es mit mit GUI.BuyMerchantOffer funktionieren. Die Argumente sind die Lagerhaus-ID, die Spieler-ID (1) und die Angebotsnummer.
              Zuletzt geändert von siedlereldeis; 17.10.2011, 22:07.

              Kommentar


              • #8
                AW: Handelsbutton abfragen

                Code:
                function GUI_Merchant.OfferClicked( _ButtonIndex )
                
                    local CurrentWidgetID = XGUIEng.GetCurrentWidgetID()
                
                    -- Get logic data
                    local PlayerID              = GUI.GetPlayerID()
                    local BuildingID            = g_Merchant.ActiveMerchantBuilding
                
                    if BuildingID == 0 then
                        return
                    end
                
                    local PlayersMarketPlaceID  = Logic.GetMarketplace(PlayerID)
                    local TraderPlayerID        = Logic.EntityGetPlayer(BuildingID)
                
                    -- Get offer data
                    local TraderType        = g_Merchant.Offers[_ButtonIndex].TraderType
                    local OfferIndex        = g_Merchant.Offers[_ButtonIndex].OfferIndex
                
                    local GoodType, OfferGoodAmount, OfferAmount, AmountPrices = 0,0,0,0
                
                    -- Check if offer can be bought
                    local CanBeBought = true
                
                    if TraderType == g_Merchant.GoodTrader then
                
                        GoodType, OfferGoodAmount, OfferAmount, AmountPrices = Logic.GetGoodTraderOffer(BuildingID,OfferIndex,PlayerID)
                
                        -- Is space in the storehouse?
                        if Logic.GetGoodCategoryForGoodType(GoodType) == GoodCategories.GC_Resource then
                
                            --ToDo: I think this has to be replaced by a function that gets the overall limit of a storehouse, NOT per goodtype.
                            --local AmountInCastle = GetPlayerGoodsInSettlement( GoodType, PlayerID)
                            --local LimitInCastle  = GetPlayerResourcesLimit( GoodType, PlayerID)
                
                            local SpaceForNewGoods =  Logic.GetPlayerUnreservedStorehouseSpace(PlayerID)
                
                            if SpaceForNewGoods < OfferGoodAmount then
                
                                CanBeBought = false
                
                                local MessageText = XGUIEng.GetStringTableText("Feedback_TextLines/TextLine_MerchantStorehouseSpace")
                                Message(MessageText)
                
                            end
                
                        -- Animal can always be bought
                        elseif Logic.GetGoodCategoryForGoodType(GoodType) == GoodCategories.GC_Animal then
                
                            CanBeBought = true
                
                        -- Goods need space on the marketplace and an upgraded marketplace / EnableRights is used, so this rule can be disabled by ALT F12 for testing
                        else
                
                            if Logic.CanFitAnotherMerchantOnMarketplace(PlayersMarketPlaceID) == false then
                
                                CanBeBought = false
                
                                local MessageText = XGUIEng.GetStringTableText("Feedback_TextLines/TextLine_MerchantMarketplaceFull")
                                Message(MessageText)
                
                            end
                
                        end
                
                    -- Entertainers needs an upgraded marketplace and space on it (same rule like good traders. Can this be merged?)
                    elseif TraderType == g_Merchant.EntertainerTrader then
                
                        if Logic.CanFitAnotherEntertainerOnMarketplace(PlayersMarketPlaceID) == false then
                
                            CanBeBought = false
                            local MessageText = XGUIEng.GetStringTableText("Feedback_TextLines/TextLine_MerchantMarketplaceFull")
                            Message(MessageText)
                        end
                
                    elseif TraderType == g_Merchant.MercenaryTrader then
                
                        GoodType, OfferGoodAmount, OfferAmount, AmountPrices = Logic.GetMercenaryOffer(BuildingID,OfferIndex,PlayerID)
                
                        local CurrentSoldierCount = Logic.GetCurrentSoldierCount(PlayerID)
                        local CurrentSoldierLimit = Logic.GetCurrentSoldierLimit(PlayerID)
                
                        local SoldierSize
                        if GoodType == Entities.U_Thief then
                            SoldierSize = 1
                        else
                            SoldierSize = OfferGoodAmount
                        end
                
                        if (CurrentSoldierCount + SoldierSize) > CurrentSoldierLimit then
                            CanBeBought = false
                            local MessageText = XGUIEng.GetStringTableText("Feedback_TextLines/TextLine_SoldierLimitReached")
                            Message(MessageText)
                        end
                    end
                
                    -- Offer can be bought
                    if CanBeBought == true then
                
                        -- Get Price and Goldamount of player
                        local Price = ComputePrice( BuildingID, OfferIndex, PlayerID, TraderType )
                        local GoldAmountInCastle = GetPlayerGoodsInSettlement(Goods.G_Gold, PlayerID )
                
                        --check if Merchant Cart can reach player (check for player's Gold Cart is superfluous)
                        local PlayerSectorType = PlayerSectorTypes.Civil
                
                        local IsReachable = CanEntityReachTarget(PlayerID, Logic.GetStoreHouse(TraderPlayerID), Logic.GetStoreHouse(PlayerID),
                            nil, PlayerSectorType)
                
                        if IsReachable == false then
                            local MessageText = XGUIEng.GetStringTableText("Feedback_TextLines/TextLine_GenericUnreachable")
                            Message(MessageText)
                            return
                        end
                
                        -- Player has the gold
                        if Price <= GoldAmountInCastle then
                
                            -- Spawn animals at the building via script. Maybe we will move this into an own tradertype after alpha
                            if Logic.GetGoodCategoryForGoodType(GoodType) == GoodCategories.GC_Animal then
                
                                local AnimalType = Entities.A_X_Sheep01
                
                                if GoodType == Goods.G_Cow then
                
                                    AnimalType = Entities.A_X_Cow01
                
                                end
                
                                for i=1,5 do
                                    GUI.CreateEntityAtBuilding(BuildingID, AnimalType, 0)
                                end
                
                            end
                
                            -- Set price
                            GUI.ChangeMerchantOffer(BuildingID,PlayerID,OfferIndex,Price)
                
                            -- Buy offer
                            GUI.BuyMerchantOffer(BuildingID,PlayerID,OfferIndex)
                
                            Sound.FXPlay2DSound( "ui\\menu_click")
                
                            StartKnightVoiceForPermanentSpecialAbility(Entities.U_KnightTrading)
                
                        else
                            local MessageText = XGUIEng.GetStringTableText("Feedback_TextLines/TextLine_NotEnough_G_Gold")
                            Message(MessageText)
                        end
                    end
                end

                Kommentar


                • #9
                  AW: Handelsbutton abfragen

                  Wie findet man sowas denn heraus?

                  Kommentar


                  • #10
                    AW: Handelsbutton abfragen

                    Zitat von CineMachus Beitrag anzeigen
                    Code:
                    function GUI_Merchant.OfferClicked( _ButtonIndex )
                    Hi Cine
                    besser hätte ich es auch nicht schreiben können
                    funk mich doch mal bei gelegenheit an...hab noch was schönes

                    Kommentar

                    Lädt...
                    X