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 | (if (eq godmode 1) (progn |
---|
82 | (with_object (bg) (set_hp 100)) |
---|
83 | (if (or (eq (with_object (bg) (state)) flinch_up)(eq (with_object (bg) (state)) flinch_down)) (with_object (bg) (set_state stopped))) |
---|
84 | )) |
---|
85 | (if (eq noclip 1) (progn |
---|
86 | (with_object (bg) (set_gravity 0)) |
---|
87 | (if (local_key_pressed up-key) (with_object (bg) (set_y (- (y) run_top_speed)))) |
---|
88 | (if (local_key_pressed down-key) (with_object (bg) (set_y (+ (y) run_top_speed)))) |
---|
89 | (if (local_key_pressed left-key) (with_object (bg) (set_x (- (x) run_top_speed)))) |
---|
90 | (if (local_key_pressed right-key) (with_object (bg) (set_x (+ (x) run_top_speed)))) |
---|
91 | (with_object (bg) (set_gravity 0)) |
---|
92 | )) |
---|
93 | (if (and (eq (mod (game_tick) 15) 0) (eq dray_has_fired 1) ) (setq dray_has_fired 0)) |
---|
94 | (if (local_key_pressed key-shiftr) (save_game (concatenate 'string "save" (digstr (get_save_slot) 4) ".spe"))) |
---|
95 | (if (and (eq (third (mouse_stat)) 1) (with_object (bg) (eq (current_weapon_type) 7)) ) |
---|
96 | (if (and (eq dray_has_fired 0) (<= (ammo_total 7) 1) (not (or (<= (with_object (bg) (hp)) 0) |
---|
97 | (eq (with_object (bg) (state)) dieing) |
---|
98 | (eq (with_object (bg) (state)) dead) |
---|
99 | (eq (with_object (bg) (state)) flinch_up) |
---|
100 | (eq (with_object (bg) (state)) flinch_down) |
---|
101 | (eq (with_object (bg) (state)) climbing) |
---|
102 | (eq (with_object (bg) (state)) climb_off) |
---|
103 | (eq (with_object (bg) (state)) climb_on) ))) |
---|
104 | (progn |
---|
105 | (setq dray_has_fired 1) |
---|
106 | (play_sound DEATH_RAY_SND 127 (x) (y)) |
---|
107 | (with_object (bg) (add_object DEATH_RAY (x) (- (y) (/(picture_height)2)) )) |
---|
108 | (with_object (bg) (add_ammo 7 -1)) |
---|
109 | ) |
---|
110 | )) |
---|
111 | |
---|
112 | (let ((mstat (mouse_stat))) |
---|
113 | (list (if (local_key_pressed left-key) -1 (if (local_key_pressed right-key) 1 0)) ;; xv |
---|
114 | (if (local_key_pressed up-key) -1 (if (local_key_pressed down-key) 1 0)) ;; yv |
---|
115 | (eq (fourth mstat) 1) ;; special button |
---|
116 | (eq (third mstat) 1) ;; fire button |
---|
117 | (if (or (eq (fifth mstat) 1) |
---|
118 | (local_key_pressed weapon-left-key)) -1 ;; weapon toggle |
---|
119 | (if (local_key_pressed weapon-right-key) 1 0)) |
---|
120 | (first mstat) ;; mx |
---|
121 | (second mstat) ;; my |
---|
122 | ))) |
---|
123 | |
---|