• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[MiniGame] Plants VS Zombies

Strack

Member
Joined
May 15, 2009
Messages
199
Reaction score
14
aTaSZVE.png
At first, sorry if my english is not the best it could be...

Well, I made Plants Vs Zombies minigame some time ago, and now (finally) decided to post it.
For those who dont know what i'm talking about, see this video:

Description:
As some of you already now, 'Plants VS Zombies' is a game which came 'famous' some few ¿years? ago, and this system tries to adapt that game for
OTs.

Contains:
~ Lib
~ Action
~ Movement
~ Creaturescript
~ Npc
~ Monster
~ Map

Download Map:
Speedyshare: http://speedy*****malware.localhost/FMuDe/map.otbm
Mediafire: http://www.mediafire.com/download/jmsznn5icwy4e3x/map.otbm

Download Monsters (Zombies & Plants):
Speedyshare: http://speedy*****malware.localhost/E3Gg9/PvZ-monsters.rar

Scripts:
Speedyshare: http://speedy*****malware.localhost/W5GM6/PvZ-scripts.rar
(otland dont let me post the code because it exceeds the word limit)

Config:
Every basic configuration is made on lib file (positions, area, zombies, plants...)
If you dont know to script in LUA better avoid modifying anything else.

Configurable part is the one in lib between:
-- CONFIG PART and -- END OF CONFIG PART

And now in parts for a better understanding

Areas:

29FSVIk.jpg


The image corresponds to the first part of the configuration:

Code:
-- Area config --
local area = {x1 = 942, x2 = 950, y1 = 895, y2 = 900, z = 7} -- area of the game (where u will be able to plant)

local playerTp = {x=944,y=894,z=7} -- where player will be tp inside area

local zombieSpawnArea = {x = 951, y1 = 895, y2 = 900, z = 7} -- area where zombies will spawn

local plantsSpawnArea = {x1 = 942, x2 = 949, y1 = 893, y2 = 893, z = 7}
-- End Area config

I think the image is good enough to understand what each line means


Zombie Spawn:

Code:
local wavesSpawn = {
[1] = { -- wave number
{name="zombi",q=5} -- name of the zombies that will spawn and quantity
},
[2] = {
{name="zombi",q=5},
{name="zombi ghoul",q=3}
},
[3] = {
{name="zombi",q=5},
{name="zombi ghoul",q=3},
{name="zombi shambler",q=1}
},
[4] = {
{name="zombi",q=5},
{name="zombi ghoul",q=3},
{name="zombi shambler",q=2},
{name="zombi mummy",q=1}
},
[5] = {
{name="zombi",q=5},
{name="zombi ghoul",q=3},
{name="zombi shambler",q=2},
{name="zombi mummy",q=2},
{name="zombi ghost",q=2}
}
}

At this time, there are 5 elements on 'wavesSpawn', which means there are 5 zombie waves. If we add another element to the table means that ingame
will be another wave. To add a new one we must set index+1 (6 in this case), and put every zombie that will appear on this wave with its quantity.
i.e.:
Code:
[6] = {
-- name = name of monster
-- q = quantity of this monster that will be summoned for this wave
-- every added zombie must be between {}, as a new element in the table
{name="zombi",q=5},
{name="zombi ghoul",q=3},
{name="zombi mummy",q=2}
}


Constants (storages, itemIDs, etc...):

Code:
-- storages --
local selStr = 145788
local globalStr = 145789
local killstr = 145790
local waveqstr = 145791
local wavenstr = 145792
local playerName = 145793

-- items --
local item1 = 2557 -- id of the item used to plant or modify plants (modifierTool)
local item2 = 2554 -- id of the item used to erase (eraserTool)
local brainId = 5808 -- id of the item which is like a brain (just decoration)

local maxRange = 8 -- max range for plant attacks
local tiempo = 30 -- in seconds, time of "peace" between each wave
local initMoney = 50 -- starting money
local aid = 5005 -- action id, better if is the same actionID for the action and movement


Plants config:

Code:
local plants = {
['peashooter'] = { -- attacks in a straight line
price = 100, -- price to buy/plant the plant
atk = 1, -- dmg done to zombies per hit. If the plant gives energy instead of attacking, this value is the Q of money it will give per "attack"
def = 3, -- number of hits it will resist from zombies before disappearing
atkType = "normal", -- function's name which defines how this plant acts ingame. AtkType functions are defined in 'local atkFunctions'
chargeT = 1000, -- time before you can buy this plant again (not in use)
speed = 2000, -- time between attacks made by this plant
special = "nothing", -- for example, slowing or paralizing (not yet implemented)
atkEff = 20, -- effect when attack hits to zombie
distEff = 3 -- distance effect when plant attacks to a zombie
},
['sunflower'] = {price = 50, atk = 25, def = 3, atkType = "giveEnergy", chargeT = 1000, speed = 10*1000, special = "nothing", atkEff = 0, distEff = 0, evolution = "twin sunflower"}, -- gives energy/money
['cherry bomb'] = {price = 150, atk = 100, def = 1, atkType = "explode3x3", chargeT = 1000, speed = 1500, special = "nothing", atkEff = 246, distEff = 0}, -- explodes in a 3x3 area
['wallnut'] = {price = 50, atk = 0, def = 10, atkType = "nothing", chargeT = 1000, speed = 10*60*1000, special = "nothing", atkEff = 0, distEff = 0}, -- blocks zombie's way
['potato mine'] = {price = 25, atk = 100, def = 1, atkType = "stepInExplode", chargeT = 1000, speed = 500, special = "nothing", atkEff = 5, distEff = 0}, -- explodes on zombie's stepIn
['snow pea'] = {price = 175, atk = 1, def = 3, atkType = "normal", chargeT = 1000, speed = 2000, special = "slow", atkEff = 5, distEff = 3}, -- attacks like peashooter but slowing enemies
['chomper'] = {price = 150, atk = 100, def = 3, atkType = "eatZombi", chargeT = 1000, speed = 15*1000, special = "nothing", atkEff = 46, distEff = 0}, -- eats zombie in front of it
['repeater'] = {price = 200, atk = 1, def = 3, atkType = "normalx2", chargeT = 1000, speed = 2000, special = "nothing", atkEff = 20, distEff = 3} -- attacks 2 times in a straight line
}

To add a new plant, just add a line to the plants' table following the sample:
Code:
['customplant'] = {price = 4545, atk = 51, def = 43, atkType = "normal", chargeT = 1000, speed = 2000, special = "nothing", atkEff = 20, distEff = 3}
Just remember 'customplant' is the name of a real creature, if name is wrong game wont detect it as a plant


Zombie's config (similar to plants):

Code:
local zombies = {
['zombi'] = {atk=1, def=12, speed = 4000}, -- higher num of speed == slower
['zombi ghoul'] = {atk=1, def=30, speed = 4000},
['zombi shambler'] = {atk=1, def=40, speed = 3500},
['zombi mummy'] = {atk=1, def=80, speed = 4000},
['zombi ghost'] = {atk=1, def=85, speed = 3000}
}

explanation:
Code:
[zombie name] = {
atk = dmg done per hit to plants
def = HP it have
speed = time between each action (move or attack)
}


¿How it works??:
Actions:

There are 2 action items you start with:
- modifierTool
- eraserTool

modifierTool allows you to:
- inside game area, plant selected plants
- repair itemEx plant
- evolve plant if this one have an evolution (implemented but there are no evolution plants [they are normal plants])

eraserTool allows you to delete ingame plants


Creaturescripts:

How to select a plant?
Simple, just look on it!

But... how it works?
- If the plant is outside game area (for example, when talking to npc to play), this plant will be registered and you will be able to choose it ingame
- If we have already selected which plants we gonna use and we are inside the game area, selected plant will be the one you will plant with modifierTool


Movements:

When zombie steps in the tile, game will end.
(And yes, you will probably become a new zombie)


NPC:

4QRq6sC.png



Normal Flow:

tjIwr1P.jpg

.
.
.
KlWaKXl.jpg



ALERT!
This is a initial version. What does it mean? It means that there still are so many bugs, implementable things, and many improvements to do...
It is far from being perfect, but runs.
I would be grateful if any bug you find you report it to me. I'll try to solve bugs and update this post as fast as posible.

Please, avoid saying that the code could be improved, of course it could! And maybe i will improve it, but not for this initial version.

Any suggestions for improvement are also welcome.

Credits:
100% Strack (do not delete credits on scripts, if I find this code posted in another forum without credits I wont post anything again)
otland profile: http://otland.net/members/strack.41543/
btibia profile: http://www.blacktibia.org/u39936


PD: 10.000 characters is too short for some systems, i had to reduce the post >.<
 
Last edited:
added map link for mediafire

pd: potatoe plant doesnt work properly, it may bug the wave. I'll fix it as soon as posible, but cant know im so busy, sry.
 
I don't understand once you start the event and get to where u need to grow the plants how do you grow them?
 
¿How it works??:
Actions:

There are 2 action items you start with:
- modifierTool
- eraserTool

modifierTool allows you to:
- inside game area, plant selected plants
- repair itemEx plant
- evolve plant if this one have an evolution (implemented but there are no evolution plants [they are normal plants])

eraserTool allows you to delete ingame plants
-- items --
local item1 = 2557 -- id of the item used to plant or modify plants (modifierTool)

You plant them using defined item1 (modifierTool), to plant them you must have a selected plant, how to do it? Look at them.

It's all explained on the first post.
 
bug when selecting what? I got no bug with selection...

was tested on tfs 0.3.6pl1 - v8.54
 
I dont know how i can create plants on the area. Someone could tell me?
 
pre-select them with "look" action, use hammer (modifierTool) on the ground.
Note: you must have enough gold to do the action, otherwise you wont be able to plant the selected one.

I know it may be tiring to read all the explanation i wrote up there, but there is all the information about how to make it work.

Regards,
 
Back
Top