source: abuse/trunk/data/lisp/input.lsp @ 651

Last change on this file since 651 was 594, checked in by Sam Hocevar, 12 years ago

data: merge abuse.lsp from all Abuse versions.

File size: 5.6 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3;;(setf player1 'joystick)
4
5
6;; note : this function is called by the game when it collects input from
7;; the local player (the machine you are playing on in net games)
8;; because it is only executed locally it should not change any global varible
9;; Also the rest of the game should not use any input gathering routines such as
10;; joy_stat & key_presed.
11
12;;  The returned input from this routine is passed on to the server where it is
13;; distributed to other clients.
14;; The format for return is '(xv yv B1 B2 B3 mx my)
15
16;; xv = movement left right (-1=left, 0=none, 1=right)
17;; yv = movement up and down (-1=up,  0=none, 1=right)
18;; B1 = using special power (T or nil)
19;; B2 = firing button (T or nil)
20;; B3 = toggle to weapons (-1 toggle weapons to the left, 0=no toggle, 1 toggle to the right)
21;; mx = mouse x position on the screen
22;; my = mouse y position on the screen
23
24;; other possible key names for get_key_code include :
25;;   "Up_Arrow","Down_Arrow","Left_Arrow","Right_Arrow",
26;;   "Left_Ctrl","Right_Ctrl","Left_Alt","Right_Alt",
27;;   "Left_Shift","Right_Shift","Caps_Lock","Num_Lock",
28;;   "Home","End","Del","F1","F2","F3","F4","F5","F6",
29;;   "F7","F8","F9","F10","Insert"
30;;   "a", "b", "c", ...
31;; though not all of these keys will work on all operating systems
32
33
34;; note : at this current time weapon toggle input is ignored and
35;; CTRL & INS are used... sorry :)  These have to be event based,
36;; not polled so no key pressed are missed.
37
38(setq left-key          (get_key_code "left_arrow"))
39(setq right-key         (get_key_code "right_arrow"))
40(setq up-key            (get_key_code "up_arrow"))
41(setq down-key          (get_key_code "down_arrow"))
42(setq weapon-left-key   (get_key_code "right_ctrl"))
43(setq weapon-right-key  (get_key_code "insert"))
44
45(setq key-shiftr        (get_key_code "right_shift"))
46(setq key-end           (get_key_code "end"))
47
48(setq key-a  (get_key_code "a"))
49(setq key-b  (get_key_code "b"))
50(setq key-c  (get_key_code "c"))
51(setq key-d  (get_key_code "d"))
52(setq key-e  (get_key_code "e"))
53(setq key-f  (get_key_code "f"))
54(setq key-g  (get_key_code "g"))
55(setq key-h  (get_key_code "h"))
56(setq key-i  (get_key_code "i"))
57(setq key-j  (get_key_code "j"))
58(setq key-k  (get_key_code "k"))
59(setq key-l  (get_key_code "l"))
60(setq key-m  (get_key_code "m"))
61(setq key-n  (get_key_code "n"))
62(setq key-o  (get_key_code "o"))
63(setq key-p  (get_key_code "p"))
64(setq key-q  (get_key_code "q"))
65(setq key-r  (get_key_code "r"))
66(setq key-s  (get_key_code "s"))
67(setq key-t  (get_key_code "t"))
68(setq key-u  (get_key_code "u"))
69(setq key-v  (get_key_code "v"))
70(setq key-w  (get_key_code "w"))
71(setq key-x  (get_key_code "x"))
72(setq key-y  (get_key_code "y"))
73(setq key-z  (get_key_code "z"))
74
75(setq dray_has_fired 1)
76(setq godmode 0)
77(setq enemytarget 0)
78(setq noclip 0)
79
80(defun get_local_input ()
81  ;; fRaBs Twist extension input logic
82  (if (eq godmode 1)
83      (progn
84        (with_object (bg) (set_hp 100))
85        (if (or (eq (with_object (bg) (state)) flinch_up)
86                (eq (with_object (bg) (state)) flinch_down))
87            (with_object (bg) (set_state stopped)))))
88  (if (eq noclip 1)
89      (progn
90        (with_object (bg) (set_gravity 0))
91        (if (local_key_pressed up-key)
92            (with_object (bg) (set_y (- (y) run_top_speed))))
93        (if (local_key_pressed down-key)
94            (with_object (bg) (set_y (+ (y) run_top_speed))))
95        (if (local_key_pressed left-key)
96            (with_object (bg) (set_x (- (x) run_top_speed))))
97        (if (local_key_pressed right-key)
98            (with_object (bg) (set_x (+ (x) run_top_speed))))
99        (with_object (bg) (set_gravity 0))))
100  (if (and (eq (mod (game_tick) 15) 0)
101           (eq dray_has_fired 1))
102      (setq dray_has_fired 0))
103  (if (local_key_pressed key-shiftr)
104      (save_game (concatenate 'string "save"
105                              (digstr (get_save_slot) 4) ".spe")))
106  (if (and (eq (third (mouse_stat)) 1)
107           (with_object (bg) (eq (current_weapon_type) 7)))
108      (if (and (eq dray_has_fired 0)
109               (<= (ammo_total 7) 1)
110               (not (or (<= (with_object (bg) (hp)) 0)
111                        (eq (with_object (bg) (state)) dieing)
112                        (eq (with_object (bg) (state)) dead)
113                        (eq (with_object (bg) (state)) flinch_up)
114                        (eq (with_object (bg) (state)) flinch_down)
115                        (eq (with_object (bg) (state)) climbing)
116                        (eq (with_object (bg) (state)) climb_off)
117                        (eq (with_object (bg) (state)) climb_on))))
118          (progn
119            (setq dray_has_fired 1)
120            (play_sound DEATH_RAY_SND 127 (x) (y))
121            (with_object (bg) (add_object DEATH_RAY (x) (- (y)
122                                          (/ (picture_height) 2))))
123            (with_object (bg) (add_ammo 7 -1)))))
124  ;; Original Abuse logic
125  (let ((mstat (mouse_stat)))
126    (list (if (local_key_pressed left-key) -1
127              (if (local_key_pressed right-key) 1 0))  ;; xv
128          (if (local_key_pressed up-key) -1
129              (if (local_key_pressed down-key) 1 0))  ;; yv
130          (eq (fourth mstat) 1) ;; special button
131          (eq (third mstat) 1) ;; fire button
132
133          (if (or (eq (fifth mstat) 1)
134                  (local_key_pressed weapon-left-key)) -1 ;; weapon toggle
135              (if (local_key_pressed weapon-right-key) 1 0))
136          (first mstat) ;; mx
137          (second mstat) ;; my
138          )))
139
140;; XXX: Mac Abuse uses these hardcoded values
141;(setq up_key 256)
142;(setq left_key 258)
143;(setq right_key 259)
144;(setq down_key 257)
145;(setq special_key 32)
146;(setq weapon_left_key 49)
147;(setq weapon_right_key 50)
148
Note: See TracBrowser for help on using the repository browser.