Crossfire Server, Trunk
experience_rewarder.py
Go to the documentation of this file.
1 # Script to give experience to a player.
2 #
3 # Copyright 2007 Nicolas Weeger
4 # Released as GPL
5 #
6 # This script will give experience to the "activating" player.
7 # It should be linked through the "trigger" event of an altar, or similar thing.
8 # Options are specified in the event object's fields.
9 # A key/value will be used to store in the player if she activated the item already.
10 #
11 # Available options are:
12 # - exp: experience to gain
13 # - skill: skill to add experience to. Can be empty, in which case exp is given to the general exp only
14 # - wc: what to do when the player doesn't know the skill:
15 # - 0: give the player the skill
16 # - 1: give player exp to total, no skill
17 # - 2: player gets nothing
18 # - race: if set, the player can only use once this item.
19 
20 import Crossfire
21 
22 key_prefix = 'experience_rewarder_'
23 
25  pl = Crossfire.WhoIsActivator()
26  evt = Crossfire.WhatIsEvent()
27 
28  if evt.Race != None and evt.Race != '':
29  if pl.ReadKey(key_prefix + evt.Race) != '':
30  return
31  pl.WriteKey(key_prefix + evt.Race, 'used', 1)
32 
33  if evt.Skill == None or evt.Skill == '':
34  pl.AddExp(evt.Exp)
35  return
36 
37  wc = evt.WC
38  if wc < 0 or wc > 2:
39  wc = 1
40  pl.AddExp(evt.Exp, evt.Skill, wc)
41 
42 
experience_rewarder.do_give_exp
def do_give_exp()
Definition: experience_rewarder.py:24