Debian Codegraph @

python/misc/reputation_trigger_connect.py

raw
1 """
2 reputation_trigger_connect.py -- trigger connections based on reputation
3
4 Use in a check_inv trigger with a event_trigger.
5
6 Arguments:
7 faction - name of faction to check against
8 threshold - number between -100 and 100
9 conn_geq - connection to trigger if reputation greater or equal than thresh
10 conn_lt - connection to trigger if reputation less than thresh
11
12 If any connection is 0, the connection will not be used.
13 """
14
15 import CFReputation
16 import Crossfire
17
18 def check():
19 player = Crossfire.WhoIsActivator()
20 if player.Type != Crossfire.Type.PLAYER:
21 return
22 params = Crossfire.ScriptParameters()
23 args = params.split()
24 faction = args[0]
25 thresh = int(args[1])
26 conn_geq = int(args[2])
27 conn_lt = int(args[3])
28
29 rep = CFReputation.reputation(player.Name, faction)
30 if len(rep) > 0:
31 if rep[0][1] >= thresh:
32 if conn_geq != 0:
33 player.Map.TriggerConnected(conn_geq, 1, player)
34 elif conn_lt != 0:
35 player.Map.TriggerConnected(conn_lt, 1, player)
36
37 check()