Jump to content

Profession Framework Mod


Fenris_Wolf

Recommended Posts

Hi. I am a super new to modding PZ and wanted to try to make some custom professions using this framework but for some reason no matter what i do it won't work. I downloaded this framework from the github link unzipped it and put it on my mod folder then I tried make my profession based of the examples in the PFW folder formatted it like a mod and put it in the mod folder. I activated my mod and the PFW mod, but it won't showup in character creation. Can you take a look at my code and tell me what I am doing wrong?

 

addProfession('Hitter', {
    name = "Pinch Hitter",
    description="When the bases are loaded with two outs...",
    icon = "",
    cost = 0,
    xp = {
        [Perks.Fitness] = 1,
        [Perks.Long_blunt] = 2,
        [Perks.Sprinting] = 2,
    },
    
    inventory = {
        ["Base.BaseballBat"] = 1,
        ["Base.Baseball"] = 1,
    },
})
 

leonProfessions.lua

 

 

Edit: Also I am running the newest IWBUMS build on steam.

Edited by leon2356
Link to comment
Share on other sites

On 3/19/2020 at 11:41 AM, Fenris_Wolf said:

None of the functions are global. you need to prefix your function call:
ProfessionFramework.addProfession

 

Sorry, I'm super new to modding when you say "prefix your function call", what do you mean exactly. You mean like this?:

 

ProfessionFramework.addProfession('Hitter', {
    name = "Pinch Hitter",
    description="When the bases are loaded with two outs...",
    icon = "",
    cost = 0,
    xp = {
        [Perks.Fitness] = 1,
        [Perks.Long_blunt] = 2,
        [Perks.Sprinting] = 2,
    },
    
    inventory = {
        ["Base.BaseballBat"] = 1,
        ["Base.Baseball"] = 1,
    },
})

leonProfessions.lua

 

Because it is still not working.

Edited by leon2356
Link to comment
Share on other sites

I tried a few other things like trying to add one of the example changes you provided with the mod:

 

ProfessionFramework.addProfession('carpenter', {
    cost = 4,
    xp = {
        [Perks.Woodwork] = 4,
    },
    inventory = {
        ["Base.Hammer"] = 2,
        ["Base.Saw"] = 1,
        ["Base.Woodglue"] = 3,
        ["Base.NailsBox"] = 3,
    },
    square = {
        ["Base.Plank"] = 10,
    },
})

 

As well as the traited you provided as well:

 

ProfessionFramework.addTrait('Nightmares', {
    name = "UI_trait_nightmares",
    description = "UI_trait_nightmaresdesc",
    exclude = {"Desensitized"},
    cost = -4,
    requiresSleepEnabled = true,
    inventory = {
        ["Base.PillsBeta"] = 1,
        ["Base.PillsSleepingTablets"] = 1,
    },
    OnGameStart = function(trait)
        Events.EveryTenMinutes.Add(function()
            local p = getSpecificPlayer(0)
            if p:isAsleep() and ZombRand(100) < 2 then
                p:forceAwake()
                p:getStats():setPanic(90)
            end
        end)
    end
})

 

And neither work. Is there a special place I have to place the "profession framework mod" in? I put it in: C:\Users\User\Zomboid\mods.

I also tried all this with the steam version and that did not work either.

Edited by leon2356
Link to comment
Share on other sites

I have the Framework mod in  ...\Zomboid\mods\ProfessionalFramework-master

I have my Profession lua in ...\Zomboid\media\lua\shared\MYPROFESSIONS.lua

 

There is an issue with your example....

Unlike [Perks.SmallBlunt] (no space) Long is just [Perks.Blunt]...  So the script stops at that mistake, and does not apply sprinting, or anything passed that line. Otherwise, I pasted your example in myprofession mod, and it appears in the setup option just fine...

 

ProfessionFramework.addProfession('Hitter', {
    name = "Pinch Hitter",
    description="When the bases are loaded with two outs...",
    icon = "",
    cost = 0,
    xp = {
        [Perks.Fitness] = 1,
        [Perks.Blunt] = 2,  <<<<<<===== FIX THIS SO IT READS AS SUCH
        [Perks.Sprinting] = 2,
    },
    
    inventory = {
        ["Base.BaseballBat"] = 1,
        ["Base.Baseball"] = 1,
    },
})

 

 

Link to comment
Share on other sites

On 3/23/2020 at 5:12 PM, Arsenal26 said:

I have the Framework mod in  ...\Zomboid\mods\ProfessionalFramework-master

I have my Profession lua in ...\Zomboid\media\lua\shared\MYPROFESSIONS.lua

 

There is an issue with your example....

Unlike [Perks.SmallBlunt] (no space) Long is just [Perks.Blunt]...  So the script stops at that mistake, and does not apply sprinting, or anything passed that line. Otherwise, I pasted your example in myprofession mod, and it appears in the setup option just fine...

 

ProfessionFramework.addProfession('Hitter', {
    name = "Pinch Hitter",
    description="When the bases are loaded with two outs...",
    icon = "",
    cost = 0,
    xp = {
        [Perks.Fitness] = 1,
        [Perks.Blunt] = 2,  <<<<<<===== FIX THIS SO IT READS AS SUCH
        [Perks.Sprinting] = 2,
    },
    
    inventory = {
        ["Base.BaseballBat"] = 1,
        ["Base.Baseball"] = 1,
    },
})

 

 

So, the PFM is in the same place as you have it but my profession mod in in: C:\Users\user\Zomboid\mods\leonProfessions\media\lua\shared/leonprofessions.lua

 

When i look in "zomboid" there is no "media" file.

 

I still tried to copy your fixed code into my file but the profession still does not show up in character creator.

 

Edit: also I have been trying this with just my mod and the profession framework mods on and no other mods.

Edited by leon2356
Link to comment
Share on other sites

3 hours ago, leon2356 said:

C:\Users\user\Zomboid\mods\leonProfessions\media\lua\shared/leonprofessions.lua

 

When i look in "zomboid" there is no "media" file.

Oh Ooops... my bad...  that's correct, should have read :

I have my Profession lua in ...\Zomboid\mods\MyProfessionsMod\media\lua\shared\MYPROFESSIONS.lua

 

Random thoughts...

- Are you testing on a new game ? or old save ? bcuz new mod memory may cause issues

- Right version of game ?

- Try disabling all mods, and re-enable them making sure PFM is activated before your custom professions mod...

- Console.txt throwing any errors ? scrolling all the way up may reveal where its hanging up or unable to find something...

 

Link to comment
Share on other sites

Ok, so.

- I am on version, 41.33.

- I am testing it on a new save.

- I have all mods off expect profession framework and my professions mod.  In the load order it is "Profession framework" then my mod.

- In Console.txt there is only one error "LOG  : General, 1585159547880> ERROR: Missing translation "UI_Loading_Mods" I'll attach a copy of it to this post. Maybe you will see something I can't.

 

console.txt

Link to comment
Share on other sites

5 hours ago, leon2356 said:

Ok, so.

- I am on version, 41.33.

- I am testing it on a new save.

- I have all mods off expect profession framework and my professions mod.  In the load order it is "Profession framework" then my mod.

- In Console.txt there is only one error "LOG  : General, 1585159547880> ERROR: Missing translation "UI_Loading_Mods" I'll attach a copy of it to this post. Maybe you will see something I can't.

 

console.txt 94.87 kB · 0 downloads

 

 

Ok, so PFM is loading just fine... but your leonprofessions mod is not getting loaded.... New professions should appear immediately after the console line :

LOG  : General, 1585178807101> ProfessionFramework.INFO: Adding Trait Jogger2

And be at the BOTTOM of the list in game character setup screen...

 

I did notice that there is an issue with examplemod refusing to load...

 

Are you sure you setup your leonProfessions mod correctly ?

ie, mod.info file in your leonProfessions folder...

 

Might wanna look there bcuz its trying to load "examplemod" and failing, and there is no sign of "leonprofessions" trying to load at all...

Link to comment
Share on other sites

21 hours ago, Arsenal26 said:

Are you sure you setup your leonProfessions mod correctly ?

ie, mod.info file in your leonProfessions folder...

OH GOOOOOOOD LOOOOORRRRRD!!!!!

 

That fixed it... I forgot to change the mod id in mod.info because all I did was copy and paste the mod.info from the example mod over. You are my hero!

Just Loaded it up and now I can see the profession.

 

I'm now a modder, YAY!

 

Edit: Is there anywhere I can see where the names of "perks" are so I don't have a repeat of the long blunt fiasco?

Edited by leon2356
Link to comment
Share on other sites

@Fenris_Wolf

 

So now that i got this working I think I found a bug?

When I try to add [perks.Tailoring] to my profession, the profession does not load. but if I remove it it works perfectly. Also I saw that the sewer trait is missing from default_traits.lua.

Edited by leon2356
Link to comment
Share on other sites

On 3/26/2020 at 12:52 PM, leon2356 said:

So now that i got this working I think I found a bug?

When I try to add [perks.Tailoring] to my profession, the profession does not load. but if I remove it it works perfectly. Also I saw that the sewer trait is missing from default_traits.lua.

PF knows nothing about individual perks. If adding it to your profession causes a error, then its going to be due to a typo on your end (ie: [perks.Tailoring] vs [Perks.Tailoring].

Need to keep your eye on the console.txt, since any errors will show up there, and will often let you know exactly where you've gone wrong.

defaults_traits.lua is just a example file atm and not actually used anyways. Its missing from there since I haven't had time to work on the mod since before tailoring was introduced.

Link to comment
Share on other sites

4 hours ago, Fenris_Wolf said:

PF knows nothing about individual perks. If adding it to your profession causes a error, then its going to be due to a typo on your end (ie: [perks.Tailoring] vs [Perks.Tailoring].

Need to keep your eye on the console.txt, since any errors will show up there, and will often let you know exactly where you've gone wrong.

Yep you were right. I did a copy and paste and it works now mb sorry. Thanks for the help love your mod! I do hope you get the chance to work on it some more and add the other traits it is missing.

Edited by leon2356
Link to comment
Share on other sites

Just released my first full mod!

 

Get a job!

https://steamcommunity.com/sharedfiles/filedetails/?id=2040632854

 

Thanks again for making profession framework. Had a lot of fun making my mod and I made sure to credit you! If you want I can friend you on steam and credit you as a co-creator.

 

Now I just got to learn how to make traits.

Edited by leon2356
Link to comment
Share on other sites

9 hours ago, Dr_Cox1911 said:

@leon2356Will try it out! I have one small suggestion though, you should add the profession framework as a dependency for your workshop mod, so that if people subscribe to your mod they automatically get PFM.

 

@Fenris_WolfShould I bump the version on the workshop?

@Dr_Cox1911

I tried my mod with the version on steam and it does not work. You need the github version for it to work. When the version on steam updates i will test it and if it works I'll add it as a dependency.

Edited by leon2356
Link to comment
Share on other sites

  • 1 month later...
On 3/26/2020 at 11:35 AM, leon2356 said:

OH GOOOOOOOD LOOOOORRRRRD!!!!!

 

That fixed it... I forgot to change the mod id in mod.info because all I did was copy and paste the mod.info from the example mod over. You are my hero!

Just Loaded it up and now I can see the profession.

 

I'm now a modder, YAY!

 

Edit: Is there anywhere I can see where the names of "perks" are so I don't have a repeat of the long blunt fiasco?

Hi PZ community!!!

Can you please let me know where I can find this info (Is there anywhere I can see where the names of "perks" )?

Thanks, I hope you are well.

Link to comment
Share on other sites

@WATTOThose are the perks for the current stable build 40.43:

Quote

    None(0),
    Agility(1),
    Cooking(2),
    Melee(3),
    Crafting(4),
    Fitness(5),
    Strength(6),
    Blunt(7),
    Axe(8),
    Sprinting(9),
    Lightfoot(10),
    Nimble(11),
    Sneak(12),
    Woodwork(13),
    Aiming(14),
    Reloading(15),
    Farming(16),
    Survivalist(17),
    Fishing(18),
    Trapping(19),
    Passiv(20),
    Firearm(21),
    PlantScavenging(22),
    BluntParent(23),
    BladeParent(24),
    BluntGuard(25),
    BladeGuard(26),
    BluntMaintenance(27),
    BladeMaintenance(28),
    Doctor(29),
    Electricity(30),
    Blacksmith(31),
    MetalWelding(32),
    Melting(33),
    Mechanics(34),
    MAX(35);

 

Link to comment
Share on other sites

  • 6 months later...

Hi, So I use this mod as a requirement for a mod i made on steam, and one of the users found a bug where if you make a custom trait, using PFM. Then, try to save that trait in a loadout. The trait will not be be in the loadout when you load it, and you will have to re add the trait everytime you load the loadout.

Link to comment
Share on other sites

  • 2 weeks later...

Hi. I got a question. If i wanted to make a trait like Axeman, but, make it for something like baseball bats, or handguns. How would I go about doing that?

 Is there anywhere i can see how axeman is coded. From that i can reverse engineer it to work for other weapons.

Edited by leon2356
Link to comment
Share on other sites

@leon2356I quickly skimmed through the sourcecode and found a couple of mentions of Axeman.

Don't know if these are all of them though:

IsoGameCharacter.class

protected float calculateCombatSpeed() {
    float f = 1.0F;
    HandWeapon handWeapon = null;
    if (getPrimaryHandItem() != null && getPrimaryHandItem() instanceof HandWeapon) {
      handWeapon = (HandWeapon)getPrimaryHandItem();
      f *= ((HandWeapon)getPrimaryHandItem()).getBaseSpeed();
    } 
    WeaponType weaponType = WeaponType.getWeaponType(this);
    if (handWeapon != null && handWeapon.isTwoHandWeapon() && getSecondaryHandItem() != handWeapon)
      f *= 0.77F; 
    if (handWeapon != null && this.Traits.Axeman.isSet() && handWeapon.getCategories().contains("Axe"))
      f *= getChopTreeSpeed(); 
    f -= getMoodles().getMoodleLevel(MoodleType.Endurance) * 0.07F;
    f -= getMoodles().getMoodleLevel(MoodleType.HeavyLoad) * 0.07F;
    f += getWeaponLevel() * 0.03F;
    f += getPerkLevel(PerkFactory.Perks.Fitness) * 0.02F;
    f *= Rand.Next(1.1F, 1.2F);
    f *= this.combatSpeedModifier;
    f *= getArmsInjurySpeedModifier();
    if (getBodyDamage() != null && getBodyDamage().getThermoregulator() != null)
      f *= getBodyDamage().getThermoregulator().getCombatModifier(); 
    f = Math.min(1.6F, f);
    f = Math.max(0.8F, f);
    if (handWeapon != null && handWeapon.isTwoHandWeapon() && weaponType.type.equalsIgnoreCase("heavy"))
      f *= 1.2F; 
    return f * GameTime.getAnimSpeedFix();
  }

public float getChopTreeSpeed() {
    return (this.Traits.Axeman.isSet() ? 1.25F : 1.0F) * GameTime.getAnimSpeedFix();
  }

HandWeapon.class

public float getSpeedMod(IsoGameCharacter paramIsoGameCharacter) {
    if (this.ScriptItem.Categories.contains("Blunt")) {
      int i = paramIsoGameCharacter.getPerkLevel(PerkFactory.Perks.Blunt);
      if (i >= 10)
        return 0.65F; 
      if (i >= 9)
        return 0.68F; 
      if (i >= 8)
        return 0.71F; 
      if (i >= 7)
        return 0.74F; 
      if (i >= 6)
        return 0.77F; 
      if (i >= 5)
        return 0.8F; 
      if (i >= 4)
        return 0.83F; 
      if (i >= 3)
        return 0.86F; 
      if (i >= 2)
        return 0.9F; 
      if (i >= 1)
        return 0.95F; 
    } 
    if (this.ScriptItem.Categories.contains("Axe")) {
      int i = paramIsoGameCharacter.getPerkLevel(PerkFactory.Perks.Axe);
      float f = 1.0F;
      if (paramIsoGameCharacter.Traits.Axeman.isSet())
        f = 0.95F; 
      if (i >= 10)
        return 0.65F * f; 
      if (i >= 9)
        return 0.68F * f; 
      if (i >= 8)
        return 0.71F * f; 
      if (i >= 7)
        return 0.74F * f; 
      if (i >= 6)
        return 0.77F * f; 
      if (i >= 5)
        return 0.8F * f; 
      if (i >= 4)
        return 0.83F * f; 
      if (i >= 3)
        return 0.86F * f; 
      if (i >= 2)
        return 0.9F * f; 
      if (i >= 1)
        return 0.95F * f; 
      return 1.0F * f;
    } 
    if (this.ScriptItem.Categories.contains("Spear")) {
      int i = paramIsoGameCharacter.getPerkLevel(PerkFactory.Perks.Spear);
      if (i >= 10)
        return 0.65F; 
      if (i >= 9)
        return 0.68F; 
      if (i >= 8)
        return 0.71F; 
      if (i >= 7)
        return 0.74F; 
      if (i >= 6)
        return 0.77F; 
      if (i >= 5)
        return 0.8F; 
      if (i >= 4)
        return 0.83F; 
      if (i >= 3)
        return 0.86F; 
      if (i >= 2)
        return 0.9F; 
      if (i >= 1)
        return 0.95F; 
    } 
    return 1.0F;
  }

IsoTree

public void WeaponHit(IsoGameCharacter paramIsoGameCharacter, HandWeapon paramHandWeapon) {
    int i = paramHandWeapon.getConditionLowerChance() * 2 + paramIsoGameCharacter.getMaintenanceMod();
    if (!paramHandWeapon.getCategories().contains("Axe"))
      i = paramHandWeapon.getConditionLowerChance() / 2 + paramIsoGameCharacter.getMaintenanceMod(); 
    if (Rand.NextBool(i))
      paramHandWeapon.setCondition(paramHandWeapon.getCondition() - 1); 
    paramIsoGameCharacter.getEmitter().playSound("ChopTree");
    WorldSoundManager.instance.addSound(null, this.square.getX(), this.square.getY(), this.square.getZ(), 20, 20, true, 4.0F, 15.0F);
    setRenderEffect(RenderEffectType.Hit_Tree_Shudder, true);
    float f = paramHandWeapon.getTreeDamage();
    if (paramIsoGameCharacter.Traits.Axeman.isSet() && paramHandWeapon.getCategories().contains("Axe"))
      f *= 1.5F; 
    this.damage = (int)(this.damage - f);
    if (this.damage <= 0) {
      this.square.transmitRemoveItemFromSquare(this);
      paramIsoGameCharacter.getEmitter().playSound("FallingTree");
      this.square.RecalcAllWithNeighbours(true);
      int j = this.LogYield;
      byte b;
      for (b = 0; b < j; b++) {
        this.square.AddWorldInventoryItem("Base.Log", 0.0F, 0.0F, 0.0F);
        if (Rand.Next(4) == 0)
          this.square.AddWorldInventoryItem("Base.TreeBranch", 0.0F, 0.0F, 0.0F); 
        if (Rand.Next(4) == 0)
          this.square.AddWorldInventoryItem("Base.Twigs", 0.0F, 0.0F, 0.0F); 
      } 
      reset();
      CellLoader.isoTreeCache.add(this);
      for (b = 0; b < IsoPlayer.numPlayers; ) {
        LosUtil.cachecleared[b] = true;
        b++;
      } 
      IsoGridSquare.setRecalcLightTime(-1);
      GameTime.instance.lightSourceUpdate = 100.0F;
      LuaEventManager.triggerEvent("OnContainerUpdate");
    } 
    LuaEventManager.triggerEvent("OnWeaponHitTree", paramIsoGameCharacter, paramHandWeapon);
  }

I guess those things you would have to mimic in Lua if a baseballbat is equipped and the character wielding it has your trait.

Link to comment
Share on other sites

  • 9 months later...

Hi! Thanks for the great mod! Easy and fun to use. However, I have problems with modding the spawn point for a specific profession. Does anyone knows a working example and is willing to share? I tried coding the spawn point according to the example in the readme file (the one from here: https://github.com/FWolfe/ProfessionFramework) but this doesn't work for me. Thanks for help!

 

I posted the same question on the steam workshop for this mod. See here: https://steamcommunity.com/sharedfiles/filedetails/?id=2216760107&searchtext=profession+framework. My user name on steam: razab (same as here). Hope that's ok.

 

 

-----------------------------------------------------------------------------------------

 

Let me provide some details:

 

For adding a new profession "Veterinarian", I created a .lua-file with the following code:

 

 

ProfessionFramework.addProfession('Veterinarian', {
    name = "Veterinarian",
    description="",
    icon = "",
    cost = 0,
    xp = {
        [Perks.Doctor] = 2,
        [Perks.Trapping] = 1,
        [Perks.SmallBlade] = 1,
    },
})

 

 

Together with the profession framework mod, this works as intended.

 

I then tried to extend the code in order to define a spawn point according to the example from the github page. My extended code is this:

 

 

ProfessionFramework.addProfession('Veterinarian', {
    name = "Veterinarian",
    description="",
    icon = "",
    cost = 0,
    xp = {
        [Perks.Doctor] = 2,
        [Perks.Trapping] = 1,
        [Perks.SmallBlade] = 1,
    },
    spawn = {
        "Muldraugh, KY" = {
            { worldX=36, worldY=31, posX=140, posY=74 },
        }
    }
})

 

The intended spawn point is what is called "isolated house" in the Project Zomboid Map Project (see here: https://map.projectzomboid.com) in Muldraugh.

 

Trying to load this in the ingame mod-menu produces an error displayed in the bottom right corner of the screen. The game still works but the new profession "Veterinarian" doesn't show up in the occupation&traits-menu of the game anymore.

 

Again, thanks for help and sorry for my bad/awkward English (not a native speaker ;) ).

Edited by razab
provided more details
Link to comment
Share on other sites

  • 2 months later...

Hey Fenris, can I post the development version to steam? That one has more traits available then the one currently on steam and its the one i based my mod on. so if anyone wants to use my mod, they need to download the version from github. Is it ok if i upload the newer one to steam? I will make sure you get credit, i just want to make it more accessible. It makes it easier to make more diverse professions.

Edited by leon2356
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...