| [GML] Projectile Launch Aiming Finder | |
|
2010-10-31, 20:33 | [GML] Projectile Launch Aiming Finder |
---|
bungatepijalan Moe Princess
Posts : 1487 Thanked : 30 Engine : Multi-Engine User Skill : Intermediate Type : Developer
Awards:
| - Overview:
Mau bikin game sejenis Gunbound yang pake AI? Pengen biar AI bisa nembak target dengan tepat? Ini dia algoritma AI-nya
Script: parabola - Code:
-
/* parabola: (x0,y0,x1,y1) -> (theta,v0)
Computes launch speed of the projectile (v0) with randomly given elevation angle (theta), for known the launcher coordinate (x0,y0) and the target coordinate (x1,y1); in case of no forces applied but the constant gravity. */ x0=argument0 y1=argument1 x1=argument2 y0=argument3 g=XXX //Replace with a reasonable value theta=pi/2-random(pi/2-arctan((y1-y0)/(x1-x0))) v0=(x1-x0)/cos(theta)*sqrt(.5*g/((x1-x0)*tan(theta)-(y1-y0)))
Script: parabola2 - Code:
-
/* parabola2: (x0,y0,x1,y1,ax,ay) -> (theta,v0)
Computes launch speed of the projectile (v0) with randomly given elevation angle (theta), for known the launcher coordinate (x0,y0), the target coordinate (x1,y1), and x-component and y-component of wind acceleration; in case of no another forces applied. */ x0=argument0 y1=argument1 x1=argument2 y0=argument3 ax=argument4 ay=argument5 g=XXX //Replace with a reasonable value do{ theta=random(pi/2) k=((y1-y0)/(x1-x0)-(ay-g)/ax)/(sin(theta)-(ay-g)/ax*cos(theta)) }until(ax*(x1-x0)/(1-k*cos(theta))>=0) v0=k*sqrt(.5*ax*(x1-x0)/(1-k*cos(theta))) Fungsi: menghitung laju luncur peluru (v0) dan sudut elevasi (theta) agar peluru dapat mengenai target dengan tepat
Deskripsi script: - parabola: menghitung laju luncur peluru (v0) dan sudut elevasi (theta), dalam kasus hanya gaya gravitasi yang bekerja pada peluru - parabola2: menghitung laju luncur peluru (v0) dan sudut elevasi (theta), dengan besar dan arah percepatan angin yang juga bekerja pada peluru, selain gaya gravitasi
Cara pemasangan: - Buat salah satu script baru: parabola atau parabola2 - Copas bagian code di atas ke masing2 script tersebut - Implementasikan script tersebut ke action Execute a piece of code pada Event saat peluru akan dibuat (diluncurkan). - Pada peluru yang diluncurkan, set speed=v0, direction=radtodeg(theta). Set gravity=g, jika menggunakan parabola (kasus tidak ada angin), atau set gravity=point_distance(0,0,ax,ay-g) dan gravity_direction=point_direction(0,0,ax,ay-g).
Created by: Bunga Tepi Jalan
|
| | |
| [GML] Projectile Launch Aiming Finder | |
|
Similar topics | |
|
Similar topics | |
|
|
Halaman 1 dari 1 |
|
|
Permissions in this forum: | Anda tidak dapat menjawab topik
| |
|
|
Latest 10 Topics | [Web Novel] Gloria Infidelis 2016-11-17, 21:27 by LightNightKnight
[Announcement] Forum baru untuk RMID 2016-08-25, 16:39 by TheoAllen
Where I'm Wrong ? 2016-07-24, 16:10 by ReydVires
flakeheartnet's Resources part III 2016-07-08, 14:30 by flakeheartnet
Keira's Art Warehouse 2016-06-28, 19:27 by KeiraBlaze
Theo Core Time System + Bingung 2016-06-27, 16:24 by Lockin
Error Script, Maybe ? 2016-06-27, 16:20 by Lockin
Nusaimoe @ RMID Lounge 2016-06-21, 05:02 by Jihad Bagas
Call Random Battle 2016-06-15, 17:04 by Lockin
Flakeheartnet Resources Part II [come back gift] 2016-06-07, 15:51 by flakeheartnet
|
Statistics
|
Members: [ 4947 ]
Topics: [ 8258 ]
Posts: [ 112606 ]
Newest member: [ https://rmid.forumotion.net/u4968 ]
|
|
|
|