Page 326 of 396
Re: Ask a simple question, get a simple answer
Posted: Fri Sep 13, 2019 7:20 pm
by Zo Kath Ra
maneus wrote: ↑Fri Sep 13, 2019 4:39 pm
No idea if it worked but how if your dying "plant" would spawn a timer which is connected to a script in your mod?
Spawn the timer on the place your dying plant is, like:
You're right, that's probably the best solution.
It's simple and it works reliably, even if you destroy the plant while it's regrowing.
Put this in objects.lua:
Code: Select all
defineObject{
name = "beach_cattail_damaged",
baseObject = "beach_cattail_damaged",
components = {
{
class = "Timer",
currentLevelOnly = true,
disableSelf = true,
timerInterval = 5,
onActivate = function(self)
self.go:destroyDelayed()
spawn("beach_cattail_blocker", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
end
},
},
}
defineObject{
name = "beach_cattail_broken",
baseObject = "beach_cattail_broken",
components = {
{
class = "Timer",
currentLevelOnly = true,
disableSelf = true,
timerInterval = 5,
onActivate = function(self)
self.go:destroyDelayed()
spawn("beach_cattail_damaged", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
end
},
},
}
Re: Ask a simple question, get a simple answer
Posted: Fri Sep 13, 2019 10:44 pm
by Pompidom
minmay wrote: ↑Fri Sep 13, 2019 7:35 am
CastSpellComponent is what you would use for that; look at the fire blade, lightning rod, stormseed orb, etc. in the standard assets for examples. Just set it as the primary action instead of the secondary action like it is for those items.
Be aware however that the onComputeCooldown hook doesn't work for CastSpellComponent, or RunePanelComponent for that matter, so plan accordingly (probably by replacing all your onComputeCooldown hooks with multipliers to the champion's "cooldown_rate" stat).
I'd rather look at your g1_power_weapon defineobject code, but I can't find it anywhere in any of the notepad files.
It shoots lightning bolts instantly.
Re: Ask a simple question, get a simple answer
Posted: Sun Sep 15, 2019 8:35 am
by Lorial
Thanks for your help Maneus and Zo Kath Ra.
I fiddled around a bit and came to the conclusion that using the timer idea on the "broken" plants only is the best and simplest solution. You destroy them, they respawn fully regrown on their position after an hour or two - end of story.
It kind of seems like the timer is slowed down when leaving the current level, but maybe the transition to another level stops the timer for a bit. I only hope that saving/reloading and possible crashes have no effect on the timers (which I assume are global?!) and reset them or some such.
I was just thinking of the farmer class and the activateByDigging function trigger plates use.
1) Is it possible to "manually" activate the timer of the specific plant so that prior farming or tending is required to make it regrow?
2) Making a specific weapon (scythe) a requirement for harvesting/destroying the plant is probably not an option, just like mining specifically with a pickax isn't or does anyone have a solution for that? Then again, a "farmers only" limitation for that weapon would be needed as well. Can this limitation be connected with a secondaryAction and an onUse function, e.g. if champion:hastrait("farmer") or champion:getClass == "farmer" or whatever?
3) Is the nutrition value of food directly connected to the XP gain of farmers?
Re: Ask a simple question, get a simple answer
Posted: Sun Sep 15, 2019 12:15 pm
by Pompidom
I finally found the power weapon code xD
Don't know how I missed it
For people that want to create magic staffs without buildup charge.
This should be an easy fix:
Code: Select all
defineObject{
name = "g1_power_weapon",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/power_weapon.fbx",
},
{
class = "Item",
uiName = "Weapon of Power",
description = "The purpose of this ancient device is a mystery, but its immense power is obvious.",
gameEffect = "Damage: 18 - 54",
gfxAtlas = "mod_assets/g1/items/icons.tga",
gfxIndex = 66,
impactSound = "impact_blade",
weight = 4.0,
primaryAction = "lightningBolt",
},
{
class = "CastSpell",
name = "lightningBolt",
uiName = "Lightning Bolt",
spell = "lightning_bolt",
power = 1, -- results in 36 attack power instead of the 30 in grimrock 1, but that's okay IMO
cooldown = 8,
},
},
tags = { "weapon" },
}
Re: Ask a simple question, get a simple answer
Posted: Sun Sep 15, 2019 8:24 pm
by Pompidom
Code: Select all
function crawlerSpawn(monster)
local monster = monster or self
monster.go:spawn("turtle").monster:addConnector("onDie", self.go.id, "crawlerSpawn")
if not respawnTimer then
local t = self.go:spawn('timer').timer
t:addConnector('onAcivate', self.go.id, "crawlerSpawn")
t:start()
t:setDisableSelf(true)
end
end
crawlerSpawn(self)
Currently a new monster spawns instantly on the place it dies.
Then I realize there is a spelling mistake
t:addConnector('onAc
tivate', self.go.id, "crawlerSpawn")
So I correct it and now turtles spawn at infinitum like ants out of an anthill
I simply want it to spawn a new turtle at the location of the script whenever the turtle is killed.
https://youtu.be/t0sw9wQfp3I
Re: Ask a simple question, get a simple answer
Posted: Sun Sep 15, 2019 10:10 pm
by akroma222
Pompidom wrote: ↑Sun Sep 15, 2019 8:24 pm
I simply want it to spawn a new turtle at the location of the script whenever the turtle is killed.
Try this:
Code: Select all
function spawnTurtleOnDie(mon)
local spawnPoint = findEntity(self.go.id)
local newTurtle = spawnPoint:spawn("turtle").monster:addConnector("onDie", self.go.id, "spawnTurtleOnDie")
end
spawnTurtleOnDie(nil)
Re: Ask a simple question, get a simple answer
Posted: Mon Sep 16, 2019 5:03 pm
by Pompidom
Code: Select all
defineObject{
name = "dm_staff_of_manar1",
baseObject = "base_dm_item",
components = {
{
class = "Model",
model = "mod_assets/dmcsb_pack/models/items/dm_staff_of_manar.fbx",
},
{
class = "Item",
uiName = "Staff of Lightning bolt +1",
description = "An ancient magical staff that shoots lightning bolts",
gfxAtlas = "mod_assets/dmcsb_pack/textures/gui/dm_icoatlas.tga",
gfxIndex = 71,
gfxIndexPowerAttack = 150,
impactSound = "impact_blunt",
weight = 2.9,
primaryAction = "lightningBolt",
},
{
class = "CastSpell",
name = "lightningBolt",
uiName = "Lightning Bolt",
spell = "lightning_bolt",
charges = 5,
power = 1, -- results in 36 attack power instead of the 30 in grimrock 1, but that's okay IMO
},
},
tags = { "weapon" },
}
This staff has 5 charges and every time you click it, it will shoot a lightning bolt instantly. there is also no cooldown, so you can unleash all 5 charges in less than a second during difficult encounters.
I had several ideas, a recharge station in the town. I made one, it's clunky, but it works and it can recharge any wand or magic object with charges. I would like to simplify it as it involves dropping the empty wand on the power station, destroys it and simply gives a new wand which means a lot of code to manually add every single object. If anyone has any ideas let me know
A recharging crystal item that is not a one time consumable would work as well. You can't leave the room as long the recharging crystal is not on it's pedestal. This way the object can not leave the room.
2nd idea: a timer component? that recharges the wand with 1 charge every 2 minutes. This one is currently my preference.
the question is how?
3rd idea: simply a secondary action that recharges the wand for 150 energy. in case the 2nd idea proves to be impossible to code.
Basically like recharging the revolver. But I would like help with the code needed. Looking at defineobject code of the recharging crystal consumable + the revolver doesn't cut it.
Re: Ask a simple question, get a simple answer
Posted: Mon Sep 16, 2019 5:18 pm
by Isaac
staff.item:setCharges(number)
In a timer driven function, number could be staff.item:getCharges() + 1
(With a maximum cap set, of course.)
Re: Ask a simple question, get a simple answer
Posted: Mon Sep 16, 2019 5:25 pm
by Pompidom
Isaac wrote: ↑Mon Sep 16, 2019 5:18 pm
staff.item:setCharges(number)
In a timer driven function, number could be staff.item:getCharges() + 1
(With a maximum cap set, of course.)
Weapons and objects don't have unique names in my mod, they're simply bought from shops.
You can for instance blow all your money on 8 lightning staffs with 4 dual staff wielding mages. (Just an example)
So it has to be implemented directly in the define object code of the staff if that's possible
Re: Ask a simple question, get a simple answer
Posted: Mon Sep 16, 2019 5:57 pm
by Pompidom
local soulCount = self.go.lightningBolt:getCharges()
if time=blablabla
soulCount = self.go.lightningBolt:getCharges() + 1