RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] NAM's Achievement Logger v1.01

0 Members and 1 Guest are viewing this topic.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
NAM's Achievement Logger
Authors: NAMKCOR
Version: 1.01
Type: Utility
Key Term: Misc System

Introduction

Fairly simple script, it's a backbone for an Achievement system, much like the 360 or PS3.
NOTE: AT THIS TIME THERE IS -NO- SCENE INCLUDED, IT IS -ONLY- THE SYSTEM ITSELF.

Features

  • Plug and play
  • Saves Achievement data externally, no need to load a game to view!

Screenshots

No screenshots, since I haven't made a scene for it.

Demo

No demo yet.

Script

Spoiler for:
Code: [Select]
#===============================================================================
# Achievement Logger XP version 1.00
#-------------------------------------------------------------------------------
# Function:
#  Allows for a simple scripted Achievement system, much like
#  XBOX360 or PS3 games.
#-------------------------------------------------------------------------------
# Features :
#  - Pretty much plug and play
#  - Saves Achievements externally, so they are independent of save games
#
#  note: this is only a backbone system, there is no scene in this script.
#        a scene will be posted separately.
#-------------------------------------------------------------------------------
# Compatibility:
#  This script -should- be compatible with just about everything
#-------------------------------------------------------------------------------
# Instructions:
#   - Setup for config variables is located where the variables are.
#   
#   - To make an Achievement, simply make an item in the database, and
#     in the elements list, check the box for the element you've chosen
#     to represent Achievements with.
#     It is reccommended that the items are unusable, in order to
#     prevent glitching.
#     
# ---WARNING---
# This system will automatically create and update a file that stores the
# achievements outside the game saves.
#
# The Achievement data file is updated at FIRST runtime (i.e. if the file does
# not exist, and every time that the 'achieve()' method is called.
#
# If you modify the achievements in the database,
# It is reccommended that you delete the acheivement file before running the
# game, after having updated the achievements database.
# Keep in mind that this will clear whatever achievements might have been
# cleared.
# -------------
#   
#   - To give the player an achievement, call the function:
#     $game_achievements.achieve(ITEM_ID)
#     (script event call)
#     where ITEM_ID is the ID of the achievement you are giving the player.
#
#   - As far as other scipts go, a couple methods have been created
#     help make things neater and easier for scripters :)
#
#     $game_achievements.get_achievements
#     :: returns the entire @achievements array.
#
#     $game_achievements.achieved?(item_id)
#     :: returns true if the achievement has been earned, false if not.
#
#     $game_achievements.set_scene(scene)
#     :: use any type of variable you want, to record what scene
#        you just came from
#
#     $game_achievements.get_scene
#     :: return @scene_from
#
#-------------------------------------------------------------------------------
# Contact:
#  Should you encounter a bug or incompatibility with this script,
#  e-mail NAMKCOR at Rockman922@hotmail.com, or message at
#  http://www.rmrk.net or http://www.chaos-project.com/
#
#  This script was designed for use and distribution only on
#  The RPG Maker Resource Kit (RMRK) and Chaos Project.
#  If this script is found posted on any other website, it is STOLEN
#  and it is advised to contact NAMKCOR at the above methods.
#
#  This work is protected by the
#  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
#  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
#
#  By using this work you agree to be bound by the aforementioned liscence
#===============================================================================

module NAMKCOR
 
  #========================================================================
  # ACHIEVEMENT_FILENAME:
  #------------------------------------------------------------------------
  # Self-explanitory, this is the file that the achievement data is
  # contained in when it saves.
  #
  # Can be named anything, with any extension, must be in SINGLE QUOTES ''
  #     'AIDS.std'
  #     'Blizzard.sex'
  #     'Rivy.bdsm'
  #     'Rockman.x'
  #
  # it really doesn't matter, it'll work, have fun with it :P
  #========================================================================
  ACHIEVEMENT_FILENAME = 'achievements.namk'
 
  #========================================================================
  # ACHIEVEMENT_ELEMENT:
  #------------------------------------------------------------------------
  # Also Self-explanitory, this is the ID of the element that represents
  # Achievements.
  #========================================================================
  ACHIEVEMENT_ELEMENT = 20
 
end

#===============================================================================
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
#===============================================================================

class Game_Achievements
 
  def initialize
    @achievements = []
    @achieved = []
    @scene_from
    setup_achievements
  end
 
  def set_scene(scene)
    @scene_from = scene
  end
 
  def get_scene
    return @scene_from
  end
 
  def achieved?(item_id)
    return @achieved.include?(item_id)
  end
 
  def get_achievements
    return @achievements
  end
 
  def achieve(item_id)
    @achieved.push(item_id)
    save_achievements
  end
   
  def setup_achievements
    for i in 1...$data_items.size
      if $data_items[i].element_set.include?(NAMKCOR::ACHIEVEMENT_ELEMENT)
        @achievements.push($data_items[i])
      end
    end
    save_achievements
  end
 
  def save_achievements
    file = File.open(NAMKCOR::ACHIEVEMENT_FILENAME, 'w')
    Marshal.dump(self, file)
    file.close
  end
     
end

$data_items = load_data("Data/Items.rxdata")
if File.exists?(NAMKCOR::ACHIEVEMENT_FILENAME)
  file = File.open(NAMKCOR::ACHIEVEMENT_FILENAME, 'r')
  $game_achievements = Marshal.load(file)
  file.close
else
  $game_achievements = Game_Achievements.new
end

Instructions

Instructions are in the comments section of the script.

Compatibility

No known compatibility issues.

Credits and Thanks

  • NAMKCOR
  • Game_Guy, for motivating me to make a script for a change
  • Blizzard, for his help with loading files

Author's Notes

Contact:
Should you encounter a bug or incompatibility with this script,
e-mail NAMKCOR at Rockman922@hotmail.com, or message at
http://www.rmrk.net or http://www.chaos-project.com/

This script was designed for use and distribution only on
The RPG Maker Resource Kit (RMRK) and Chaos Project.
If this script is found posted on any other website, it is STOLEN
and it is advised to contact NAMKCOR at the above methods.

This work is protected by the
Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
 
By using this work you agree to be bound by the aforementioned lisence
« Last Edit: April 26, 2009, 06:18:39 PM by NAMKCOR »

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
ooo, sexy.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
yeah it's pretty much the same function as the one game_guy posted, except mine saves the info externally so you have a lot more freedom with it.

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon