Official Community Forums
 
HomeHome  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log in  The Wiki  Website  github Project  

Share | 
 

 ingamne economy system

View previous topic View next topic Go down 
AuthorMessage
tichfuie
Super Contributor
Super Contributor
avatar

Posts : 257
Join date : 2013-02-07
Location : NA

PostSubject: ingamne economy system   Fri 12 Apr - 7:25

i havent seen this yet in mars plugins,
but i winder if there is an existing system for ingame economy, ie: gold, coins to purchase items



if not, i wonder how easy or hard will be to adapt one, or maybe there is some other existing code in mars that can be replicated/tweaked to use it for this?


Back to top Go down
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: ingamne economy system   Fri 12 Apr - 7:44

I believe there was the start of one in the MarsQuest (at least to specify how much gold to give upon completion) It is not all that hard to make the back end for it I believe we just modified the Trading in MarsInventoryPlugin and then made the players gold amount a stat property

Code:
protected boolean changeMoney(long playerOid,int amount){
      Log.debug("changeMoney playerOid = " + playerOid);
      boolean success = false;
      CombatInfo objInfo = getCombatInfo(playerOid);
      if (objInfo == null){
         Log.debug("changeMoney objInfo = null");
         return false;
      }
      Lock objLock = objInfo.getLock();
      try {
         objLock.lock();
         Log.debug("changeMoney withdraw gold start = " + objInfo.statGetCurrentValue("gold"));
         int curMoney = objInfo.statGetCurrentValue("gold");
         if (curMoney >= amount){
            objInfo.statSetBaseValue("gold",curMoney - amount);
            success = true;
         }
      }
      finally {
         objLock.unlock();
      }
      return success;
   }


If that returns true you give the player the item other wise you say the player does not have enough money. I dont recall exactly why I made it a stat instead of just a property but you could probably do it as either. When dealing with items/money Locks are your friends.


Building the actual vendor would probably be a little more complicated and I have not made one. Basically if I were to make one I would create a VendorBehavior that handles request for what the npc sells, as well as buying/selling item requests.


Then you would need to make a gui that opens and shows the list of items and prices
Back to top Go down
tichfuie
Super Contributor
Super Contributor
avatar

Posts : 257
Join date : 2013-02-07
Location : NA

PostSubject: Re: ingamne economy system   Fri 12 Apr - 8:11

thanks
Back to top Go down
Sponsored content




PostSubject: Re: ingamne economy system   

Back to top Go down
 
ingamne economy system
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Pre-WotLK System Requirements
» Tau Smart Missile System
» SYSTEM-OF-A-DOWN app
» TCI Official Forum Ranking System
» WHAT SYSTEM ARE YOU GETTING BF3 FOR?

Permissions in this forum:You cannot reply to topics in this forum
 :: Development :: Getting Started-
Jump to: