File: reputation_trigger_connect.py

package info (click to toggle)
crossfire-maps 1.75.0%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 275,656 kB
  • sloc: python: 7,711; sql: 92; sh: 73; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
reputation_trigger_connect.py -- trigger connections based on reputation

Use in a check_inv trigger with a event_trigger.

Arguments:
    faction - name of faction to check against
    threshold - number between -100 and 100
    conn_geq - connection to trigger if reputation greater or equal than thresh
    conn_lt - connection to trigger if reputation less than thresh

If any connection is 0, the connection will not be used.
"""

import CFReputation
import Crossfire

def check():
    player = Crossfire.WhoIsActivator()
    if player.Type != Crossfire.Type.PLAYER:
        return
    params = Crossfire.ScriptParameters()
    args = params.split()
    faction = args[0]
    thresh = int(args[1])
    conn_geq = int(args[2])
    conn_lt = int(args[3])
    
    rep = CFReputation.reputation(player.Name, faction)
    if len(rep) > 0:
        if rep[0][1] >= thresh:
            if conn_geq != 0:
                player.Map.TriggerConnected(conn_geq, 1, player)
        elif conn_lt != 0:
            player.Map.TriggerConnected(conn_lt, 1, player)

check()