English Rocketmod icon

25 comments
10.06.10 11:27:29 am
like 17 like it!
11 kb, 512 Downloads
YellowBanana
BANNED
Offline Off
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.
imageimage
ok This file has been reviewed and approved by Fraizeraust (01.01.17 05:17:57 pm)

Comments

25 comments
Goto Page
To the start Previous 1 2 Next To the start

Log in!

You need to log in to be able to write comments!Log in
30.04.11 01:45:20 pm
Up
JONY
User
Offline Off
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 >
29.04.11 11:04:16 pm
Up
bestquit
User
Offline Off
bad script very bad stars:1 maximum 5
30.08.10 03:30:59 pm
like I like it!
Up
DeD_Ha_Ta6yPeTke
User
Offline Off
--[[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)
28.08.10 09:56:20 pm
like I like it!
Up
RyceR
User
Offline Off
@RedNarok Kamikaze is my mode
28.08.10 09:52:54 pm
like I like it!
Up
RadNarok
User
Offline Off
Nice Work Kamikaze XD.
12.08.10 12:17:05 am
Up
HaRe
User
Offline Off
Or another way just add it to the servertransfer.cfg in your sys folder
12.08.10 12:13:12 am
Up
YellowBanana
BANNED
Offline Off
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.
11.08.10 11:25:39 pm
like I like it!
Up
Delta
User
Offline Off
nice work
11.08.10 05:21:11 pm
like I like it!
Up
shokeh
User
Offline Off
This would be 5/5 but 1 problem

Other ppl dont see the rocket or the explosion they think I use admin powers. D=
20.06.10 08:40:49 pm
like I like it!
Up
GPolice
User
Offline Off
COOL VERY GOOOD!
19.06.10 07:52:50 am
like I like it!
Up
WarriorGirl90
User
Offline Off
cool!
13.06.10 12:10:49 pm
like I like it!
Up
Jake-rus
User
Offline Off
LOL
12.06.10 08:14:28 pm
like I like it!
Up
Banaan
User
Offline Off
great
12.06.10 03:10:50 pm
Up
JaKenMarX
COMMUNITY BANNED
Offline Off
nice script
11.06.10 09:38:50 pm
like I like it!
Up
DoP3
User
Offline Off
LOL epic mod.
11.06.10 02:52:06 pm
like I like it!
Up
Gucis
User
Offline Off
Nice
11.06.10 01:43:23 pm
Up
Sudden Death
User
Offline Off
~~O.O~~
11.06.10 12:25:13 pm
like I like it!
Up
RyceR
User
Offline Off
me too
11.06.10 06:05:45 am
like I like it!
Up
Mirash
User
Offline Off
YEAH! good script! Im like it! KABOOOOOM!
10.06.10 04:45:00 pm
like I like it!
Up
connor34
User
Offline Off
yes crazyx i am with you
To the start Previous 1 2 Next To the start