• Anmelden

duschkopf

Ankömmling

  • »duschkopf« ist der Autor dieses Themas

Motto: Das nennst du Frisur? Ich nenn das "Haare, die vor deinem Gesicht weglaufen".

  • Nachricht senden

1

Sonntag, 8. Februar 2009, 14:17

Mausskript.

Hallo, auf den Wunsch von Cow :D hab ich mal ne neue Skriptanfrage gestellt.
Also, es geht darum, das ich ein Mausskript suche.
Dieses Mausskript sollte aber so funktionieren, das ich, wenn ich spiele, einen NPC anklicke und der Spieler nicht mehr hinlaufen muss, sondern der NPC sofort loslegt.
Das heißt z.B. Der Spieler kommt in seine Wohung und klickt seine Mutter an, obwohl diese am anderen Ende der Map steht.
Ich hoffe, das ist möglich...
Wenn nicht, ist da sauch nicht so schlimm.
۞_۞
Bild

:verrückt: ich sitz zu viel vorm Computer! :verrückt:




2

Sonntag, 8. Februar 2009, 14:34

Ich glaube, dass kannst du sogar selbst erstellen ;)

Ich hab hier mein Lieblingsmausscript extra für dich:
Spoiler

Ruby Quellcode

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#==============================================================================
#
# Mouse Script 1.0                                  	created by: cybersam
#                                                   	edited by: MagicMagor
#
#==============================================================================
#
# (got rid of cybersams explanation here, because it isn't true for this module)
#                                                   	MagicMagor
#==============================================================================
 
#==============================================================================
# I have edited cybersams script, to fit my needs and my personal style of
# coding. I have also extended the script and got rid of several bugs. 
# If you use this, give credit to cybersam and me.
#------------------------------------------------------------------------------
# MagicMagor
#==============================================================================
 
module Mouse
 
  MOUSE_LEFT	= 0x01    	# left mouse button
  MOUSE_RIGHT   = 0x02    	# right mouse button
 
  attr_reader :MOUSE_LEFT, :MOUSE_RIGHT
 
  # Flags
 
  INIT_CURSOR = 0x01
  INIT_SAVE = 0x02
  INIT_TYPE = 0x03
  CURSOR_PIC = 0x01
  CURSOR_ROOT = 0x02
  CURSOR_BITMAP = 0x03
 
  attr_reader :INIT_CURSOR, :INIT_SAVE, :INIT_TYPE,
          	:CURSOR_PIC, :CURSOR_ROOT, :CURSOR_BITMAP
 
 
  @getCursorPos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  @getWindowRect = Win32API.new('user32', 'GetWindowRect', ['p', 'p'], 'i')
  @scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  @client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
  @readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  @findwindow = Win32API.new('user32', 'FindWindow', %w(p p), 'l')
  @getKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
 
  #---------------------------------------------------------------------------
  # Initialize the mouse-system, with given arguments. Is automaticly called
  # if needed.
  #---------------------------------------------------------------------------
  def Mouse.initSystem(*args)
	@init = true
	@handle = self.getHandle()
	@cursor = Sprite.new()
	if args.length >= 1
  	flags = args[0]
  	@showCursor  = (flags & INIT_CURSOR)
  	@saveToGame = (flags & INIT_SAVE)
  	withType = (flags & INIT_TYPE)
  	if (@showCursor != 0)
    	@showCursor = true
  	else
    	@showCursor = false
  	end
  	if (@saveToGame != 0)
    	@saveToGame = true
  	else
    	@saveToGame = false
  	end
  	@cursor.visible = @showCursor
  	@originX = 0
  	@originY = 0
  	if (@saveToGame)
    	@gameX = args[-2]
    	@gameY = args[-1]
  	end
  	if (@showCursor)
    	if (withType)
      	self.setCursor(args[1], args[2])
    	else
      	self.setCursor(args[1])
    	end
  	end
	end
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Checks if key was pressed.
  #---------------------------------------------------------------------------  
  def Mouse.pressed?(key)
   return ((@getKeyState.call(key) & 0x01) == 1)
  end
  def Mouse.click_area?(startx,endx,starty,endy)
	screenx = $game_variables[1]
	screeny = $game_variables[2]
	if screenx > startx and screenx < endx and screeny > starty and screeny < endy and Mouse.pressed?(Mouse::MOUSE_LEFT)
  	return true
	end
  end
  #---------------------------------------------------------------------------
  # Returns true if saving mouse positions to game-variables is enabled
  #---------------------------------------------------------------------------  
  def Mouse.saveToGame?()
	if !(@init)
  	self.initSystem(nil)
	end
	return @saveToGame
  end
 
  #---------------------------------------------------------------------------
  # Enables saving the mouse positions to game-variables
  #---------------------------------------------------------------------------  
  def Mouse.enableSaveToGame(game_x = nil, game_y = nil )
	if !(@init)
  	self.initSystem(nil)
	end
	@saveToGame = true
	if (game_x != nil)
  	@gameX = game_x
	end
	if (game_y != nil)
  	@gameY = game_y
	end
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Disables saving the mouse positions to game-variables
  #---------------------------------------------------------------------------  
  def Mouse.disableSaveToGame()
	if !(@init)
  	self.initSystem(nil)
	end
	@saveToGame = false
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Sets the variable-ID in which the X position is saved
  #---------------------------------------------------------------------------  
  def Mouse.setGameX(game_x)
	if !(@init)
  	self.initSystem(nil)
	end
	@gameX = game_x
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Sets the variable-ID in which the Y position is saved
  #---------------------------------------------------------------------------  
  def Mouse.setGameY(game_y)
   if !(@init)
  	self.initSystem(nil)
	end
   @gameY = game_y
   return nil
  end
 
  #---------------------------------------------------------------------------
  # Returns the variable-ID in which the X position is saved
  #---------------------------------------------------------------------------  
  def Mouse.gameX
	return @gameX
  end
 
  #---------------------------------------------------------------------------
  # Returns the variable-ID in which the Y position is saved
  #---------------------------------------------------------------------------  
  def Mouse.gameY
	return @gameY
  end
 
  #---------------------------------------------------------------------------
  # Returns X-Value of mouse positions
  #---------------------------------------------------------------------------	
  def Mouse.x()
	if !(@init)
  	self.initSystem(nil)
	end
	x, y = Mouse.mousePos()
	return x
  end
 
  #---------------------------------------------------------------------------
  # Returns Y-Value of mouse positions
  #---------------------------------------------------------------------------	
  def Mouse.y()
	if !(@init)
  	self.initSystem(nil)
	end
	x, y = Mouse.mousePos()
	return y
  end
 
  #---------------------------------------------------------------------------
  # Returns TRUE when the mouse-cursor is shown.
  #---------------------------------------------------------------------------	
  def Mouse.shown?()
	if !(@init)
  	self.initSystem(nil)
	end
	return @showCursor
  end
 
  #---------------------------------------------------------------------------
  # Enables showing of the mouse-cursor.
  #---------------------------------------------------------------------------	
  def Mouse.enableShow()
	if !(@init)
  	self.initSystem(nil)
	end
	@showCursor = true
	@cursor.visible = true
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Disable showing of the mouse-cursor.
  #---------------------------------------------------------------------------	
  def Mouse.disableShow()
	if !(@init)
  	self.initSystem(nil)
	end
	@showCursor = false
	@cursor.visible = false
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Sets a new bitmap for the cursor.
  #---------------------------------------------------------------------------	
  def Mouse.setCursor(filename, type = CURSOR_PIC, originX = 0, originY = 0)
	if !(@init)
  	self.initSystem(nil)
	end
	@originX = originX
	@originY = originY
	case type
	when CURSOR_PIC
  	@cursor.bitmap = RPG::Cache.picture(filename)
  	@cursor.z = 999	
  	return nil
	when CURSOR_ROOT
  	@cursor.bitmap = Bitmap.new(filename)
  	@cursor.z = 999
  	return nil
	when CURSOR_BITMAP
  	@cursor.bitmap = filename
  	@cursor.z = 999
  	return nil
	end
  end
 
  #---------------------------------------------------------------------------
  # Sets the x-coordinate of the cursor-picture origin.
  #---------------------------------------------------------------------------	
  def Mouse.setOriginX(originX)
	if !(@init)
  	self.initSystem(nil)
	end
	@originX = originX
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Sets the y-coordinate of the cursor-picture origin.
  #---------------------------------------------------------------------------	
  def Mouse.setOriginY(originY)
	if !(@init)
  	self.initSystem(nil)
	end
	@originY = originY
	return nil
  end
 
  #---------------------------------------------------------------------------
  # Updates the position of the mouse-cursor on screen.
  #---------------------------------------------------------------------------	
  def Mouse.update()
	if !(@init)
  	self.initSystem(nil)
	end
	if (@showCursor)
  	if Mouse.x() != nil
    	@cursor.x = Mouse.x() - @originX
  	end
  	if Mouse.y() != nil
    	@cursor.y = Mouse.y() - @originY
  	end
	end
	if ((@saveToGame) && (@gameX != nil) && (@gameY != nil))
  	$game_variables[@gameX] = Mouse.x()
  	$game_variables[@gameY] = Mouse.y()
	end
	return nil
  end
 
#===============================================================================  
# Private methods start here
# Do not call them directly.
# Edit them only if you know what you are doing.
#===============================================================================  
 
  #---------------------------------------------------------------------------
  # Calculates mouse position inside the programms window.
  #---------------------------------------------------------------------------  
  def Mouse.mousePos(catch_anywhere = false)
	x, y = Mouse.screenToClient(*Mouse.getPos)
	width, height = Mouse.clientSize()
	if ((x == nil) || (y == nil))
  	return nil
	end
	if ((catch_anywhere) || ((x >= 0) && (y >= 0) && (x < width) && (y < height)))
  	return x, y
	else
  	return nil
	end
  end
 
  #---------------------------------------------------------------------------
  # Gets mouse position from OS.
  #---------------------------------------------------------------------------  
  def Mouse.getPos()
	if !(@init)
  	Mouse.initSystem(nil)
	end
	pos = [0, 0].pack('ll')
	if @getCursorPos.call(pos) != 0
  	return pos.unpack('ll')
	else
  	return nil
	end
  end
 
  #---------------------------------------------------------------------------
  # Transforms screen-coordinates in client-coordinates.
  #---------------------------------------------------------------------------	
  def Mouse.screenToClient(x, y)
	if !(@init)
  	self.initSystem(nil)
	end
	return nil unless x and y
	pos = [x, y].pack('ll')
	if @scr2cli.call(@handle, pos) != 0
  	return pos.unpack('ll')
	else
  	return nil
	end
  end
 
 
  #---------------------------------------------------------------------------
  # Gets the client size from OS.
  #---------------------------------------------------------------------------	
  def Mouse.clientSize()
	if !(@init)
  	self.initSystem(nil)
	end
	rect = [0, 0, 0, 0].pack('l4')
	@client_rect.call(@handle, rect)
	right, bottom = rect.unpack('l4')[2..3]
	return right, bottom
  end
 
  #---------------------------------------------------------------------------
  # Gets the windows handle from OS.
  #---------------------------------------------------------------------------	
  def Mouse.getHandle()
	if !(@init)
  	self.initSystem(nil)
	end
	gameName = "\0" * 256
	@readini.call('Game', 'Title', '', gameName, 255, ".\\Game.ini")
	gameName.delete!("\0")
	if ($DEBUG)
  	# Only one RGSS Player should be open
  	result = @findwindow.call('RGSS Player', 0) 
	else
  	result = @findwindow.call('RGSS Player', gameName)
	end
	return result
  end
end
zum Lesen den Text mit der Maus markieren


Sobald du die Maus im Spiel haben willst, musst du per Callscript folgendes aufrufen:

Ruby Quellcode

1
2
Mouse.initSystem((Mouse::INIT_CURSOR | 
Mouse::INIT_SAVE), '', 1, 2)


Wenn du Maus-x und Maus-y in den Game-Variablen 1 und 2 speichern willst, musst du im Callscript folgendes einfügen:

Ruby Quellcode

1
Mouse.update()



Den Rest kannst du dir hoffentlich selber denken:
Beim entsprchenden Event Trigger auf ParallelProcess stellen und so vorgehen:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Callscript: Mouse.update()
@variable1 durch 32 teilen
@variable2 durch 32 teilen
@variable3 = This Event - ScreenX
@variable4 = This Event - ScreenY
@variable3 durch 32 teilen
@variable4 durch 32 teilen
@conditional branch: if @variable1 == @variable3
  @conditional branch: if @variable2 == @variable4
	@conditional brach: script: Mouse.pressed?(Mouse::MOUSE_LEFT)
  	# hier passiert etwas...
  	# ...
	-
  - 
-
Erase Event


Ich hoff du weißt, was ich meine...

cow
Spoiler: Sachen
zum Lesen den Text mit der Maus markieren

duschkopf

Ankömmling

  • »duschkopf« ist der Autor dieses Themas

Motto: Das nennst du Frisur? Ich nenn das "Haare, die vor deinem Gesicht weglaufen".

  • Nachricht senden

3

Sonntag, 8. Februar 2009, 15:45

sorry, aber ich kann kein RGSS.
aber ich probiers mal... :D
۞_۞
Bild

:verrückt: ich sitz zu viel vorm Computer! :verrückt:




Social Bookmarks