Forum nie tylko o Tibii i OTS...

Nie tylko o Tibii i OTS...

  • Nie jesteś zalogowany.
  • Polecamy: Gry

#1 2012-01-11 13:25:22

Sassin

http://i38.tinypic.com/19pb0n.gif

Zarejestrowany: 2012-01-11
Posty: 11

Tower Attack 8.54

Oto skrypt, który napisałem dla zabicia czasu.

Tworzymy plik o nazwie tower.lua w data/spells/scripts i wklejamy:

Kod:

local function isWalkable(pos, creature, proj, pz)
if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
    pos.stackpos = i
    local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
end
return true
end

local config = {
                storage = 2000,
                max_towers = 1, --maksymalna ilość wież
                name = 'tower', --nazwa NPCta
                time = 30, --w sekundach
                }
                
function onTargetTile(cid, pos)
if isWalkable(pos, true, true, true) then
    local npc = doCreateNpc(config.name, pos, false)
    doCreatureSetStorage(npc, config.storage, cid)
    doPlayerSetStorageValue(cid, config.storage, (getPlayerStorageValue(cid, config.storage) <= 0 and 1 or getPlayerStorageValue(cid, config.storage) + 1))
    return addEvent(function()
                            pos.stackpos = STACKPOS_TOP_CREATURE
                            if getThingFromPos(pos).uid == 0 then
                                return true
                            end
                            if getCreatureName(getThingFromPos(pos).uid):lower() == config.name:lower() then
                                doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) - 1)
                                return doRemoveCreature(getThingFromPos(pos).uid)
                            end end,
                            config.time * 1000,
                            cid, pos, config)
    
end
return true
end

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_BIGCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, config.storage) >= config.max_towers then
    return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Posiadasz maksymalna ilosc wieżyczek.')
end
return doCombat(cid, combat, var)
end

Do spells.xml doklejamy:

Kod:

<rune name="Test" id="2268" mana="0" allowfaruse="1" exhaustion="0" blocktype="solid" event="script" value="test.lua"/>

Idziemy do data/NPC/scripts, tworzymy plik tower.lua i wklejamy:

Kod:

local damage = {
                ['fire'] = {COMBAT_FIREDAMAGE,CONST_ME_FIREAREA,CONST_ANI_FIRE},
                ['ice'] = {COMBAT_ICEDAMAGE,CONST_ME_ICEATTACK,CONST_ANI_ICE},
                ['earth'] = {COMBAT_EARTHDAMAGE,CONST_ME_CARNIPHILA,CONST_ANI_EARTH},
                ['energy'] = {COMBAT_ENERGYDAMAGE,CONST_ME_ENERGYHIT,CONST_ANI_ENERGY},
                ['death'] = {COMBAT_DEATHDAMAGE,CONST_ME_MORTAREA,CONST_ANI_SUDDENDEATH},
                ['holy'] = {COMBAT_HOLYDAMAGE,CONST_ME_HOLYDAMAGE,CONST_ANI_HOLY},
                ['physical'] = {COMBAT_PHYSICALDAMAGE,CONST_ME_GROUNDSHAKER,CONST_ANI_LARGEROCK},
                ['drown'] = {COMBAT_DROWNDAMAGE,CONST_ME_WATERSPLASH,CONST_ANI_SMALLICE}
                }
local types = {'fire','ice','earth','energy','death','holy','physical','drown'}

local keywordHandler, t, h = KeywordHandler:new(), 0, 0
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)         npcHandler:onCreatureDisappear(cid)         end

local config = {
                storage = 2000,
                range = 5, --zasieg wiezyczki
                player_range = 8, --odległość na jaką może odejść gracz by wieza nie znikla
                ----
                damage = {300,500}, --obrazenia {min, max}
                interval = 2, --w sekundach
                type = '', --typ obrażeń, do wyboru 'fire', 'ice', 'earth', 'energy', 'death', 'holy', 'physical', 'drown'
                ----
                interval_healing = 3, --po ile ataków ma uleczać, na przykład: atak (1), atak (2), atak (3), leczenie, atak (1) ...
                healing = {10,25} --leczenie {od, do}
                }
function onThink()                        npcHandler:onThink()                         
local cid = getCreatureStorage(getNpcCid(), config.storage)
if isPlayer(cid) then
    if getDistanceBetween(getThingPos(getNpcCid()), getThingPos(cid)) > config.player_range then
        doRemoveCreature(getNpcCid())
        return doPlayerSetStorageValue(cid, config.storage, 0)
    end
else
    return doRemoveCreature(getNpcCid())
end 
if getCreatureTarget(cid) == 0 then
    t = 0
    return true
end
if getDistanceBetween(getThingPos(getNpcCid()), getThingPos(getCreatureTarget(cid))) > config.range then
    return true
end
if t == 0 and h <= config.interval_healing then
    local v = damage[config.type]
    if not v then
        local s = types[math.random(#types)]
        v = damage[s]
    end
        if h == config.interval_healing then
            doTargetCombatHealth(getNpcCid(), cid, COMBAT_HEALING, config.healing[1], config.healing[2], CONST_ME_MAGIC_BLUE)
            h = 0
            t = 1
            return doSendDistanceShoot(getThingPos(getNpcCid()), getThingPos(cid), CONST_ANI_ENERGYBALL)
        end
        doTargetCombatHealth(getNpcCid(), getCreatureTarget(cid), v[1], -config.damage[1], -config.damage[2], v[2])
        doSendDistanceShoot(getThingPos(getNpcCid()), getThingPos(getCreatureTarget(cid)), v[3])
        h = h + 1
        t = 1
elseif t > 0 and t <= config.interval then
    t = t + 1
else
    t = 0
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

W data/NPC robimy plik tower.xml i wklejamy:

Kod:

<?xml version="1.0"?>
<npc name="Tower" floorchange="0" speed="0" hidehealth="1" walkable="0" script="tower.lua">
    <health now="150" max="150"/>
    <look type="333"/>
</npc>

Jak to działa zapytacie?
Otóż używając runy (w tym przypadku 2268 czyli SD) gdziekolwiek w zasięgu wzroku, pojawi się nam wieżyczka, która będzie nam pomagać w walce.
Bazowo jest ustawione, iż atakuje co 2 sekundy ze wszystkich żywiołów (losowość), a co 3 tury zaprzestaje ataku by nas uleczyć. Wieża po 30 sekundach znika.
Ogólnie skrypt jest banalny i prosty, ale wystarczy trochę umiejętności i mnóstwo wyobraźni by stworzyć z tego coś naprawdę godnego uwagi.


http://s2.tibiafun.y0.pl/char.php?c=Sassin

Kliknij, i pomóż nabić mi LvL

Offline

 

#2 2012-02-21 02:26:45

 KamaShoot

http://i35.tinypic.com/2q9yumu.gif

12612754
Call me!
Skąd: FRANCE
Zarejestrowany: 2012-02-19
Posty: 137
Profesja: Hoster
Server: MINIWAR
WWW

Re: Tower Attack 8.54

Bardzo ciekawy skrypt, gratuluje pomyslu, napewno przyda sie nie jednemu graczu.
Ocena 9/10


Pomoglem daj +
http://s2.tibiafun.y0.pl/char.php?c=Bladeli
Zapraszam na najlepsze forum o OTS www.tibiaot.pun.pl
http://img844.imageshack.us/img844/5093/111ke.gif

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
https://www.berlin-hotel.pl/