English Simple Pet system icon

24 comments
03.05.12 07:09:40 am
like 15 like it!
4 kb, 433 Downloads
Devil-Thanh
GAME BANNED
Offline Off
Hey all
I'm bored today so i made this lua.
This is the pet system by me, it's very simple but fun, i think
Your Pet can attack enemy and kill them
You can up dmg and accuracy of you Pet(Pet can attack miss)
On/Off your Pet

√ Use and edit
× upload again and say it yours

I think the images is too bad

but have fun!
(i'm bad at English)
imageimageimageimage
ok This file has been reviewed and approved by Sparty (02.07.16 03:06:28 pm)

Comments

24 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
23.07.13 10:18:44 am
like I like it!
Up
Junior3534
User
Offline Off
I think its good and work but when i turn on my pet,he dont follow me ???

HELP PLEASE ! Thanks
04.07.12 07:12:48 pm
Up
omg
User
Offline Off
there were so many errors/bugs/bad code when i first ran it that it was utterly useless. i then proceeded to spend a big ass amount of time trying to fix everything in order to get it working in my server...i spent so much time trying to fix it/optimize it/read ur code that i might as well have just written the whole thing by myself

anyway, heres my fixed version because i think its a good code idea (it now has no bugs):
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
function initArray2(f,v)
     local cmd={}
     for c=1,f do
          cmd[c]=v
     end
     return cmd
end

config = {
     startdmg = 1,          --This is the first dmg of Pet
     startaccuracy = 1,          --This is the first accuracy point of pet (it >0) 
     updmgcost = 1,          --Up Pet's dmg price
     addeddmg = 1,          --This dmg will be added to Pet's dmg in one up
     upaccuracycost = 1,     --Up Pet's accuracy price
     addedaccuracy = 1,     --This point will be added to Pet's accuracy in one up
     --added stuff
     startrange=80,--in pixels, i guess. it gets used in distance formula calculation. for reference: 32 pixels is 1 tile length
     uprangecost=1,
     addedrange=1
}
sa=3--the serveraction for menu (1=f2,2=f3,3=f4)
Con = {lvl = 0,x = 0,y = 0,rot = 0,tg = 0,dmg = 0, accuracy = 0,exist = 0,range = 0}
Pet = initArray2(32,Con)
petimages={}
timer(10000,"fillimages")
function fillimages()
     for i=1,32 do
          petimages[i]=image("gfx/pet.bmp",0,0,1)
     end
end

addhook('join','join')
function join(id)
     Pet[id]={lvl = 1,x = 0,y = 0, rot = 0, tg = 0, dmg = config.startdmg, accuracy = config.startaccuracy,exist = 0,range=config.startrange}
end

addhook("leave","existomatic")
function existomatic(id)
     Pet[id].exist=0
     Pet[id].x=0
     Pet[id].y=0
     Pet[id].tg=0
     imagepos(petimages[id],0,0,0)
end

addhook('serveraction','sv_act')
function sv_act(id,act)
     if act==sa then
          minimenu(id)
     end
end

function minimenu(id)
     local ex=""
     if Pet[id].exist==1 then ex="Off" else ex="On" end
     menu(id,"Pet Menu,Pet "..ex..",Pet information,Up "..config.addeddmg.." Dmg|"..config.updmgcost..",Up "..config.addedaccuracy.." Accuracy|"..config.upaccuracycost..",Up 10 Range|2012")
end

addhook('menu','mn')
function mn(id,t,b)
     if t=="Pet Menu" then
          if b==1 then
               if Pet[id].exist==0 then
                    Pet[id].exist=1
                    imagepos(petimages[id],player(id,"x"),player(id,"y"),0)
               else
                    Pet[id].exist=0
                    Pet[id].x=0
                    Pet[id].y=0
                    Pet[id].tg=0
                    imagepos(petimages[id],0,0,0)
               end
          elseif b==2 then
               local ex=""
               if Pet[id].exist==1 then ex="Yes" else ex="No" end 
               menu(id,"Pet Infomation,Dmg|"..Pet[id].dmg..",Accuracy|"..Pet[id].accuracy..",Exists|"..ex..",Range|"..Pet[id].range.."")
          elseif b==3 then
               if player(id,'money')>=config.updmgcost then
                    Pet[id].dmg=Pet[id].dmg + config.addeddmg
                    parse("setmoney "..id.." "..player(id,'money')-config.updmgcost)
                    minimenu(id)
                    msg2(id,"©000255000Successful!@C")
               else
                    msg2(id,"©255000000Dont have enough money!@C")
               end
          elseif b==4 then
               if player(id,'money')>=config.upaccuracycost then
                    Pet[id].accuracy=Pet[id].accuracy + config.addedaccuracy
                    parse("setmoney "..id.." "..player(id,'money')-config.upaccuracycost)
                    minimenu(id)
                    msg2(id,"©000255000Successful!@C")
               else
                    msg2(id,"©255000000Dont have enough money!@C")
               end
          elseif b==5 then
               if player(id,'money')>=config.uprangecost then
                    Pet[id].range=Pet[id].range+config.addedrange
                    parse("setmoney "..id.." "..player(id,"money")-config.uprangecost)
                    minimenu(id)
                    msg2(id,"©000255000Successful!@C")
               else
                    msg2(id,"©255000000Dont have enough money!@C")
               end
          end
     end
end

function checkfreeline(x1, y1, x2, y2)
     local len = math.floor(math.sqrt((x1 - x2)^2 + (y1 - y2)^2))
     local c=-math.deg(math.atan2(x1 - x2, y1 - y2))
     local d=math.sin(math.rad(c))
     local e=-math.cos(math.rad(c))
     for k = 0,len,16 do--this can be readjusted for accuracy or performance; make 16 larger for performance, closer to 1 for accuracy. 16 is just my recommended optimization
          if tile(math.floor((x1+d*k)/32),math.floor((y1+e*k)/32),"wall") then
               return false
          end
     end
     return true
end

addhook('second','sec')
function sec()
     local tblL=player(0,"tableliving")
     for _,id in ipairs(tblL) do
          if Pet[id].exist==1 then
               Pet[id].tg = 0
               for _,i in ipairs(tblL) do
                    if player(i,'team')~= player(id,'team') then
                         if checkfreeline(Pet[id].x , Pet[id].y , player(i,'x') , player(i,'y')) then
                              local cls = math.sqrt((Pet[id].x - player(i,'x'))^2 + (Pet[id].y - player(i, 'y'))^2)
                              if cls<Pet[id].range then
                                   Pet[id].tg = i
                                   fire(id)
                                   return
                              else
                                   Pet[id].tg = 0
                              end
                         end
                    end
               end
               Pet[id].x = player(id,'x')
               Pet[id].y = player(id,'y')
               tween_move(petimages[id],1000,Pet[id].x,Pet[id].y)
          end
     end
end

function fire(id)
     local img=image("gfx/petfire.bmp",0,0,1)
     rot = -math.deg(math.atan2(Pet[id].x - player(Pet[id].tg, 'x'), Pet[id].y - player(Pet[id].tg, 'y'))) 
     imagepos(img,Pet[id].x,Pet[id].y,rot)
     tween_move(img,200, player(Pet[id].tg,'x') , player(Pet[id].tg,'y'))
     timer(200,"freeimage",img)
     if math.random(0,Pet[id].accuracy)~=0 then
          if player(Pet[id].tg,'health')>Pet[id].dmg then
               timer(200,"parse","sethealth "..Pet[id].tg.." "..player(Pet[id].tg,'health')-Pet[id].dmg)
               timer(200,"parse","explosion "..player(Pet[id].tg,"x").." "..player(Pet[id].tg,"y").." "..(Pet[id].dmg*4+32).." 1 "..id)
          else
               timer(200,"parse","customkill "..id.." \"Uber Missile\" "..Pet[id].tg)
          end
          Pet[id].tg = 0
     end
end
edited 3×, last 05.07.12 04:20:26 am
30.06.12 10:25:49 pm
like I like it!
Up
Xcover
User
Offline Off
How to turn pet menu?
19.05.12 03:24:50 pm
like I like it!
Up
DarkEvilz
User
Offline Off
my game crash when i turn on pet
14.05.12 01:38:10 pm
like I like it!
Up
Misho
User
Offline Off
user mafia_man can you stop acting like a dumbass?
06.05.12 09:03:40 pm
Up
mafia_man
User
Offline Off
I'm bored today so i don't like it.
× Bad description
× Ugly gfx
× Brainfuck script
06.05.12 04:22:12 pm
like I like it!
Up
Xirot
User
Offline Off
@user Guitorres - trz: I agree with you
06.05.12 03:45:28 pm
like I like it!
Up
4Vendetta
User
Offline Off
Why not pets like robots?
IMG:http://img607.imageshack.us/img607/2774/petjc.png
Somethinks like this, with customizable weapons and shields?
05.05.12 07:38:11 am
Up
DevGru
User
Offline Off
@user Guitorres - trz: Skin? do you mean script?
05.05.12 07:04:42 am
like I like it!
Up
luugiadat1997
User
Offline Off
it good
05.05.12 06:51:09 am
like I like it!
Up
Misho
User
Offline Off
user Guitorres - trz tottaly agree with you.
user Devil-Thanh you had to ask some one to make you better sprites. lol
05.05.12 12:00:02 am
like I like it!
Up
Guitorres - trz
User
Offline Off
nice skin, but you realy fail in the GFX
04.05.12 04:39:52 pm
like I like it!
Up
Misho
User
Offline Off
I've tested it out.
And it's cool, nice idea.
But make it BIGGER with more functions.
03.05.12 09:48:58 pm
like I like it!
Up
4Vendetta
User
Offline Off
Nice I've tested it and looks nice, I thinks later you'll upgrade this lua, or not? So you've potential nice
03.05.12 07:27:00 pm
like I like it!
Up
Shawni
User
Offline Off
Idea is stealed, i already made a script like this

But nice work.
03.05.12 04:28:18 pm
like I like it!
Up
Sniper_x
User
Offline Off
Nice Lua!
03.05.12 03:17:43 pm
Up
Devil-Thanh
GAME BANNED
Offline Off
@user SkullzOrig: ideas exists in life. many ways to get idea
edited 2×, last 29.06.12 06:28:48 am
03.05.12 02:16:10 pm
Up
BaDgEr
User
Offline Off
When my pet has small hp, can I take it to vet?
03.05.12 01:59:44 pm
Up
SkullzOrig
User
Offline Off
Sooo... Are we gonna copy ideas from World Of Warcraft?(WoW)
03.05.12 01:44:18 pm
like I like it!
Up
KiRa_3
User
Offline Off
Nice
I will edit this and will not upload this
To the start Previous 1 2 Next To the start