source: abuse/branches/win32/Abuse32/LISP/CHAT.LSP @ 100

Last change on this file since 100 was 100, checked in by Sam Hocevar, 15 years ago
  • Importing an old Win32 port by Jeremy "Marauder" Scott.
File size: 2.4 KB
Line 
1(enable_chatting)
2
3(setq color_list '(
4        ("Brown" 0)
5        ("Blue" 1)
6        ("Yellow" 2)
7        ("Fire" 3)
8        ("Olive" 4)
9        ("Pink" 5)
10        ("Dark Blue" 6)
11        ("Grape" 7)
12        ("Africaan" 8)
13        ("Toxik" 9)
14))
15
16(setq Color_help '"Colors: Br, Bl, Ye, Fi, Ol, Pi, Da, Gr, Af, To")
17
18(setq team_list '(
19        ("Red" 0)
20        ("Blue" 1)
21        ("Green" 2)
22        ("Yellow" 3)
23))
24
25(setq team_color_list '(
26     (0 (("Fire" 3) ("Pink" 5) ("Africaan" 8)))
27         (1 (("Blue" 1) ("Grape" 7) ("Dark Blue" 6)))
28         (2 (("Olive" 4) ("Toxik" 9)))
29         (3 (("Yellow" 2) ("Brown" 0)))
30))
31
32(setq Team_help '"Teams: None, Red, Blue, Green, Yellow")
33
34(defun find_color (str colors)
35        (if (search str (car (car colors)))
36                (progn
37                        (chat_print (concatenate 'string "# " (player_name) " is now " (car (car colors))))
38                        (set_object_tint (car (cdr (car colors))))
39                )
40                (if (cdr colors)
41                        (find_color str (cdr colors))
42                        nil
43                )
44        )
45)
46
47(defun find_team (str team)
48        (if (search str (car (car team)))
49                (progn
50                        (chat_print (concatenate 'string "# " (player_name) " is now on " (car (car team))))
51                        (if (not (eq (get_object_team) (car (cdr (car team)))))
52                                (progn
53                                        (set_hp 0)
54                                        (create_dead_parts cop_dead_parts (* (get_dead_part (me)) 3) (get_object_tint))
55;                                       (set_kills (- (get_kills) 1))
56                                        (set_object_team (car (cdr (car team))))
57                                        (set_object_tint (car (cdr (car (car (cdr (nth (get_object_team) team_color_list)))))))
58                                )
59                        )
60                )
61                (if (cdr team)
62                        (find_team str (cdr team))
63                        nil
64                )
65        )
66)
67
68(defun chat_input (str)
69        (if (and (> (length str) 0) (equal (elt str 0) #\/))
70                (if (and (search "/nick " str) (> (length str) 6))
71                        (chat_print (concatenate 'string "# " (player_name) " is known as "
72                                (progn
73                                        (set_player_name (substr 6 (- (length str) 1) str))
74                    (player_name)
75                                )
76                        ))
77                        (if (and (local_player) (search "/help" str))
78                                (chat_print "Commands : /nick [name], /color, /team, /help")
79                                (if (search "/color" str)
80                                        (if (> (length str) 7)
81                                                (find_color (substr 7 (- (length str) 1) str) color_list)
82                                                (chat_print Color_help)
83                    )
84                                        (if (search "/team" str)
85                                                (if (> (length str) 6)
86                                                        (find_team (substr 6 (- (length str) 1) str) team_list)
87                                                        (chat_print Team_help)
88                                                )
89                                                (if (local_player)
90                                                        (chat_print (concatenate 'string "unknown command " str))
91                                                )
92                                        )
93                                )
94                        )
95                )
96                (chat_print (concatenate 'string "<" (player_name) "> " str))
97        )
98)
Note: See TracBrowser for help on using the repository browser.