游戏狂人
![Rank: 6](static/image/common/star_level3.gif) ![Rank: 6](static/image/common/star_level2.gif)
- 贡献度
- 223
- 金元
- 4634
- 积分
- 1365
- 精华
- 1
- 注册时间
- 2013-7-27
|
这是我的完整代码
local assets=
{
Asset("ANIM", "anim/brscanno.zip"),
Asset("ANIM", "anim/swap_brscanno.zip"),
Asset("ATLAS", "inventoryimages/brscanno.xml"),
}
local prefabs =
{
"ice_projectile",
}
local function onfinished(inst)
inst:Remove()
end
local function onequip(inst, owner)
---- 增加亮光
--inst.entity:AddLight()
--inst.Light:Enable(true)
--inst.Light:SetIntensity(0.75)
--inst.Light:SetColour(241/255,141/255,0/255)
--inst.Light:SetFalloff( 0.4 )
--inst.Light:SetRadius( 8 )
owner.AnimState:OverrideSymbol("swap_object", "swap_brscanno", "swap_icestaff")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
local com = owner.components.combat
inst.ownerAreaHitRange = com.areahitrange
inst.ownerAreaHitDamagePercent = com.areahitdamagepercent
com.areahitrange = 10
com.areahitdamagepercent = 0.5
end
local function onunequip(inst, owner)
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
end
local function onattack(inst, owner, target)
if owner.components.sanity and owner.components.sanity:GetPercent() < 1.1 and not target:HasTag("wall") then
owner.components.sanity oDelta(-10)
owner.components.health oDelta(-5)
end
if owner.components.sanity and owner.components.sanity:GetPercent() < 0.5 and not target:HasTag("wall") then
owner.components.sanity oDelta(-20)
owner.components.health oDelta(-10)
end
if owner.components.sanity and owner.components.sanity:GetPercent() < 0.1 and not target:HasTag("wall") then
owner.components.health oDelta(-30)
end
end
local function fn(Sim)
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
local anim = inst.entity:AddAnimState()
inst.entity:AddSoundEmitter()
----
MakeInventoryPhysics(inst)
anim:SetBank("icestaff")
anim:SetBuild("brscanno")
anim layAnimation("idle")
inst:AddTag("icestaff")
inst:AddTag("rangediceweapon")
----- 放地上可以用来做饭
--inst:AddComponent("cooker")
----- 发热
--inst:AddComponent("heater")
--inst.components.heater.equippedheat = 9999
----- 点火
--inst:AddComponent("lighter")
----- 保温
--inst:AddComponent("insulator")
--inst.components.insulator.insulation = TUNING.INSULATION_MED
----- 保护脑残值
--inst:AddComponent("dapperness")
--inst.components.dapperness.dapperness = TUNING.DAPPERNESS_TINY
----- 工具添加
--inst:AddComponent("tool")
--inst.components.tool:SetAction(ACTIONS.CHOP, 2)
--inst.components.tool:SetAction(ACTIONS.MINE, 2, 2)
--inst.components.tool:SetAction(ACTIONS.DIG, 2)
--inst.components.tool:SetAction(ACTIONS.HAMMER, 2)
--if TheInput:IsKeyDown(KEY_CTRL) then
--inst.components.tool:SetAction(ACTIONS.NET)
--end
---- 钓鱼
--inst:AddComponent("fishingrod")
----- 武器相关
inst:AddComponent("weapon")
inst.components.weapon:SetDamage(800)
inst.components.weapon:SetRange(100, 100)
inst.components.weapon:SetOnAttack(onattack)
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(TUNING.AXE_USES)
inst.components.finiteuses:SetUses(TUNING.AXE_USES)
inst.components.finiteuses:SetOnFinished( onfinished )
inst.components.weapon:SetProjectile("brs_projectile")
inst.components.weapon.quickAttack=true --攻击加速
-------
inst:AddComponent("inspectable")
inst:AddComponent("inventoryitem")
inst.components.inventoryitem.atlasname = "inventoryimages/brscanno.xml"
inst:AddComponent("equippable")
inst.components.equippable.walkspeedmult = 1.2, --移动加速
inst.components.equippable:SetOnEquip( onequip )
inst.components.equippable:SetOnUnequip( onunequip )
return inst
end |
|