Author Topic: Script request for gold taken based on player level  (Read 317 times)

Legacy_Bazilbrush

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Script request for gold taken based on player level
« on: June 30, 2011, 01:44:36 pm »


               At the moment I am creating my own death system. When a player dies, they are transported to an area with no exits and are given a 'death stone' which curses them and makes them blind. The only way to get out of the area is to talk to the Reaper who will take the death stone out of their inventory for a certain amount of gold reflected on the level of the player.

Only trouble is that I can't work out how to do this. I can get the Reaper to take a set amount gold off the player but this is unfair on lower level players. What I need is a script that will take a percentage of gold from the player based on their level. This script will be placed on the Actions Taken node of a conversation. Can anyone out there help me out with a script that does this?
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Script request for gold taken based on player level
« Reply #1 on: June 30, 2011, 01:52:58 pm »


               Can you post the script you have right now and we can show you how to modify it so that it does as you need? Also, what percentage of gold do you want taken? What sort of math do you want (ex. 1000gp/level or 10% of total gold, etc.)?
               
               

               


                     Modifié par _Knightmare_, 30 juin 2011 - 12:54 .
                     
                  


            

Legacy_Bazilbrush

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Script request for gold taken based on player level
« Reply #2 on: June 30, 2011, 01:59:08 pm »


               Ok Knightmare, here it is. I was thinking of 10% of the players gold. Here is the script I am using at the moment.

void main()
{

object oPC = GetPCSpeaker();

object oItem;
oItem = GetItemPossessedBy(oPC, "deathstone");

if (GetIsObjectValid(oItem))
   DestroyObject(oItem);

AssignCommand(oPC, TakeGoldFromCreature(100, oPC, TRUE));

object oTarget;
location lTarget;
oTarget = GetWaypointByTag("area01");

lTarget = GetLocation(oTarget);

//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));

oTarget = oPC;

//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead

int nInt;
nInt = GetObjectType(oTarget);

if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oTarget));

}
               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
Script request for gold taken based on player level
« Reply #3 on: June 30, 2011, 02:52:31 pm »


               Maybe replace

AssignCommand(oPC, TakeGoldFromCreature(100, oPC, TRUE));

with

int iAmount = GetGold(oPC)/10;
AssignCommand(oPC, TakeGoldFromCreature(iAmount, oPC, TRUE));


BTW, it kind of looks like the code near the bottom will just play an effect on the PC (since the GetObectType check is on the oPC object that should never be a waypoint). If that's what you intend, you can probably get by without so much checking...
               
               

               


                     Modifié par MrZork, 30 juin 2011 - 01:53 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Script request for gold taken based on player level
« Reply #4 on: June 30, 2011, 05:17:17 pm »


               Use a local, not an inventory item. The inventory-based way is far more susceptible to bugging. Having a full inventory is just one possibility.

Funky
               
               

               
            

Legacy_Bazilbrush

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Script request for gold taken based on player level
« Reply #5 on: June 30, 2011, 06:10:10 pm »


               Thanks for all of the advice guys, I have got it working now. Much appreciated.