Jump to content

Brybry

Member
  • Content Count

    213
  • Joined

  • Last visited

About Brybry

  • Rank
    Hexadecimal Acolyte

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Alternate way to do it: -- This is magical.local __INTEGER_MAP__ = Trait.new("__INTEGER_MAP__", "__INTEGER_MAP__", 0, "__INTEGER_MAP__ Trait Not For Use", false, false);local function numberToInteger(num) if not num or type(num) ~= "number" then num = 0 end __INTEGER_MAP__:addXPBoost(Perks.None, num); local tempMap = transformIntoKahluaTable(__INTEGER_MAP__:getXPBoostMap()); return tempMap[Perks.None];endlocal function getXPForPerkLevel(perk, level) if not perk or not level then return 0 end local target = nil; for i = 0, PerkFactory.PerkList:size() - 1 do local info = PerkFactory.PerkList:get(i); if info:getType() == perk then target = info; break; end end if not target then return 0 end return target:getTotalXpForLevel(level);endfunction applyTraitBoostsToPlayer(player, traitName) if not player or not instanceof(player, "IsoPlayer") then print("Error in applyTraitBoostsToPlayer: invalid player = "..tostring(player)); return end -- Remove this bit if you do not want it if player:HasTrait(traitName) then print("Error in applyTraitBoostsToPlayer: player already has trait: "..tostring(traitName)); return; else player:getTraits():add(traitName); end if not traitName or type(traitName) ~= "string" then print("Error in applyTraitBoostsToPlayer: invalid traitName or player already has trait: "..tostring(traitName)); return end local trait = TraitFactory.getTrait(traitName); if not trait then print("Error in applyTraitBoostsToPlayer: trait "..tostring(traitName).." doesn't exist"); return end local playerBoostMap = player:getDescriptor():getXPBoostMap(); local traitBoostMap = transformIntoKahluaTable(trait:getXPBoostMap()); local xp = player:getXp(); for perk, value in pairs(traitBoostMap) do -- Add the appropriate value to xp boost based off of current value local oldBoost = playerBoostMap:get(perk); if not oldVal then oldBoost = 0; end local newBoost = value:intValue(); newBoost = math.min(3, oldBoost + newBoost); playerBoostMap:put(perk, numberToInteger(newBoost)); -- Level perk trait-value times and set appropriate experience local oldLevel = player:getPerkLevel(perk); local oldXP = xp:getXP(perk) - getXPForPerkLevel(perk, oldLevel); for i = 0, value:intValue()-1 do player:LevelPerk(perk); end xp:setXPToLevel(perk, player:getPerkLevel(perk)); xp:AddXPNoMultiplier(perk, oldXP); endend
  2. I come bearing ugly presents function applyTraitBoostsToPlayer(player, traitName) if not player or not instanceof(player, "IsoPlayer") then print("Error in applyTraitToPlayer: invalid player = "..tostring(player)); return end if not traitName or type(traitName) ~= "string" or player:HasTrait(traitName) then print("Error in applyTraitToPlayer: invalid traitName or player already has trait: "..tostring(traitName)); return end local trait = TraitFactory.getTrait(traitName); if not trait then print("Error in applyTraitToPlayer: trait "..tostring(traitName).." doesn't exist"); return end -- Get existing perks from the player xpBoostMap for caching local xpBoostMap = transformIntoKahluaTable(player:getDescriptor():getXPBoostMap()); local cachedPerks = {}; -- Cache old perk/xp values and set the perk level to 0 for perk, value in pairs(xpBoostMap) do local oldValues = {}; oldValues.level = player:getPerkLevel(perk); local totalXP = player:getXp():getXP(perk); local levelXP = getXPForPerkLevel(perk, oldValues.level); oldValues.xp = totalXP - levelXP; -- Value here is actually java.lang.Integer so convert it oldValues.boost = value:intValue(); cachedPerks[perk] = oldValues; player:level0(perk); end -- Add trait to the player via applyTraits. This applies XP boost and appropriate levels local traitList = ArrayList.new(); traitList:add(traitName); player:applyTraits(traitList); -- Add back old perk levels and XP from cached values for perk, oldValues in pairs(cachedPerks) do local xp = player:getXp(); local curLevel = player:getPerkLevel(perk); local oldLevel = oldValues.level; local oldBoost = oldValues.boost; local targetLevel = oldLevel + curLevel - oldBoost; -- counteracts applyTraits() str/fit +5 if perk == Perks.Strength or perk == Perks.Fitness then targetLevel = targetLevel - 5; end if targetLevel > curLevel then for i = curLevel, targetLevel do player:LevelPerk(perk); end elseif targetLevel < curLevel then for i = curLevel, targetLevel+1, -1 do player:LoseLevel(perk); end end xp:setXPToLevel(perk, player:getPerkLevel(perk)); xp:AddXPNoMultiplier(perk, oldValues.xp); endendfunction getXPForPerkLevel(perk, level) if not perk or not level then return 0 end local target = nil; for i = 0, PerkFactory.PerkList:size() - 1 do local info = PerkFactory.PerkList:get(i); if info:getType() == perk then target = info; break; end end if not target then return 0 end return target:getTotalXpForLevel(level);end Gist in case I update anything I might be able to do a cleaner method since it may be possible to use getXPBoostMap():put() if I can create (or clone) a java.lang.Integer object but I'll have to play with it to see if that will work out. If you only want the XP Boost but not the initial perk levels from the trait then set targetLevel = oldLevel and remove the strength/fitness offset bit.
  3. If you're pulling appid 108600 then you need to pull appid 380870 instead. The "Buying & Running the server" thread may be old and have out of date info. I think the full command is: steamcmd +login $username $password +force_install_dir ./install/path +app_update 380870 validate +quitwith -beta iwillbackupmysave -betapassword lookforthepasswordintheforums if you want the beta branch.
  4. Moddedtibby brought up really poor performance on Firefox which should now be fixed. Not at the moment but maybe someday. TIS would have to expose the options via ISteamGameServer:SetKeyValue() but that also has limited storage capacity (and is maybe shared with the server description? I forget.) Otherwise, I'd have to write a bot that implements opensteamworks via a node.js wrapper and have it connect to servers to pull the server options again. That could happen if I get really bored.
  5. Yeah, sorry about that. There was a bug where I would lose connection to steam and stop updating. I'm going to give it a little love this coming week and improve the performance and add some filters. When I originally made it there weren't the 400(!) servers there are now.
  6. Brybry

    Server Not Responding

    What I'm guessing is happening here is that the OP is trying to set up the server using the base game files and is setting up a non-steam server and then trying to connect to that with a steam enabled client. Follow the instructions in EG's link about downloading SteamCMD and grabbing appId 380870 and using that as that's the easy way to do it. With regards to ports: I don't think steam ports do need to be forwarded anymore. I'm going to write a wiki article on server setup and configuration eventually but as far as I can tell it only needs the game port and map data tcp ports forwarded still. At this time I'm unsure if the game port only needs udp still or if it wants udp and tcp. Steam port 1 is used to talk to steam and so does need to be able to bind and be allowed outbound access but it doesn't need anything inbound. Most setups allow outbound by default or else things like web browsing won't work for them. Steam port 2, as far as I can tell, is unused because I think that functionality (query port) is multiplexed into the game port (default 16261.) After all of the trouble people have been having with ports I'm thinking about how hard it would be to write a mod to put everything on one port TCP/UDP and use UPnP/STUN/TURN to handle forwarding.
  7. Yeah, require() was just flat out broken for mods before, it only worked for base game scripts. Now it both correctly loads (so load order is correct) and returns the loaded module/value. I don't know if it's according to spec with regards to multiple/duplicate imports (aka A requires B and C and B requires C then it shouldn't load C twice) but either way it's leaps and bounds better now
  8. Require is also very important for ensuring load order of scripts -- which is wasn't doing before for mods. For example, if script B.lua declares a global Foobar and script A.lua needs that global but script A loads before script B then script A can require script B to ensure that it has access to Foobar.
  9. yep, OpenJDK Java 7 is working, but with Oracle Java 7 i get errors and with Oracle Java 8 no errors except this unsupported -UseSplitVerifier. the main question is: which is the best for PZ? 7 or 8 , Oracle or OpenJDK It should work fine with Oracle Java 7, it just needs the correct LD_PRELOAD Try editing the shell script to change the first JSIG="`java -classpath pzexe.jar zombie.jsig`" to JSIG="JSIG=`dirname "$(readlink -f $(which java))"`/../lib/amd64/libjsig.so" and the second one to JSIG="JSIG=`dirname "$(readlink -f $(which java))"`/../lib/i386/libjsig.so"
  10. Ok, so due to a potential bug or just weird behavior make sure you have TCP ports forwarded on your router to your server, even if you are connecting from within your internet network or localhost. I think this issue is related.
  11. At first glance it looks like TCP port 16262+ is blocked in some way (firewall, not being forwarded, client or server jvm trying to use ipv6 instead of ipv4, etc) and so the client can't connect to that for the map info and is doing a normal clean disconnect.
  12. Brybry

    Lua Parameters

    For instance... how does the game know to make your specific player say "I love pzmods.net" only from the parameter _player? I know this is not exactly an example of what I was talking about above, but it is similar. I assume the order of the parameters in the function matters? Like it would have a different result or an error if it was instead: function UIDestroyItems.onDestroyItem(_player, _item, _items)? So when you do something like: function YourFunction(argument1, argument2, ...) ...endEvents.OnSomeEvent.Add(YourFunction);on the java side of things YourFunction gets added to a list of functions to call when the event OnSomeEvent is triggered. The triggering is done in java or lua where appropriate with something like triggerEvent("OnSomeEvent", parameter1, parameter2, ...) Thus the event parameters are constant in number and type as defined by the triggering function triggerEvent(). To know what arguments you need to put in your event handler function YourFunction() you have to look at other lua examples where that event was used or find where someone else has done the legwork and documented it for you (or decompile java and find the triggering function usage.)
  13. For infinite carry weight then you could hook the item transfer timed action and make the items weigh 0 when putting them on a player and then put them back to their original weight when transferring them to a container/ground/anywhere that's not the player. Might have to be done on game start as well depending if item weight saves or not. Or you could even do something crazy like add an invisible item with negative weight to the player's inventory. And there's probably something that can be hooked to fix the weight transfer over capacity issue but I haven't looked into it for the cause of that yet. Most of that stuff is done in lua and thus mutable.
  14. You used to be able to with java reflection but that was a security issue and so was taken out. Since there is no setCapacity() you have to be clever and use something else to get the same effect. In this case you can probably use some combination of getPlayer():setMaxWeight, getPlayer():setMaxWeightBase, and getPlayer():setMaxWeightDelta and/or getPlayer():getWeightMod() Something like: local targetWeight = 50;getPlayer():setMaxWeightBase(targetWeight / getPlayer:getWeightMod());Note that BodyDamage:UpdateStrength() still applies modifiers from hunger and well fed and strength (getWeightMod() is the strength modifier) so if you have to also potentially detect and adjust for those. Also, of the player has god mode that might not work (as I think it might then ignore BodyDamage:UpdateStrength()'s modifiers) and so a simple getPlayer():setMaxWeight(50); would probably work in that case. I don't think the weight values save between sessions either so they probably have to be applied when appropriate.
  15. For efficiency you can do something like this: local recipes = getAllRecipes();local knownRecipes = getPlayer():getKnownRecipes();for i = 0, recipes:size()-1 do local recipe = recipes:get(i); if recipe:needToBeLearn() and not knownRecipes:contains(recipe:getOriginalname()) then knownRecipes:add(recipe:getOriginalname()); --print("Added Recipe ["..recipe:getOriginalname().."] from module "..recipe:getModule():getName()); endend
×
×
  • Create New...