From 3f9e90d0754a5302a1f686af5c04f1a2267e345b Mon Sep 17 00:00:00 2001 From: ryo_saeba Date: Mon, 4 Jun 2007 18:38:35 +0000 Subject: [PATCH] Experience rewarder script. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@6415 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/items/experience_rewarder.py | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 python/items/experience_rewarder.py diff --git a/python/items/experience_rewarder.py b/python/items/experience_rewarder.py new file mode 100644 index 000000000..ed0b26d20 --- /dev/null +++ b/python/items/experience_rewarder.py @@ -0,0 +1,43 @@ +# Script to give experience to a player. +# +# Copyright 2007 Nicolas Weeger +# Released as GPL +# +# This script will give experience to the "activating" player. +# It should be linked through the "trigger" event of an altar, or similar thing. +# Options are specified in the event object's fields. +# A key/value will be used to store in the player if she activated the item already. +# +# Available options are: +# - exp: experience to gain +# - skill: skill to add experience to. Can be empty, in which case exp is given to the general exp only +# - wc: what to do when the player doesn't know the skill: +# - 0: give the player the skill +# - 1: give player exp to total, no skill +# - 2: player gets nothing +# - race: if set, the player can only use once this item. + +import Crossfire + +key_prefix = 'experience_rewarder_' + +def do_give_exp(): + pl = Crossfire.WhoIsActivator() + evt = Crossfire.WhatIsEvent() + + if evt.Race != None and evt.Race != '': + if pl.ReadKey(key_prefix + evt.Race) != '': + return + pl.WriteKey(key_prefix + evt.Race, 'used', 1) + + if evt.Skill == None or evt.Skill == '': + pl.AddExp(evt.Exp) + return + + wc = evt.WC + if wc < 0 or wc > 2: + wc = 1 + pl.AddExp(evt.Exp, evt.Skill, wc) + + +do_give_exp()