[v0.1.1] Stupid Achievements

Post your example zscripts/ACS scripts/etc here.

Re: [v0.1] Stupid Achievements

Postby f7cjo » Mon Aug 03, 2020 10:56 am

I can't PM, as my account is too young, here is my achievement:
Code: Select allExpand view
class ni_departure : sa_Achievement
{
  Default
  {
    sa_Achievement.name "Early Departure";
    sa_Achievement.description "Decide it's not worth it";
    sa_Achievement.borderColor 0xA30000;
    sa_Achievement.boxColor    0xff0000;
  }
}

just a small test achievment.
Here is the ACS line that causes the crash:
Code: Select allExpand view
ScriptCall("sa_Achiever", "achieve", "ni_departure");

I load the pk3 file with my achievement after the stupid achievements library. The achievements menu in the settings works fine.
f7cjo
 
Joined: 02 Jul 2020
Location: poland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [v0.1] Stupid Achievements

Postby m8f » Mon Aug 03, 2020 12:19 pm

Hmm. What if you change sa_Achiever.achieve signature so it looks like this:
Code: Select allExpand view
  static
  void achieve(String achievementClass)
  {
    achievePrivate(achievementClass);
  }

in zscript/StupidAchievement.zs.

One more thing: please replace "sa_" namespace with your own.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit

Re: [v0.1] Stupid Achievements

Postby f7cjo » Mon Aug 03, 2020 12:36 pm

It works now, thank you for the help.
f7cjo
 
Joined: 02 Jul 2020
Location: poland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [v0.1] Stupid Achievements

Postby m8f » Mon Aug 03, 2020 8:26 pm

Version 0.1.1 is up.
Changelog:
- fixed access to achievements from ACS.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit

Re: [v0.1.1] Stupid Achievements

Postby Laskow » Sun Jul 04, 2021 5:37 am

Can you teach me how to replace Imp by monsters? I expected it's very easy if I can use bIsMonster but it didn't work.
User avatar
Laskow
 
Joined: 16 Feb 2021

Re: [v0.1.1] Stupid Achievements

Postby m8f » Sun Jul 04, 2021 5:52 am

Do you mean how to make achievements for other monsters?

You have to add checks for monster classes. Impness is checked here. This function does the following:
1. Check if something has replaced the original imp.
2. Check if this is an imp or it's inherited from imp. ZScript has this handy construction a is "DoomImp", where a is a tested actor, and the class is after is.
3. If any of above is true, consider this thing an Imp.

When you have similar functions for other monsters (or even generalized function which takes checked monster class as a string parameter), you can use them in event functions in EventHandler (the ones with override) and give the corresponding achievements.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit

Re: [v0.1.1] Stupid Achievements

Postby Laskow » Sun Jul 04, 2021 6:50 am

Yes, and for all actors who used the flag "monster".

Thankfully, other monsters achievements works fine now! However, I think it's not going well actually because this code doesn't work by 2 errors:

Unknown class name 'Cultist' of type 'Actor'
Unknown identifier 'isReplacingCultist'


Code: Select allExpand view
  private
  bool isCultist(Actor a)
  {
    bool isReplacingCultist = ("Cultist" == Actor.getReplacee(a.getClass()));
    bool isBasedOnCultist = (a is "Cultist");
    return (isReplacingCultist || isBasedOnCultist);
  }



But this one works without a hitch.
Code: Select allExpand view
  private
  bool isCultist(Actor a)
  {
    bool isBasedOnCultist = (a is "Cultist");
    return (isBasedOnCultist);
  }



Note that the actor "Cultist" is the custom one.
User avatar
Laskow
 
Joined: 16 Feb 2021

Re: [v0.1.1] Stupid Achievements

Postby m8f » Sun Jul 04, 2021 6:59 am

To check for custom classes, which may or not be loaded, you need a trick: put class in a string constant, like this:
Code: Select allExpand view
  bool isCultist(Actor a)
  {
    string cultistClass = "Cultist";
    bool isReplacingCultist = (cultistClass == Actor.getReplacee(a.getClass()));
    bool isBasedOnCultist = (a is cultistClass);
    return (isReplacingCultist || isBasedOnCultist);
  }


Again, it would be even better to move classes to function parameters entirely to prevent code duplication, like this:
Code: Select allExpand view
  bool isMonsterClass(Actor a, string checkClass)
  {
    bool isReplacing = (checkClass == Actor.getReplacee(a.getClass()));
    bool isBasedOn = (a is checkClass);
    return (isReplacing || isBasedOn);
  }
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit

Re: [v0.1.1] Stupid Achievements

Postby Laskow » Sun Jul 04, 2021 10:37 am

Finally it works fine.
Thank you so much for your help! I'm not an expert of ZScript so that was so helpful.
User avatar
Laskow
 
Joined: 16 Feb 2021

Previous

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests