|
5 | 5 | launch |
6 | 6 | ====== |
7 | 7 | Activate with a cursor on screen and you will go there rapidly. Attack |
8 | | -something first to send them there. |
| 8 | +something first to ride them there. |
9 | 9 |
|
10 | 10 | ]====] |
11 | | -function launch(unitSource,unitTarget) |
12 | | - local curpos |
13 | | - if df.global.ui_advmode.menu == df.ui_advmode_menu.Look then |
14 | | - curpos = df.global.cursor |
15 | | - else |
16 | | - qerror("No [l] cursor located! You would have slammed into the ground and exploded.") --seriously, kasplut! |
17 | | - end |
| 11 | +function launch(unitSource,unitTarget,unitRider) |
| 12 | +local curpos |
| 13 | + if df.global.ui_advmode.menu == df.ui_advmode_menu.Look then |
| 14 | + curpos = df.global.cursor |
| 15 | + elseif df.global.gamemode == 1 then |
| 16 | + qerror("No [l] cursor located!You would have slammed into the ground and exploded.") |
| 17 | + else |
| 18 | + qerror("Must be used in adventurer mode or the arena!") |
| 19 | +end |
18 | 20 |
|
19 | 21 |
|
20 | | - local count=0 |
21 | | - local l = df.global.world.proj_list |
22 | | - local lastlist=l |
23 | | - l=l.next |
24 | | - while l do |
25 | | - count=count+1 |
| 22 | +local count=0 |
| 23 | +local l = df.global.world.proj_list |
| 24 | +local lastlist=l |
| 25 | +l=l.next |
| 26 | + while l do |
| 27 | + count=count+1 |
26 | 28 | if l.next==nil then |
27 | | - lastlist=l |
| 29 | + lastlist=l |
28 | 30 | end |
29 | 31 | l = l.next |
30 | | - end |
31 | | - |
32 | | - resultx = curpos.x - unitSource.pos.x |
33 | | - resulty = curpos.y - unitSource.pos.y |
34 | | - resultz = curpos.z - unitSource.pos.z |
35 | | - |
36 | | - |
37 | | - newlist = df.proj_list_link:new() |
38 | | - lastlist.next=newlist |
39 | | - newlist.prev=lastlist |
40 | | - proj = df.proj_unitst:new() |
41 | | - newlist.item=proj |
42 | | - proj.link=newlist |
43 | | - proj.id=df.global.proj_next_id |
44 | | - df.global.proj_next_id=df.global.proj_next_id+1 |
45 | | - proj.unit=unitSource |
46 | | - proj.origin_pos.x=unitSource.pos.x |
47 | | - proj.origin_pos.y=unitSource.pos.y |
48 | | - proj.origin_pos.z=unitSource.pos.z |
49 | | - proj.target_pos.x=curpos.x |
50 | | - proj.target_pos.y=curpos.y |
51 | | - proj.target_pos.z=curpos.z |
52 | | - proj.prev_pos.x=unitSource.pos.x |
53 | | - proj.prev_pos.y=unitSource.pos.y |
54 | | - proj.prev_pos.z=unitSource.pos.z |
55 | | - proj.cur_pos.x=unitSource.pos.x |
56 | | - proj.cur_pos.y=unitSource.pos.y |
57 | | - proj.cur_pos.z=unitSource.pos.z |
58 | | - proj.flags.no_impact_destroy=true |
59 | | - proj.flags.piercing=true |
60 | | - proj.flags.high_flying=true --this probably doesn't do anything, let me know if you figure out what it is |
61 | | - proj.flags.parabolic=true |
62 | | - proj.flags.no_collide=true |
63 | | - proj.flags.unk9=true |
64 | | - proj.speed_x=resultx*10000 |
65 | | - proj.speed_y=resulty*10000 |
66 | | - proj.speed_z=resultz*12500 --higher z speed makes it easier to reach a target safely |
67 | | - if df.global.world.units.active[0].job.hunt_target==nil then |
68 | | - proj.flags[12]=true |
69 | | - elseif df.global.world.units.active[0].job.hunt_target then |
70 | | - proj.flags[12]=false |
71 | | - end |
72 | | - unitoccupancy = dfhack.maps.ensureTileBlock(unitSource.pos).occupancy[unitSource.pos.x%16][unitSource.pos.y%16] |
73 | | - if not unitSource.flags1.on_ground then |
74 | | - unitoccupancy.unit = false |
75 | | - else |
76 | | - unitoccupancy.unit_grounded = false |
77 | | - end |
78 | | - unitSource.flags1.projectile=true |
79 | | - unitSource.flags1.on_ground=false |
80 | 32 | end |
81 | 33 |
|
82 | | -if not (dfhack.isMapLoaded() and dfhack.world.isAdventureMode()) then |
83 | | - qerror("This script can only be used in adventure mode.") |
| 34 | +resultx = curpos.x - unitSource.pos.x |
| 35 | +resulty = curpos.y - unitSource.pos.y |
| 36 | +resultz = curpos.z - unitSource.pos.z |
| 37 | + |
| 38 | +newlist = df.proj_list_link:new() |
| 39 | +lastlist.next=newlist |
| 40 | +newlist.prev=lastlist |
| 41 | +proj = df.proj_unitst:new() |
| 42 | +newlist.item=proj |
| 43 | +proj.link=newlist |
| 44 | +proj.id=df.global.proj_next_id |
| 45 | +df.global.proj_next_id=df.global.proj_next_id+1 |
| 46 | +proj.unit=unitSource |
| 47 | +proj.origin_pos.x=unitSource.pos.x |
| 48 | +proj.origin_pos.y=unitSource.pos.y |
| 49 | +proj.origin_pos.z=unitSource.pos.z |
| 50 | +proj.target_pos.x=curpos.x |
| 51 | +proj.target_pos.y=curpos.y |
| 52 | +proj.target_pos.z=curpos.z |
| 53 | +proj.prev_pos.x=unitSource.pos.x |
| 54 | +proj.prev_pos.y=unitSource.pos.y |
| 55 | +proj.prev_pos.z=unitSource.pos.z |
| 56 | +proj.cur_pos.x=unitSource.pos.x |
| 57 | +proj.cur_pos.y=unitSource.pos.y |
| 58 | +proj.cur_pos.z=unitSource.pos.z |
| 59 | +proj.flags.no_impact_destroy=true |
| 60 | +proj.flags.piercing=true |
| 61 | +proj.flags.high_flying=true --this probably doesn't do anything, let me know if you figure out what it is |
| 62 | +proj.flags.parabolic=true |
| 63 | +proj.flags.no_collide=true |
| 64 | +proj.flags.unk9=true |
| 65 | +proj.speed_x=resultx*10000 |
| 66 | +proj.speed_y=resulty*10000 |
| 67 | +proj.speed_z=resultz*15000 --higher z speed makes it easier to reach a target safely |
| 68 | + if df.global.world.units.active[0].job.hunt_target==nil then |
| 69 | + proj.flags.safe_landing=true |
| 70 | + elseif df.global.world.units.active[0].job.hunt_target then |
| 71 | + proj.flags.safe_landing=false |
| 72 | + end |
| 73 | +unitoccupancy = dfhack.maps.ensureTileBlock(unitSource.pos).occupancy[unitSource.pos.x%16][unitSource.pos.y%16] |
| 74 | + if not unitSource.flags1.on_ground then |
| 75 | + unitoccupancy.unit = false |
| 76 | + else |
| 77 | + unitoccupancy.unit_grounded = false |
| 78 | + end |
| 79 | + unitSource.flags1.projectile=true |
| 80 | + unitSource.flags1.on_ground=false |
84 | 81 | end |
85 | 82 |
|
86 | 83 | unitTarget = curpos |
87 | 84 | if df.global.world.units.active[0].job.hunt_target==nil then |
88 | | - unitSource = df.global.world.units.active[0] |
| 85 | + unitSource = df.global.world.units.active[0] |
89 | 86 | else |
90 | | - unitSource = df.global.world.units.active[0].job.hunt_target --kudos Rumrusher for including this, allowing you to fling others around! |
| 87 | + unitRider = df.global.world.units.active[0] |
| 88 | + unitSource = df.global.world.units.active[0].job.hunt_target |
| 89 | + unitSource.general_refs:insert("#",{new=df.general_ref_unit_riderst,unit_id=unitRider.id}) |
| 90 | + unitRider.relationship_ids.RiderMount=unitSource.id |
| 91 | + unitRider.flags1.rider=true |
| 92 | + unitSource.flags1.ridden=true |
| 93 | + require("utils").insert_sorted(df.global.world.units.other.ANY_RIDER,unitRider,"id") |
91 | 94 | end |
92 | 95 |
|
93 | | -launch(unitSource,unitTarget) |
| 96 | +launch(unitSource,unitTarget,unitRider) |
0 commit comments