Page 295 of 396
Re: Ask a simple question, get a simple answer
Posted: Thu Mar 28, 2019 6:50 am
by Lorial
How can I define a proper "fence"?
When I define the object as "base_door" I get warning messages as the gate node is missing. Using "base_wall" will just let the party walk through. A workaround is the added "obstacle" component which blocks the tile the wall is attached to. So for wall_decorations that is no problem, but in a more central position it is not an option.
I also tried using an existing fence as "base_object". Works, but with the obligatory console warning of a missing gate node.
Code: Select all
defineObject{
name = "cemetery_fence_02",
-- baseObject = "base_wall",
-- baseObject = "base_door",
baseObject = "cemetery_wall_01",
components = {
{
class = "Model",
model = "mod_assets/models/cemetery_fence_02.fbx",
staticShadow = true,
},
},
placement = "wall",
editorIcon = 124,
automapIcon = 84,
}
PS: The constrainBox doesn't seem to work either. Am I right in assuming that box1 and box2 are needed to form an impassible... box for items, for instance throwing weapons? Would that refer to the party as well?! Puzzling...
Re: Ask a simple question, get a simple answer
Posted: Thu Mar 28, 2019 10:44 am
by minmay
You need to make a model with a mesh node named "gate". That mesh will be used for detecting collisions with the DoorComponent.
ItemConstrainBoxComponent only affects dropping and pushing items, not thrown items; you want ProjectileColliderComponent for colliding with thrown items. But you normally don't want to add a ProjectileColliderComponent to a door, because the DoorComponent already handles projectile collision using the gate node.
The ItemConstrainBoxComponents on base_door are there to stop you from dropping items inside the door frame.
Re: Ask a simple question, get a simple answer
Posted: Thu Mar 28, 2019 11:57 am
by Lorial
minmay wrote: ↑Thu Mar 28, 2019 10:44 am
You need to make a model with a mesh node named "gate". That mesh will be used for detecting collisions with the DoorComponent.
ItemConstrainBoxComponent only affects dropping and pushing items, not thrown items; you want ProjectileColliderComponent for colliding with thrown items. But you normally don't want to add a ProjectileColliderComponent to a door, because the DoorComponent already handles projectile collision using the gate node.
The ItemConstrainBoxComponents on base_door are there to stop you from dropping items inside the door frame.
Yes, I figured it out in the meantime, thanks. Apparently it does not work with "Gate", but the node needs to be called "gate" - the usual. Do not forget to "update" the node before you save the model.
Thanks for the constrain box explanation. Wall_grating objects seem to have none, hence the reason why you can lay things beyond the frame. Having no ProjectileCollider for a waist-high fence or low wall would be prefered anyway.
So in case anyone else was wondering, this here should work for a proper fence:
Code: Select all
defineObject{
name = "cemetery_fence_02",
baseObject = "base_wall_grating",
components = {
{
class = "Model",
model = "mod_assets/models/cemetery_fence_02.fbx",
staticShadow = true,
},
},
placement = "wall",
editorIcon = 124,
automapIcon = 84,
}
Wouldn't a constrainBox work the same way as a surface component, for instance for a raised floor tile model to prevent things from falling "into" the model?
Re: Ask a simple question, get a simple answer
Posted: Sat Mar 30, 2019 12:25 pm
by shayologo
Hello
It's a way to fixe range from firearm? I don't want to take care about to firearm skill
I want a range of 1 for one firearm
Re: Ask a simple question, get a simple answer
Posted: Sat Mar 30, 2019 4:00 pm
by Zo Kath Ra
shayologo wrote: ↑Sat Mar 30, 2019 12:25 pm
Hello
It's a way to fixe range from firearm? I don't want to take care about to firearm skill
I want a range of 1 for one firearm
Define a new firearm that sets the Firearms skill to 1 when equipped and remembers the old value, maybe in a Counter component.
Problem: If the champion increases his Firearms skill while wielding the weapon, that's not taken into account.
Re: Ask a simple question, get a simple answer
Posted: Sat Mar 30, 2019 7:16 pm
by minmay
Zo Kath Ra wrote: ↑Sat Mar 30, 2019 4:00 pmDefine a new firearm that sets the Firearms skill to 1 when equipped and remembers the old value, maybe in a Counter component.
Problem: If the champion increases his Firearms skill while wielding the weapon, that's not taken into account.
Uhh, please don't do that. As soon as the player opens the skill screen, that approach is ruined.
A much simpler way to force a specific range: set the range to 1-champion:getSkillLevel("firearms") in the onAttack hook, and set it back to 1 right after the attack, like this:
Code: Select all
defineObject{
name = "really_crappy_gun",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/pistol.fbx",
},
{
class = "Item",
uiName = "Really Crappy Gun",
gfxIndex = 333,
impactSound = "impact_blunt",
weight = 1.1,
traits = { "firearm" },
},
{
class = "FirearmAttack",
attackPower = 5,
cooldown = 6,
range = 1,
attackSound = "gun_shot_small",
ammo = "pellet",
requirements = { "firearms", 1 },
onAttack = function(self, champion, slot)
self:setRange(1-champion:getSkillLevel("firearms"))
end,
onPostAttack = function(self, champion, slot)
self:setRange(1)
end,
},
},
}
It's a bit more involved if you want the firearm to be able to jam or backfire (jams don't call onPostAttack, backfires call onBackfire instead of onPostAttack) but still fairly simple, and I can explain how to do that too if needed.
Re: Ask a simple question, get a simple answer
Posted: Sat Mar 30, 2019 7:45 pm
by shayologo
Thx you man
you are my hero
Re: Ask a simple question, get a simple answer
Posted: Mon Apr 01, 2019 4:32 am
by vanblam
is there a way to spawn an object in a specific direction, or force direction?
Code: Select all
if g.map:getCeilingElevation(g.x,g.y)-1 == g.elevation then
local choice2 = math.random()
if choice2 <= 0.25 then
g:spawn("sg_forest_rock_ceiling_trim01")
elseif choice2 <= 0.50 then
g:spawn("sg_forest_rock_ceiling_trim02")
elseif choice2 <= 0.75 then
g:spawn("sg_forest_rock_ceiling_trim03")
else
g:spawn("sg_forest_rock_ceiling_trim04")
end
end
For example in this section what could I do to get it to spawn in a specific direction?
Re: Ask a simple question, get a simple answer
Posted: Mon Apr 01, 2019 5:42 am
by minmay
You'll have to use the global spawn(name, level, x, y, facing, elevation, [id]) function. GameObject:spawn() always spawns the new object with the facing of the object you're spawning it from.
g:spawn("thing") is equivalent to spawn("thing",g.level,g.x,g.y,g.facing,g.elevation)
Re: Ask a simple question, get a simple answer
Posted: Mon Apr 01, 2019 5:51 am
by vanblam
minmay wrote: ↑Mon Apr 01, 2019 5:42 am
You'll have to use the global spawn(name, level, x, y, facing, elevation, [id]) function. GameObject:spawn() always spawns the new object with the facing of the object you're spawning it from.
g:spawn("thing") is equivalent to spawn("thing",g.level,g.x,g.y,g.facing,g.elevation)
Awesome ty sir