minmay wrote:Just return false from the onExplode hook and no explosion will be created. (The item will still be destroyed.)
I should have thought of that.
**Works perfectly.
minmay wrote:Just return false from the onExplode hook and no explosion will be created. (The item will still be destroyed.)
Code: Select all
defineObject{
name = "fire_bomb_trap_rune_utility",
components = {
{
class = "ScriptController",
name = "controller",
onInit = function(self) -----------------[utility script that reactivates the traps, and makes them red; also erases them after 50 seconds.]
self.go.script:setSource([[function armTheTrap(trap)
local trap = findEntity(trap)
trap.floortrigger:enable()
trap.model:setEmissiveColor(vec(0,-255,-255))
trap:playSound("key_lock") -------------------[ stock sound effect ]
delayedCall(self.go.id, 50, "eraseBomb", trap.id) -------[the trap duration of 50 can be changed to suit.]
end
function eraseBomb(trap)
local trap = findEntity(trap)
if trap then
trap:playSound("force_field_cast")
trap:destroy()
end
end ]])
end
},
{
class = "Script",
},
},
placement = "floor",
tags = { "scripting" },
editorIcon = 148,
}
defineObject{
name = "fire_bomb_trap_rune",
baseObject = "base_spell",
components = {
{
class = "Model",
model = "assets/models/effects/trap_rune.fbx",
offset = vec(0, 0.1, 0),
},
{
class = "ProjectileCollider",
collisionGroup = 2, -- only dispel projectiles collision with us
onInit = function(self)
if not fire_bomb_trap_rune_utility then ------------------[Spawns the utillity script and momentarily deactivates the rune trap; and makes it blue.]
spawn("fire_bomb_trap_rune_utility",1,0,0,0,0,"fire_bomb_trap_rune_utility")
end
self.go.floortrigger:disable()
delayedCall("fire_bomb_trap_rune_utility", 1.5, "armTheTrap", self.go.id)
self.go.model:setEmissiveColor(vec(-255,0,0))
end
},
{
class = "FloorTrigger",
triggeredByItem = false,
onActivate = function(self)
self.go:spawn("fireburst")
self.go:destroy()
end,
},
}
}
defineObject{
name = "trap_bomb_fire",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/essence_fire.fbx",
},
{
class = "Item",
uiName = "Trap Bomb",
gfxIndex = 346,
impactSound = "impact_blunt",
stackable = false,
sharpProjectile = false,
projectileRotationY = 90,
weight = 0.1,
},
{
class = "Particle",
particleSystem = "essence_fire",
},
{
class = "ThrowAttack",
cooldown = 4,
},
{
class = "BombItem",
bombType = "fire",
bombPower = 4,
onExplode = function(self,level,x,y,facing,elevation)
spawn("fire_bomb_trap_rune",level,x,y,facing,elevation)
self.go:playSound("lock_incorrect") ------------[ stock sound effect ]
return false end,
},
},
tags = { "weapon", "weapon_throwing", "custom_vieuxchat" },
}
defineObject{
name = "giant_snake_trap_thrower",
baseObject = "base_monster",
components = {
{
class = "Model",
model = "assets/models/monsters/snake.fbx",
storeSourceData = true,
enabled = false,
},
{
class = "Animation",
animations = {
idle = "assets/animations/monsters/snake/snake_idle.fbx",
moveForward = "assets/animations/monsters/snake/snake_walk.fbx",
turnLeft = "assets/animations/monsters/snake/snake_turn_left.fbx",
turnRight = "assets/animations/monsters/snake/snake_turn_right.fbx",
moveForwardTurnLeft = "assets/animations/monsters/snake/snake_walk_turn_left.fbx",
moveForwardTurnRight = "assets/animations/monsters/snake/snake_walk_turn_right.fbx",
attack = "assets/animations/monsters/snake/snake_attack.fbx",
attackFromBehind = "assets/animations/monsters/snake/snake_attack_from_behind.fbx",
getHitFrontLeft = "assets/animations/monsters/snake/snake_get_hit_front_left.fbx",
getHitFrontRight = "assets/animations/monsters/snake/snake_get_hit_front_right.fbx",
getHitBack = "assets/animations/monsters/snake/snake_get_hit_back.fbx",
getHitLeft = "assets/animations/monsters/snake/snake_get_hit_left.fbx",
getHitRight = "assets/animations/monsters/snake/snake_get_hit_right.fbx",
fall = "assets/animations/monsters/snake/snake_get_hit_front_left.fbx",
},
currentLevelOnly = true,
},
{
class = "Monster",
meshName = "snake_mesh",
hitSound = "snake_hit",
dieSound = "snake_die",
hitEffect = "hit_goo",
capsuleHeight = 0.2,
capsuleRadius = 0.7,
health = 300,
evasion = 10,
exp = 200,
traits = { "animal" },
headRotation = vec(90, 0, 0),
},
{
class = "UggardianBrain", ---------------------[Added simple onThink hook to allow modest trap avoidance.]
name = "brain",
sight = 10,
allAroundSight = true,
morale = 100,
onThink = function(self) --QaD Just enough so that it doesn't follow the party step for step; triggering its own traps.
local dX, dY = getForward(self.go.facing)
for each in self.go.map:entitiesAt(self.go.x+dX, self.go.y+dY) do
if each.name == "fire_bomb_trap_rune" then
local action = {"rangedAttack","rangedAttack","rangedAttack", "wait", "turnLeft", "turnRight"}
local choice = action[math.random(#action)]
return self.go.brain[choice](self.go.brain)
end
end
end
},
{
class = "MonsterMove",
name = "move",
sound = "snake_walk",
cooldown = 3,
},
{
class = "MonsterMove",
name = "moveForwardAndTurnRight",
animations = { forward="moveForwardTurnRight" },
sound = "snake_walk",
turnDir = 1,
cooldown = 2,
resetBasicAttack = true,
},
{
class = "MonsterMove",
name = "moveForwardAndTurnLeft",
animations = { forward="moveForwardTurnLeft" },
sound = "snake_walk",
turnDir = -1,
cooldown = 2,
resetBasicAttack = true,
},
{
class = "MonsterTurn",
name = "turn",
sound = "snake_walk",
resetBasicAttack = true,
},
{
class = "MonsterAttack",
name = "basicAttack",
attackFromBehindAnimation = "attackFromBehind",
attackPower = 26,
accuracy = 20,
cooldown = 4,
sound = "snake_attack",
woundChance = 30,
causeCondition = "poison",
conditionChance = 20,
},
{
class = "MonsterAttack",
name = "rangedAttack",
attackType = "projectile",
attackPower = 30,
cooldown = 4,
animation = "attack",
sound = "snake_attack",
shootProjectile = "trap_bomb_fire",
projectileHeight = 1.5,
},
{
class = "UggardianFlames",
particleSystem = "air_elemental", --_vieuxchat",
emitFromMaterial = "*",
},
},
tags = { "custom_vieuxchat" }
}
Code: Select all
defineObject{
name = "fire_bomb_trap_rune_utility",
components = {
{
class = "ScriptController",
name = "controller",
onInit = function(self) -----------------[utility script that reactivates the traps, and makes them red; also erases them after 50 seconds.]
self.go.script:setSource([[function armTheTrap(trap)
local trap = findEntity(trap)
trap.floortrigger:enable()
trap.model:setEmissiveColor(vec(0,-255,-255))
trap:playSound("key_lock") -------------------[ stock sound effect ]
delayedCall(self.go.id, 50, "eraseBomb", trap.id) -------[the trap duration of 50 can be changed to suit.]
end
function eraseBomb(trap)
local trap = findEntity(trap)
if trap then
trap:playSound("force_field_cast")
trap:destroy()
end
end ]])
end
},
{
class = "Script",
},
},
placement = "floor",
tags = { "scripting" },
editorIcon = 148,
}
defineObject{
name = "fire_bomb_trap_rune",
baseObject = "base_spell",
components = {
{
class = "Model",
model = "assets/models/effects/trap_rune.fbx",
offset = vec(0, 0.1, 0),
},
{
class = "ProjectileCollider",
collisionGroup = 2, -- only dispel projectiles collision with us
onInit = function(self)
if not fire_bomb_trap_rune_utility then ------------------[Spawns the utillity script and momentarily deactivates the rune trap; and makes it blue.]
spawn("fire_bomb_trap_rune_utility",1,0,0,0,0,"fire_bomb_trap_rune_utility")
end
self.go.floortrigger:disable()
delayedCall("fire_bomb_trap_rune_utility", 3, "armTheTrap", self.go.id)
self.go.model:setEmissiveColor(vec(-255,0,0))
end
},
{
class = "FloorTrigger",
triggeredByItem = false,
onActivate = function(self)
self.go:spawn("fireburst")
self.go:destroy()
end,
},
}
}
defineObject{
name = "trap_bomb_fire",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/essence_fire.fbx",
},
{
class = "Item",
uiName = "Trap Bomb",
gfxIndex = 346,
impactSound = "impact_blunt",
stackable = false,
sharpProjectile = false,
projectileRotationY = 90,
weight = 0.1,
},
{
class = "Particle",
particleSystem = "essence_fire",
},
{
class = "ThrowAttack",
cooldown = 4,
},
{
class = "BombItem",
bombType = "fire",
bombPower = 4,
onExplode = function(self,level,x,y,facing,elevation)
for each in self.go.map:entitiesAt(self.go.x, self.go.y) do
if each.monster or each.party then
return true
end
end
spawn("fire_bomb_trap_rune",level,x,y,facing,elevation)
self.go:playSound("lock_incorrect") ------------[ stock sound effect ]
return false
end,
},
},
tags = { "weapon", "weapon_throwing", "custom_vieuxchat" },
}
}
Code: Select all
defineObject{
name = "giant_snake_trap_thrower",
baseObject = "base_monster",
components = {
{
class = "Model",
model = "assets/models/monsters/snake.fbx",
storeSourceData = true,
enabled = false,
},
{
class = "Animation",
animations = {
idle = "assets/animations/monsters/snake/snake_idle.fbx",
moveForward = "assets/animations/monsters/snake/snake_walk.fbx",
turnLeft = "assets/animations/monsters/snake/snake_turn_left.fbx",
turnRight = "assets/animations/monsters/snake/snake_turn_right.fbx",
moveForwardTurnLeft = "assets/animations/monsters/snake/snake_walk_turn_left.fbx",
moveForwardTurnRight = "assets/animations/monsters/snake/snake_walk_turn_right.fbx",
attack = "assets/animations/monsters/snake/snake_attack.fbx",
attackFromBehind = "assets/animations/monsters/snake/snake_attack_from_behind.fbx",
getHitFrontLeft = "assets/animations/monsters/snake/snake_get_hit_front_left.fbx",
getHitFrontRight = "assets/animations/monsters/snake/snake_get_hit_front_right.fbx",
getHitBack = "assets/animations/monsters/snake/snake_get_hit_back.fbx",
getHitLeft = "assets/animations/monsters/snake/snake_get_hit_left.fbx",
getHitRight = "assets/animations/monsters/snake/snake_get_hit_right.fbx",
fall = "assets/animations/monsters/snake/snake_get_hit_front_left.fbx",
spinAttack = "mod_assets/animations/monsters/snake/spin_around_left.fbx",
},
currentLevelOnly = true,
},
{
class = "Monster",
meshName = "snake_mesh",
hitSound = "snake_hit",
dieSound = "snake_die",
hitEffect = "hit_goo",
capsuleHeight = 0.2,
capsuleRadius = 0.7,
health = 300,
evasion = 10,
exp = 200,
traits = { "animal" },
headRotation = vec(90, 0, 0),
},
{
class = "UggardianBrain",
name = "brain",
sight = 10,
allAroundSight = true,
morale = 100,
onThink = function(self) --QaD Just enough so that it doesn't always follow the party step for step; triggering its own traps.
local dX, dY = getForward(self.go.facing)
for each in self.go.map:entitiesAt(self.go.x+dX, self.go.y+dY) do
if each.name == "fire_bomb_trap_rune" and each.model:getEmissiveColor()[2] ~= "-255" then
local action = {"turnTowardsParty", "turnTowardsParty", "turnLeft", "turnRight", "wait" }
local choice = action[math.random(#action)]
if self.go.brain.partyStraightAhead then
choice = "rangedAttack"
end
self.go.brain[choice](self.go.brain)
return self.go.brain.seesParty
end
end
end,
},
{
class = "MonsterMove",
name = "move",
sound = "snake_walk",
cooldown = 3,
},
{
class = "MonsterMove",
name = "moveForwardAndTurnRight",
animations = { forward="moveForwardTurnRight" },
sound = "snake_walk",
turnDir = 1,
cooldown = 2,
resetBasicAttack = true,
},
{
class = "MonsterMove",
name = "moveForwardAndTurnLeft",
animations = { forward="moveForwardTurnLeft" },
sound = "snake_walk",
turnDir = -1,
cooldown = 2,
resetBasicAttack = true,
},
{
class = "MonsterTurn",
name = "turn",
sound = "snake_walk",
resetBasicAttack = true,
},
{
class = "MonsterAttack",
name = "basicAttack",
attackFromBehindAnimation = "attackFromBehind",
attackPower = 26,
accuracy = 20,
cooldown = 4,
sound = "snake_attack",
woundChance = 30,
causeCondition = "poison",
conditionChance = 20,
},
{
class = "MonsterAttack",
name = "rangedAttack",
attackType = "projectile",
attackPower = 30,
cooldown = 4,
animation = "spinAttack",
sound = 'snake_walk',
shootProjectile = "trap_bomb_fire",
projectileHeight = 1.5,
onAttack = function(self) self.go:playSound("snake_attack") end,
},
{
class = "UggardianFlames",
particleSystem = "air_elemental", --_vieuxchat",
emitFromMaterial = "*",
},
},
tags = { "custom_vieuxchat" }
}
defineAnimationEvent{
animation = "mod_assets/animations/monsters/snake/spin_around_left.fbx",
event = "attack",
frame = 43,
}
Code: Select all
if each.name == "trap_rune_*" then
Code: Select all
if each.name:find("trap_rune_") then
Code: Select all
if each.name:sub(1,10) == "trap_rune_" then
Code: Select all
if each.name:match("^trap_rune_*") then