Aller au contenu

Photo

Script request for gold taken based on player level


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Bazilbrush

Bazilbrush
  • Members
  • 28 messages
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?

#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
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 .


#3
Bazilbrush

Bazilbrush
  • Members
  • 28 messages
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));

}

#4
MrZork

MrZork
  • Members
  • 942 messages
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 .


#5
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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

#6
Bazilbrush

Bazilbrush
  • Members
  • 28 messages
Thanks for all of the advice guys, I have got it working now. Much appreciated.