local tile = ground.Map:GetTileAtPoint(pos.x, pos.y, pos.z)
return tile ~= GROUND.IMPASSIBLE and tile < GROUND.UNDERGROUND end return false end
local function createlight(staff, target, pos) local light = SpawnPrefab("perd") light.Transform:SetPosition(pos.x, pos.y, pos.z) local caster = staff.components.inventoryitem.owner end
inst:AddComponent("spellcaster") inst.components.spellcaster:SetSpellFn(createlight) inst.components.spellcaster:SetSpellTestFn(cancreatelight)
inst.components.spellcaster.canuseonpoint = true inst.components.spellcaster.canusefrominventory = false
¼´¿É×°±¸»ØÐýïÚºó£¬ÔÚ¿ÕµØÉϵãÊó±êÓÒ¼üÕÙ»½»ð¼¦¡£ÆäÖÐperd£¨»ð¼¦£©¿ÉÒÔÌ滻ΪÆäËûÎïÆ·
ÁùÊ®Èý.È®ÑÀ·ÉïÚ£¨×°±¸È®ÑÀ£¬Ò»ÕÐÖƵУ©
ÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\houndstooth.luaÎļþ£¬
1.ÔÚÏÂÁÐÄÚÈÝ£º
local assets= {
Asset("ANIM", "anim/hounds_tooth.zip"), }
µÄÏÂÒ»ÐвåÈëÒÔÏÂÄÚÈÝ£º
local function onequip(inst, owner)
owner.AnimState:OverrideSymbol("swap_object", "swap_houndstooth")
owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end
"swap_houndstooth",
local function onunequip(inst, owner)
owner.AnimState:ClearOverrideSymbol("swap_object") owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") end
local function onhit(inst, attacker, target)
local impactfx = SpawnPrefab("impact") if impactfx then
local follower = impactfx.entity:AddFollower()
follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 ) impactfx:FacePoint(Vector3(attacker.Transform:GetWorldPosition())) end
inst:Remove() end
local function onthrown(inst, data)
inst.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) end
2.ÔÚinst:AddComponent("inspectable")µÄÏÂÒ»ÐвåÈëÒÔÏÂÄÚÈÝ£º
inst:AddComponent("weapon") inst.components.weapon:SetDamage(3000) inst.components.weapon:SetRange(15, 18)
inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst.components.equippable.equipstack = true
inst:AddComponent("projectile") inst.components.projectile:SetSpeed(60) inst.components.projectile:SetOnHitFn(onhit) inst:ListenForEvent("onthrown", onthrown)
¼´¿ÉʹȮÑÀ³ÉΪװ±¸µÄÎäÆ÷£¬Ë¦³öÈ¥¿ÉÒ»ÕÐÖƵС£ÓÃÈ®ÑÀÖÆÔìÎïƷʱ£¬·ÅÔÚ·Ç×°±¸¸ñ£¨ÆÕͨ¿â´æ¸ñ»ò±³°ü¸ñ£©¼´¿É
ÁùÊ®ËÄ.ÖÖ¸¯ÀÃʳÎïµÃ¸ß
Äñ£¬¸ßÄñÎÞ¹¥»÷ÐÐΪ¡¢Ï¸ßÄñµ°£¬¸ßÄñµ°¿É¶Ñµþ
1.ÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\spoiledfood.luaÎļþ£¬ÔÚ
inst.components.edible.hungervalue = TUNING.SPOILED_HUNGERµÄÏÂÒ»ÐвåÈëÏÂÁÐÄÚÈÝ£º
local function OnDeploy (inst, pt)
local tallbird = SpawnPrefab("tallbird") if tallbird then
tallbird:PushEvent("growfromspoiledfood") tallbird.Transform:SetPosition(pt.x, pt.y, pt.z) inst.components.stackable:Get():Remove() end end
inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy
2.ÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\tallbird.luaÎļþ£¬½«ÒÔÏÂÄÚÈÝ£º
inst.components.combat:SetRange(TUNING.TALLBIRD_ATTACK_RANGE) ÐÞ¸ÄΪ£º
inst.components.combat:SetRange(TUNING.TALLBIRD_ATTACK_RANGE*0)
ÔÚinst:AddComponent("inspectable")µÄÏÂÒ»ÐвåÈëÒÔÏÂÄÚÈÝ£º
inst:AddComponent("periodicspawner")
inst.components.periodicspawner:SetPrefab("tallbirdegg") inst.components.periodicspawner:SetRandomTimes(80, 110) inst.components.periodicspawner:SetDensityInRange(20, 2) inst.components.periodicspawner:SetMinimumSpacing(8) inst.components.periodicspawner:Start()
3.ÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\tallbirdegg.luainst:AddComponent("edible")µÄÏÂÒ»ÐвåÈëÏÂÁÐÄÚÈÝ£º
inst:AddComponent("stackable")
inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM
Îļþ£¬ÔÚ
ÁùÊ®Îå.ÇàÄê¸ßÄñ²»³¤´ó£¬²¢Ôö¼ÓѪÁ¿¼°¹¥»÷Á¦£¬Î¹Ê³¿ÉÖØÐÂÈÏÈË
1.ÇàÄê¸ßÄñ18000Ìì²»³¤´ó£ºÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\smallbird.luaÎļþ£¬½«return TUNING.TEENBIRD_GROW_TIMEÌ滻Ϊreturn TUNING.TEENBIRD_GROW_TIME*1000¼´¿É
2.Ìá¸ßÇàÄê¸ßÄñѪÁ¿µ½30000µã£ºÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\smallbird.luaÎļþ£¬½«
3.Ìá¸ßÇàÄê¸ßÄñ¹¥»÷Á¦µ½180µã£ºÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\smallbird.luaÎļþ£¬½«
4.ͨ¹ýιʳÈøßÄñÖØÐÂÈÏÈË£ºÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\smallbird.luaÎļþ£¬ÔÚ--print("smallbird - OnGetItemFromPlayer")µÄÏÂÒ»ÐвåÈëÒÔÏÂÄÚÈÝ£º
local player = GetPlayer()
if player and player.components.leader then player.components.leader:AddFollower(inst) end
ÁùÊ®Áù.ι×ÔÑø¸ßÄñ²ú±ã±ã
ÓüÇʱ¾´ò¿ªÓÎϷĿ¼\\data\\scripts\\prefabs\\smallbird.luaÎļþ£¬ÔÚlocal function OnEat(inst, food)µÄÏÂÒ»ÐвåÈëÒÔÏÂÄÚÈÝ£º
if food.components.edible then
local poo = SpawnPrefab("poop") poo.Transform:
SetPosition(inst.Transform:GetWorldPosition()) end
¼´¿Éι×ÔÑø¸ßÄñ²ú±ã±ã
inst.components.combat:SetDefaultDamage(TUNING.TEENBIRD_DAMAGE)
Ìæ
»»
Ϊ
inst.components.combat:SetDefaultDamage(TUNING.TEENBIRD_DAMAGE*5)
inst.components.health:SetMaxHealth(TUNING.TEENBIRD_HEALTH)
Ìæ
»»
Ϊ
inst.components.health:SetMaxHealth(TUNING.TEENBIRD_HEALTH*100)¼´¿É