Author Topic: Character Variables  (Read 6864 times)

0 Members and 1 Guest are viewing this topic.

Offline Kvetch

  • Administrator
  • Hero Member
  • *****
  • Posts: 729
    • View Profile
    • Email
Character Variables
« on: April 26, 2012, 07:23:51 pm »
These are used in scripts, usually using %actor.<something or other>%  This is directly from the wonderful people at The Builder's Academy.  4Dimensions does actually have more than these, but these are a good fallback for almost anything.

Characters

In this context, %char% represents a variable for a character,

%obj% is a variable for an object, and %room% is a variable for a room.

When using field:
   

The variable returns:

%char.alias%
   

The list of aliases of the mob or the character name for players.

%char.align(<number>)%
%char.align%
   

The numeric alignment of the character.
If a subfield is provided, the alignment is set to this value.
-1000 <= subfield <= 1000.

%char.affect(<spellname>)%
   

True if the character is affected by the spell <spellname>.
Example: %self.affect(bless)%

%char.canbeseen%
   

True if the character can be seen by the mob.
Always returns true for non-mob triggers.

%char.cha%
%char.cha(<value>)%
   

The character's charisma.
If a subfield is provided, the value is added to the current stat.

%char.class%
   

The character's class, as a string.

%char.con%
%char.con(<value>)%
   

The character's constitution.
If a subfield is provided, the value is added to the current stat.

%char.dex%
%char.dex(<value>)%
   

The character's dexterity.
If a subfield is provided, the value is added to the current stat.

%char.exp%
%char.exp(<amount>)%
   

The character's experience points.
If a subfield is provided, the value is added to the current experience.
Currently the limit is set to 1000 exp. Do not abuse this feature!

%char.eq(<position>)%
%char.eq(*)%
   

An object variable for the object equipped inposition, if any.
The specified position may be either a position number (0-17) or the name of the location:
light, rfinger, lfinger, neck1, neck2, body, head, legs, feet, hands, arms, shield, about, waist, rwrist, lwrist, wield, hold
When called with * as subfield, it will return whether or not the character is wearing anything at all.

%char.fighting%
   

A variable for the target this character is currently fighting, or an empty return.

%char.follower%
   

A variable for the first character following this character, or an empty return.

%char.gold%
%char.gold(<amount>)%
   

The amount of gold on the character.
If a subfield is used, the amount is added to the current gold amount.
Do not abuse this feature!

%char.has_item(<object variable>)%
%char.has_item(<object vnum>)%
%char.has_item(<object name>)%
   

True if character has an object with the correct characteristics.

%char.hisher%
   

"his", "her" or "its", depending on the gender of the character.

%char.heshe%
   

"he", "she" or "it", depending on the gender of the character.

%char.himher%
   

"him", "her" or "it", depending on the gender of the character.

%char.id%
   

The unique id of the character.
This is mostly an internal value, but can be useful when you want a unique identifier.

%char.int%
%char.int(<value>)%
   

The character's intelligence.
If a subfield is provided, it will be added to the current stat.

%char.inventory%
%char.inventory(<object vnum>)%
   

An object variable pointing to the first object in the inventory, or if a subfield is given, the first item with the correct vnum.
If such an item cannot be found, the reutrn is empty.

%char.is_killer%
%char.is_killer( on | off )%
   

The player killer status of the character.
The subfield sets or removes the flag.

%char.is_thief%
%char.is_thief( on | off )%
   

The player thief status of the character.
The subfield sets or removes the flag.

%char.is_pc%
   

True if the character is a player.
This is the new and official way to check this.

%char.level%
   

The character's current level.

%char.hitp%
%char.hitp(<value>)%
   

The current hit points of the character.
If a value is given, it will be added to the current stat.

%char.mana%
%char.mana(<value>)%
   

The current mana points of the character.
If a value is given, it will be added to the current stat.

%char.move%
%char.move(<value>)%
   

The movement points of the character.
If a value is given, it will be added to the current stat.

%char.master%
   

A variable for the master of the character, or an empty return.
The master is the person the character is currently following.

%char.maxhitp%
%char.maxhitp(<value>)%
   

The maximum hit points of the character.
If a value is given, it will be added to the current stat.

%char.maxmana%
%char.maxmana(<value>)%
   

The maximum mana points of the character.
If a value is given, it will be added to the current stat.

%char.maxmove%
%char.maxmove(<value>)%
   

The maximum movement points of the character.
If a value is given, it will be added to the current stat.

%char.name%
   

The character's name (the short description for mobs).

%char.next_in_room%
   

A variable for the next person in the room.
An empty return if this character is the last in the room.

%char.pos%
%char.pos(<position>)%
   

The current position of the character.
If a subfield is provided, the characters position is changed.
Allows Sleeping, Resting, Sitting, Fighting, Standing
Thx to Christian Ejlertsen for this contribution.

%char.prac%
%char.prac(<value>)%
   

The number of practice sessions available to the character.
If a subfield is provided, it is added to the current amount.

%char.race%
   

The character's race, as a string.

%char.room%
   

A room variable for the room the character is in.
Older versions returned a room vnum here.

%char.sex%
   

The character's sex, as a string (MALE, FEMALE, or NEUTRAL).

%char.skill(<skillname>)%
   

The percentage of learnedness in the named skill.

%char.skillset("<skill>" <value>)%
   

Set the character's learnedness of skill <skill> to <value>.
This variable has no return value.
Example: %char.skillset("magic missile" 65)%

%char.str%
%char.str(<value>)%
   

The character's strength.
If a subfield is provided, the value is added to the current stat.

%char.stradd%
%char.stradd(<value>)%
   

The character's strength addition (if str is 18).
If a subfield is provided, the value is added to the current stat.

%char.saving_para%
%char.saving_para(<value>)%
   

The characters saving throw vs. paralysis.
If a subfield is provided, the value is added to the current stat.

%char.saving_rod%
%char.saving_rod(<value>)%
   

The characters saving throw vs. rods and staves.
If a subfield is provided, the value is added to the current stat.

%char.saving_petri%
%char.saving_petri(<value>)%
   

The characters saving throw vs. petrification.
If a subfield is provided, the value is added to the current stat.

%char.saving_breath%
%char.saving_breath(<value>)%
   

The characters saving throw vs. breath weapons.
If a subfield is provided, the value is added to the current stat.

%char.saving_spell%
%char.saving_spell(<value>)%
   

The characters saving throw vs. spells.
If a subfield is provided, the value is added to the current stat.

%char.title%
%char.title(<value>)%
   

The character's title. This only makes sense for PCs.
If a subfield is provided, the title is set to this value.

%char.vnum%
%char.vnum(<value>)%
   

The character's virtual number. -1 for PCs.
The check for %actor.vnum% != -1 is deprecated. Use %actor.is_pc% instead.
If a subfield is given, it is the equivalent of
(%char.vnum% == <value>)

%char.varexists(<var>)%
   

True if:
1. %char% has a script attached, and
2. the global variable <var> exists.
Otherwise, false is returned.
This is highly useful when dealing with remote vars on players.

%char.weight%
   

The character's weight.

%char.wis%
%char.wis(<value>)%
   

The character's wisdom.
If a subfield is provided, it will be added to the current stat.

%char.<global>%
   

If the specified field is not a recognized one, the character's script global list is searched for a matching global name. If found, its value will be returned. This can is also used to get values of vars set on players;

if %actor.varexists(testvar)%
  set testvar %actor.testvar%
end
* and then later in the script write it back:
remote testvar %actor.id%

Offline Kvetch

  • Administrator
  • Hero Member
  • *****
  • Posts: 729
    • View Profile
    • Email
Re: Character Variables
« Reply #1 on: June 30, 2012, 09:47:15 pm »
please note, you can combine strings... for example:
an object
%self.carried_by%
This let's the trigger figure out who is carrying this object - good for using things like doing an echo around the player carrying the object.
%self.carried_by.name%
This will let you use the NAME of the person carrying the object in a script with that object.

I know people had told me I could do this before, but didn't 100% get it until the other day when I had to figure out how to get a name in a RANDOM script - which means there is no actor starting the script.  So, I thought I'd pass it on.