Dateien

> > CS2D > Lua Scripts > Rocketmod
DateiübersichtCS2D-ÜbersichtLua Scripts-Übersicht

Englisch Rocketmod >

25 Kommentare11 kb, 855 Downloads

alt Rocketmod

YellowBanana
BANNED Off Offline

After the fireballmod, I now present you the new and better rocketmod! I used a more OOP approach to script this time.

Includes:
>Multiple rockets for one person!
>Detonate at a distance
>Rockets cost money
>Easy to edit constants

Install:
> Extract everything in your cs2d folder

Usage:
> Press F2 to launch a rocket, press F3 to make it explode.
Zugelassen von GeoB99

Download Download

11 kb, 855 Downloads

Kommentare

25 Kommentare
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

Logge dich ein!

Du musst dich einloggen, um selber Kommentare verfassen zu können!Einloggen

alt

JONY
User Off Offline

I modified your code a little bit - now the rocket follows your cursor and rotates accordingly (although there's a small problem there). Explode with attack (left click). I hope you dont mind that i changed it. Copy this to rocketmod.lua:
Spoiler >

alt

bestquit
User Off Offline

bad script very bad stars:1 maximum 5

alt

DeD_Ha_Ta6yPeTke
User Off Offline

--[[Constants]]--

rpiconst = 180 / math.pi
imagepath = "sys/lua/rocketmod/Rocket.png" -- path to image
speed = 15 --speed of rocket
dmg = 100 --damage the rocket does
turnrate = 20 --@depricated turnrate of the rocket
tileconst =32 --width/height of tile
collisionradius = 200 -- the radius in which the rocket will do damage
money = 1000


--[[ Table setups! ]]--


ROCKETS = {} -- table to store all rockets
rocket = {}
rocket_mt = { __index = rocket}
rocketmod = {}

--[[ Hooks! ]]--

addhook("serveraction","rocketmod.serveraction")
function rocketmod.serveraction(id,action)
     if action == 1 then

          if(buyItem(id,money)) then
               local fb = rocket:new(player(id,"x"),player(id,"y"),toRad(player(id,"rot")),player(id,"rot"),id)
               table.insert(ROCKETS,fb)
               fb.id = #ROCKETS
               fb:draw() -- draw once to get an imageid
          end
     end

     if action == 2 then
          for _k,_v in ipairs(ROCKETS) do
               if(id == _v.pid) then
                    _v:explode()
                    break
               end
          end
     end
end

addhook("ms100","my_ms100")
function my_ms100()
     for i,v in ipairs(ROCKETS) do
          v:update()
     end
end


--[[

     Below here is the rocket class!

     ]]--


function rocket:new(x,y,dir,rot,playerid)
     return setmetatable({x=x,y=y,dir=dir,rot=rot,id = nil,imageid = nil,pid = playerid},rocket_mt)
end

function rocket:draw()
     self.imageid = image(imagepath,self.x,self.y,1)
     imagepos(self.imageid,self.x,self.y,self.rot)
     imagescale(self.imageid,0.6,0.6)
end

function rocket:explode()
     parse(string.format("%s %i %i %i %i %i","explosion",self.x,self.y,collisionradius,dmg,self.pid))
     self:destroy()
end

function rocket:update()
     self.y = self.y - (math.cos(self.dir)*speed)
     self.x = self.x + (math.sin(self.dir)*speed)

     --Player collision
     --[[for i,v in ipairs(player(0,"table")) do
          if(i ~= self.pid) then
               if(self:collision(i)) then
                    --parse("sethealth "..i.." "..(player(i,"health")-dmg))
                    parse("customkill "..self.pid.." rocketed "..i)
                    self:destroy()
               end
          end
     end --]]

     --Map boundaries collision
     if(self.x > (map("xsize")*tileconst) or self.x < 0 or self.y > (map("ysize")*tileconst) or self.y < 0) then
          self:destroy()
     else
          imagepos(self.imageid,self.x,self.y,self.rot)
     end
end

function rocket:destroy()
     freeimage(self.imageid)

     table.remove(ROCKETS,self.id)

     for i,m in ipairs(ROCKETS) do
          m.id = i
     end
end

function rocket:collision(playerid)
     if((self.x > player(playerid,"x") - collisionradius) and (self.x < player(playerid,"x") + collisionradius)) then
          if((self.y > player(playerid,"y") - collisionradius) and (self.y < player(playerid,"y") + collisionradius)) then
               return true
          end
     end
     return false
end

function rocket:turn(rate)
     self.dir = self.dir + toRad(rate)
     self.rot = self.rot + rate
end

--[[ Additional functions ]]--

function buyItem(id,price)
     cm = player(id,"money")
     if(cm>=price) then
          parse("setmoney "..id.." "..cm-price)
          return true
     else
          msg2(id,"©255000000 You have insufficient funds!")
          return false
     end
end


function toRad(deg)
     return (deg / rpiconst)
end
(xD)
Ich mag es!

alt

RyceR
User Off Offline

@RedNarok Kamikaze is my mode
Ich mag es!

alt

RadNarok
User Off Offline

Nice Work Kamikaze XD.
Ich mag es!

alt

HaRe
User Off Offline

Or another way just add it to the servertransfer.cfg in your sys folder

alt

YellowBanana
BANNED Off Offline

If other people want to see the Rocket, they must have the graphics installed! U can , for example, add it to your map so it will automaticalloy send to the player.

alt

Delta
User Off Offline

nice work
Ich mag es!

alt U made an oops D=

shokeh
User Off Offline

This would be 5/5 but 1 problem

Other ppl dont see the rocket or the explosion they think I use admin powers. D=
Ich mag es!

alt

Slater
User Off Offline

COOL VERY GOOOD!
Ich mag es!

alt

Jake-rus
User Off Offline

LOL
Ich mag es!

alt

Banaan
User Off Offline

great
Ich mag es!

alt

XiBaoZi
COMMUNITY BANNED Off Offline

nice script

alt

DoP3
User Off Offline

LOL epic mod.
Ich mag es!

alt

Gucis
User Off Offline

Nice
Ich mag es!

alt

RyceR
User Off Offline

me too
Ich mag es!

alt

Mirash
User Off Offline

YEAH! good script! Im like it! KABOOOOOM!
Ich mag es!

alt

connor34
User Off Offline

yes crazyx i am with you
Ich mag es!
Zum Anfang Vorherige 1 2 Nächste Zum Anfang