Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: tk on November 10, 2008, 04:17:33 pm

Title: Auto Aiming Missile 1.6
Post by: tk on November 10, 2008, 04:17:33 pm
Script Name: Auto Aiming Missile
Script Description: Creates a missile which chases a target.
Original Author(s): tk
Core Version: 2.6.3
Full Description:
Creates a flame missile which chases a given target. Missile is able to dodge near polys.
NOTE: Missile() must be threaded while calling it by AppOnIdle(), uses Sleep() function.

procedure Missile(owner_ID, target_ID: Byte; X, Y: Single);
Parameters: Owner's ID, target's ID, Position of start;




(http://img110.imageshack.us/img110/1/aam.png)




Quote
const
   rocketFuel = 45;   // default 45;
   accuracy = 40; //0 - the best accuracy, default 40;
   acceleration = 3; // default 3;
   flametraceMovement = 2; // default 2;

procedure nova(X,Y,dir_x,dir_y,r,speed,power: single; n: word; style, id: byte);
var
   angle,sine,cosine: single;
begin
   angle:=6.28318/n;
   for n:=n downto 1 do
   begin
      sine:=sin(angle*n);
      cosine:=cos(angle*n);
      CreateBullet(cosine*r + X, sine*r + Y,cosine*speed + dir_x,sine*speed + dir_y,power, style, ID);
   end;
end;

procedure Missile(owner_ID, target_ID: Byte; X, Y: Single);
{v. 1.6}
var
   poly_coll, target_coll: Boolean;
   n, interval: Word;
   X2, Y2, dist, next_dist_x, next_dist_y, prev_dist_x, prev_dist_y, rd: Single;
begin
   GetPlayerXY(target_ID,X2,Y2);
   dist:=Distance(X,Y,X2,Y2);
   next_dist_x:=(X2-X)/(dist/10);
   next_dist_y:=(Y2-Y)/(dist/10);
   X:=X + next_dist_x;
   Y:=Y + next_dist_y;
   prev_dist_x:=next_dist_x;
   prev_dist_y:=next_dist_y;
   interval:=40;
   while n < rocketFuel do
   begin
      Sleep(interval);
      next_dist_x:=((X2-X)/(dist/(20+accuracy*2))+prev_dist_x*accuracy) / (accuracy+1);
      next_dist_y:=((Y2-Y)/(dist/(24+accuracy*2))+prev_dist_y*accuracy) / (accuracy+1);
      prev_dist_x:=next_dist_x;
      prev_dist_y:=next_dist_y;
      X:=X + next_dist_x;
      Y:=Y + next_dist_y;
      GetPlayerXY(target_ID,X2,Y2);
      dist:=Distance(X,Y,X2,Y2);
      if dist > 80 then //poly dodging
      begin
         if not rayCast(X,Y,X+15,Y,rd,16) then X:=X - 15 else
            if not rayCast(X,Y,X-15,Y,rd,16) then X:=X + 15;
         if not rayCast(X,Y,X,Y+18,rd,19) then Y:=Y - 18 else
            if not rayCast(X,Y,X,Y-18,rd,19) then Y:=Y + 18;
      end;
      if dist < 25 then //check for collision
      begin
         target_coll:=true;
         break;
      end else
         if not RayCast(X,Y,X,Y,rd,1) then
         begin
            poly_coll:=true;
            break;
         end;
      if dist > 10*flametraceMovement then //create one flame
         CreateBullet(X, Y, next_dist_x/10*flametraceMovement, next_dist_y/10*flametraceMovement, 0, 5, owner_ID);
      if interval > 9 then   
         interval:=interval-acceleration; //acceleration
      n:=n+1;
   end;
   if target_coll then //collision with target
   begin
      DoDamageBy(target_ID, owner_ID, GetPlayerStat(target_ID, 'health')-1);
      nova(X,Y,next_dist_x/2,next_dist_y/2,20,5,2,7,14,owner_ID);
      nova(X2,Y2,0,0,30,8,2,9,14,owner_ID);
      nova(X2,Y2,0,0,12,-3,10,5,4,owner_ID);
   end else
      if poly_coll then   //collision with poly
      begin
         nova(X,Y,next_dist_x/2,next_dist_y/2,20,5,2,7,14,owner_ID);
         nova(X,Y,0,0,20,-3,10,4,4,owner_ID);
      end else
         begin //no fuel
            nova(X,Y,next_dist_x/3,next_dist_y/2,20,5,2,7,14,owner_ID);
            CreateBullet(X, Y, next_dist_x/2, next_dist_x/3, 10, 4, owner_ID);
         end;
end;


Title: Re: Auto Aiming Missile 1.0
Post by: BombSki on November 10, 2008, 04:22:05 pm
this is very cool, especially ingame.. its also really hard to dodge :)
its a pity that it uses the sleep function due to instability, but i hope it will be used in some scripts
Title: Re: Auto Aiming Missile 1.0
Post by: iDante on November 10, 2008, 04:34:19 pm
Hehe I made something very similar to this once.
What would be awesome would be mod-ing say, the law or something to shoot this kind of thing.
Title: Re: Auto Aiming Missile 1.0
Post by: Retro349 on November 10, 2008, 05:28:46 pm
This looks really cool!

Know any servers that use this, so I can try it out?
Title: Re: Auto Aiming Missile 1.0
Post by: Rampage_Terranius on November 11, 2008, 12:18:55 am
i had an idea to make something like this as a "special" weapon in a script im making atm it worked a little like this but was really unstable

any way gj and nice script
Title: Re: Auto Aiming Missile 1.0
Post by: Mr on November 11, 2008, 01:40:06 am
Awesome... looks really cool. Let's imagine... "CHEATER!111" xD
Title: Re: Auto Aiming Missile 1.0
Post by: Gizd on November 11, 2008, 04:15:42 am
This is awesome [retard]
I'm going to use it in my script.

[edit]
But i need to make it shorter.
Title: Re: Auto Aiming Missile 1.0
Post by: xmRipper on November 11, 2008, 08:38:54 am
omg really good job.
Title: Re: Auto Aiming Missile 1.0
Post by: Norbo on November 11, 2008, 10:49:25 am
this rocks
finally you got around releasing it tk, after months of hard work and problems (i know because I was brain storming with tk a bit)
Title: Re: Auto Aiming Missile 1.0
Post by: dragus on November 15, 2008, 06:56:18 am
what is commends in this scripts
Title: Re: Auto Aiming Missile 1.0
Post by: Toumaz on November 15, 2008, 07:19:40 am
what is commends in this scripts

Reading helps.

Full Description: In version for admin use the /mss command to launch the missile.
Title: Re: Auto Aiming Missile 1.0
Post by: DorkeyDear on November 15, 2008, 11:52:31 am
minor tip: "includes.txt" should be "Includes.txt" or it will not work on case-sensitive OSs.
and nice job; probably very difficult to perfect / improve such type things so, i do contratz you.. made me come up with a concept of how to make a path finder for Soldat :P
Title: Re: Auto Aiming Missile 1.0
Post by: shantec on November 16, 2008, 05:21:06 am
Damn i love this! Its really hard to dodge..
But only bad thing in this is the "poly dodgin"... with little bit of knowledge and time, it could be improved!
But overall very good!


Edit.
A turret that shoots these, once in 5 (?) seconds :D
Title: Re: Auto Aiming Missile 1.0
Post by: rayanaga on November 22, 2008, 02:52:37 am
Wow Dude.
This script is totally insane!!
Great job man!
Love it!
Title: Re: Auto Aiming Missile 1.0
Post by: LORD KILLA on December 06, 2008, 03:39:56 am
WOW!
Can u please make me a ready script of this ?
I tried to add Misslie.pas and the include line to scripts/default foldet but it dont work [if its possible, put it into core.pas]
If i made it wrong putting in default folder, please say me
Title: Re: Auto Aiming Missile 1.0
Post by: tk on December 06, 2008, 04:10:48 am
Don't put it into default. You have to put 'missile' folder attached in a zip into your 'scripts' folder.
Title: Re: Auto Aiming Missile 1.0
Post by: LORD KILLA on December 06, 2008, 04:16:04 am
where put Includes ?
And why as zip ?
Title: Re: Auto Aiming Missile 1.0
Post by: LORD KILLA on December 06, 2008, 04:26:35 am
 
  • ScriptCore v2.2 loaded! Found 1 scripts...
  • Compiling default -> Core.pas...
  • Compiling default -> NetworkCore.pas...
  • Compiling default -> AdminCore.pas...
  • Compilation Complete. [/tt]

    ->Thats what Console write
Title: Re: Auto Aiming Missile 1.0
Post by: LORD KILLA on December 06, 2008, 04:31:14 am
Hey i didnt see u are polish :)
anyway, can u integre it into a weapon, too [Barret- following bullet lol]
Title: Re: Auto Aiming Missile 1.0
Post by: tk on December 06, 2008, 04:40:40 am
http://forums.soldat.pl/index.php?topic=21468.0

Drag and drop "missile" folder from archive into your "scripts" folder located in soldatserver directory. You dont have to care about includes.txt. Just put WHOLE missile folder in your scripts folder.

I've made auto aiming law, maybe I'll post it when I fix some things.
Title: Re: Auto Aiming Missile 1.0
Post by: LORD KILLA on December 06, 2008, 05:36:35 am
thx works fine, /o\
Title: Re: Auto Aiming Missile 1.0
Post by: |_ancer on January 06, 2009, 12:18:26 am
Pwning bots with other scripts owns. Imagine real servers and the amount of power you would have.
Title: Re: Auto Aiming Missile 1.0
Post by: Eagle on January 11, 2009, 07:18:21 pm
Great script!  Really fun to harass zombies with...
Title: Re: Auto Aiming Missile 1.0
Post by: Shard on June 15, 2009, 05:08:52 am
Sorry for dragging up old topics but whats the command to fire the missile. I've looked and cant find it so dont tell me to go and read the post. Link is broken too...
Title: Re: Auto Aiming Missile 1.0
Post by: -Vis- on June 15, 2009, 05:18:01 am
what is commends in this scripts

Reading helps.

Full Description: In version for admin use the /mss command to launch the missile.

You really SHOULD try reading the posts once in a while, Shard. ::)
Title: Re: Auto Aiming Missile 1.0
Post by: tk on June 15, 2009, 06:21:05 am
Updated first post (http://forums.soldat.pl/index.php?topic=31034.msg368965#msg368965)
Rewrote the whole function, made it more readable, updated to work with 2.6.5 properly.

It's ready made function for scripters, and there's no version for admin anymore.
If it's really needed I'll write it later.
Title: Re: Auto Aiming Missile 1.6
Post by: Shard on June 15, 2009, 07:18:14 am
I must have just skipped over it lol. The download link wont work for me
Title: Re: Auto Aiming Missile 1.6
Post by: ~Niko~ on June 15, 2009, 11:12:13 am
I must have just skipped over it lol. The download link wont work for me
Maybe because THERE ISN'T...

Anyways here you go...
Title: Re: Auto Aiming Missile 1.0
Post by: demoniac93 on June 15, 2009, 03:15:23 pm
Hehe I made something very similar to this once.
What would be awesome would be mod-ing say, the law or something to shoot this kind of thing.

GROM (Missile launcher) anyone?
Love it!
Title: Re: Auto Aiming Missile 1.6
Post by: Centurion on June 15, 2009, 03:55:40 pm
Get a server running with that script and I will be living on that server 24/7
Title: Re: Auto Aiming Missile 1.6
Post by: Shard on June 16, 2009, 06:11:21 am
sweetness, thanks Niko(once again lol)
Title: Re: Auto Aiming Missile 1.6
Post by: scarface09 on June 17, 2009, 08:16:46 am
Very awesome script mate! Nice work, works great!
Title: Re: Auto Aiming Missile 1.6
Post by: freestyler on June 17, 2009, 02:01:14 pm
Hehe I made something very similar to this once.
What would be awesome would be mod-ing say, the law or something to shoot this kind of thing.

GROM (Missile launcher) anyone?
Love it!
It's scriptable. :) Would require you to change LAW to something that doesn't shoot at all (or shots very slow, non-damaging bullets), so it would be "blank" weapon. Then you should add something like this (pseudocode):
Code: [Select]
[inside apponidle]
  for i := 1 to 32 do if getplayerstat(i, 'active') then
    if (getplayerstat(i, 'primary') = 14) and (getkeypress(i, 'shoot')) // i'm not sure if LAW is #14
    and ((getkeypress(i, 'prone')) or (getkeypress(i, 'crouch'))) // players need to crouch to shoot, delete this line to allow shooting while standing
    then [shoot the missile]
It would need some reload restrictions, like setting the timer to 10 seconds after shooting or checking for LAW's reload.
Title: Re: Auto Aiming Missile 1.6
Post by: tk on June 17, 2009, 03:06:49 pm
I did it some time ago with modded law. Set flame as bullet style, low damage (like 5?), and speed 0.

inside OnPlayerDamage()
Code: [Select]
if victim = shooter then
  if GetPlayerStat(shooter,'Primary') = 16 then{ i think law is 16}
    if GetPlayerStat(shooter,'Ammo') = 0 then { player has shot }
      if (getkeypress(shooter, 'prone')) or (getkeypress(shooter, 'crouch') then begin
        target:=NearestTarget(...);
        if target = 0 then exit;
        Missile(shooter, target, GetPlayerStat(shooter,'x'), GetPlayerStat(shooter,'y'));
      // or the second possibility
        ThreadFunc([shooter, target, GetPlayerStat(shooter,'x'), GetPlayerStat(shooter,'y')],'Missile');
      end;

Missile can't be called from AppOnIdle() if it's not threaded. All things like GetTargetXY are refreshed in AppOnIdle() only once per second, coords of target don't change while flight of the missile, so it's not able to make curves.
Title: Re: Auto Aiming Missile 1.6
Post by: zop on June 20, 2009, 10:27:51 am
Very thanks.
This script works very beautiful.
Title: Re: Auto Aiming Missile 1.6
Post by: Silnikos on July 19, 2009, 05:51:42 am
Anyone got working launch command?
I tried with:
Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
begin
if GetPiece(Text,' ',0) = '/aim' then begin
Missile(
ID,
GetPlayerStat(strtoint(GetPiece(Text,' ',1)), 'ID'),
GetPlayerStat(strtoint(GetPiece(Text,' ',1)), 'X'),
GetPlayerStat(strtoint(GetPiece(Text,' ',1)), 'Y'),
);
end;
Result := false;
end;
But I keep on getting syntax errors...
Title: Re: Auto Aiming Missile 1.6
Post by: danmer on July 19, 2009, 11:21:20 am
GetPlayerStat(strtoint(GetPiece(Text,' ',1)), 'ID'),

...


you don't get the player's ID from the player... Just do strtoint(GetPiece(Text,' ',1))
Title: Re: Auto Aiming Missile 1.6
Post by: Xariki on October 18, 2009, 10:39:12 am
Hello,

im new to scripting, and Im starting new again (last time was 1 1/2 years ago)
so I kinda forgot everything >.>

I have used this script before (the 1.0 version) and it worked fine, you typed /mss and it shot a flaming missile at your nearest target. In 1.6 I type /mss and absolutely nothing happens. Help please?

(sorry for refreshing an old topic but I really need help on this one)
Title: Re: Auto Aiming Missile 1.6
Post by: Centurion on October 18, 2009, 12:05:13 pm
How can I test this script? I mean I don't have a server.
Title: Re: Auto Aiming Missile 1.6
Post by: tk on October 18, 2009, 02:46:57 pm
Server is only the way to test it.

Here is a simple launcher for those who would like to shoot missiles by using a command.
It finds the nearest target automatically. (command /aim)
Code: [Select]
function lookForTarget(ID: byte; MinDistance, MaxDistance: integer; UsingRaycast: boolean): byte;
var
   i,Team: byte; X,Y,X2,Y2,sqrdist,maxdist: single;
begin
   GetPlayerXY(ID,X,Y);
   maxdist:=MaxDistance*MaxDistance;
   Result:=0;
   Team := GetPlayerStat(ID, 'Team');
   for i:=1 to 32 do
      if i <> ID then
         if GetPlayerStat(i, 'Active') then
            if GetPlayerStat(i, 'Alive') then
               if GetPlayerStat(i, 'team') <> Team then
               begin
                  GetPlayerXY(i,X2,Y2);
                  if UsingRayCast then
                     if not RayCast(X,Y-7,X2,Y2-7,sqrdist,MaxDistance+1) then continue;
                  X2:=X2-X; Y2:=Y2-Y; sqrdist:=X2*X2+Y2*Y2;
                  if (sqrdist < maxdist) and (sqrdist >= MinDistance) then
                  begin
                     Result:=i;
                     maxdist:=sqrdist;
                  end;
               end;
end;


function OnCommand(ID: Byte; Text: string): boolean;
var x, y: single; target: byte;
begin
  if Text = '/aim' then begin
    target := lookForTarget(ID, 0, 700, true);
    if target > 0 then begin
      GetPlayerXY(ID, x, y);
      Missile(ID, target, x, y);
    end;
  end;
  Result := false;
end;
Title: Re: Auto Aiming Missile 1.6
Post by: xmRipper on October 18, 2009, 04:54:06 pm
How can I test this script? I mean I don't have a server.
You don't need rent a server. Just download the latest dedicated server from soldat.pl , then you can test.
Title: Re: Auto Aiming Missile 1.6
Post by: the halo fan on October 20, 2009, 02:36:05 pm
LOL, duds i'm new to scripts to and I still cann't use this. I put the missile folder in the script folder and went in the sever press /(as a command) then typed /aim shot my law and the missile from the law did NOTHING. Please help. :-\ BTW I'm testing it.
Title: Re: Auto Aiming Missile 1.6
Post by: heywood on October 20, 2009, 02:44:30 pm
the script doesnt work for me too somehow
i have tried the command /aim but nothing happend
Title: Re: Auto Aiming Missile 1.6
Post by: zop on October 20, 2009, 07:27:48 pm
the script doesnt work for me too somehow
i have tried the command /aim but nothing happend
Did you put an enemy bot for missile?
Title: Re: Auto Aiming Missile 1.6
Post by: the halo fan on October 21, 2009, 04:50:56 am
I'm going to answer that to. I put a bot in. Next.lol no rush.
Title: Re: Auto Aiming Missile 1.6
Post by: homerofgods on October 21, 2009, 08:25:34 am
LOL, duds i'm new to scripts to and I still cann't use this. I put the missile folder in the script folder and went in the sever press /(as a command) then typed /aim shot my law and the missile from the law did NOTHING. Please help. :-\ BTW I'm testing it.
have you enabled scripting?
Title: Re: Auto Aiming Missile 1.6
Post by: the halo fan on October 21, 2009, 01:46:22 pm
Uhhhhh...............lol i have no idea what you said or how to do it.
Title: Re: Auto Aiming Missile 1.6
Post by: Gizd on October 22, 2009, 08:36:02 am
server.ini
Title: Re: Auto Aiming Missile 1.6
Post by: the halo fan on October 23, 2009, 04:37:01 am
.......................... ???
I think i know were the sever.ini is but how to enable scripting?
Title: Re: Auto Aiming Missile 1.6
Post by: Toumaz on October 23, 2009, 04:58:50 am
set Scripting=1
Title: Re: Auto Aiming Missile 1.6
Post by: y0uRfath0r~ on March 20, 2011, 08:09:14 am
:3
Title: Re: Auto Aiming Missile 1.6
Post by: jrgp on March 20, 2011, 10:39:03 am
:3
Warned