Page 71 of 396

Re: Ask a simple question, get a simple answer

Posted: Fri May 29, 2015 12:33 pm
by alois
st1nger wrote:hi everyone

is it possible to check if the party moves against a wall?
i want script the system from DM to damage the party.
or has anyone else these system already?
Try this :)

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
			class = "Party",
			onMove = function(self,direction)
				local dx,dy = getForward(direction)
				if self.go.map:isBlocked(self.go.x+dx,self.go.y+dy,self.go.elevation) then
					-- add your damage routine here
					return true -- if you want the "bumping effect"; otherwise return false
				else
					return true -- let the party move freely
				end
			end,
		},
	},
}
Alois :)

Re: Ask a simple question, get a simple answer

Posted: Fri May 29, 2015 1:29 pm
by st1nger
Wonderful. Thank you :)

Re: Ask a simple question, get a simple answer

Posted: Fri May 29, 2015 2:46 pm
by Isaac
Here is an alternative that allows setting it via function call; and optionally limits damage to the two closest PCs (that actually touch the wall).

example usage: hurt.script:setActive(true, 10, "fire") The last two arguments are optional.
hurt.script:setSelective(false) causes indiscriminate party damage instead of the default (selective).

Code: Select all

-- script name: hurt
wall_damage = 2
damage_type = "physical"
selective = true

function dmgWall(self, dir)
	local dX,dY = getForward(dir)
	local x,y = party.x+dX, party.y+dY
	if party.map:isWall(x,y) then
		if selective then
			local injured = {{1,2},{2,4},{3,4},{1,3}}
			local rank = 2
			for x = 1,2 do
				local move = (dir - (party.facing))%4 +1
				local champion = party.party:getChampion(injured[move][x])
				 if champion:isAlive() then
					champion:damage(wall_damage, damage_type)
				 else
					rank = rank - 1
						if rank < 1 then
						    for x = 1,4 do
								party.party:getChampion(x):damage(wall_damage, damage_type)
							end
						end
				 end
			end
		else 
			for x = 1,4 do
				local champion = party.party:getChampion(x)
				if champion:isAlive() then
					champion:damage(wall_damage, damage_type)	
				end
			end
		end	
	end
end

function setActive(self, bool, damage, dmgType)
	if type(bool) == "boolean" then

		if type(dmgType) == "string" and type(damage) == "number" then
			wall_damage = damage
			damage_type = dmgType
		end
		
		if bool then
		 party.party:addConnector("onMove", self.go.id, "dmgWall")
		 return
		end
		party.party:removeConnector("onMove", self.go.id, "dmgWall")			
	end
end

function setSelective(self,bool)
	if type(bool) == "boolean" then
			selective = bool
	end
	print(selective, bool)
end

Re: Ask a simple question, get a simple answer

Posted: Fri May 29, 2015 8:36 pm
by spectre900
Can ammo (say arrows) be able to be programmed to have a chance to break when hitting something?

Re: Ask a simple question, get a simple answer

Posted: Fri May 29, 2015 9:51 pm
by Zo Kath Ra
spectre900 wrote:Can ammo (say arrows) be able to be programmed to have a chance to break when hitting something?
Do you want the arrow to disappear from the game, or do you want it to turn into a broken_arrow object that can be repaired later? I can only help you with the former:

Code: Select all

defineObject{
    name = "fragile_arrow",
    baseObject = "base_item",
    components = {
        {
            class = "Model",
            model = "assets/models/items/arrow.fbx",
        },
        {
            class = "Item",
            uiName = "Fragile Arrow",
            gfxIndex = 107,
            impactSound = "impact_arrow",
            stackable = true,
            sharpProjectile = false,
            projectileRotationY = 90,
            weight = 0.1,
            onThrowAttackHitMonster = function(self, monster)
                if (math.random() <= 0.5) then
                    hudPrint("The arrow breaks!")
                    self.go:destroyDelayed()
                end
            end,
        },
        {
            class = "AmmoItem",
            ammoType = "arrow",
        },
    },
}
Problems:
- the arrow only has a chance of breaking when it hits a monster (not if you miss and the arrow falls to the ground in front of the monster, or if you hit a wall)
- if you set "sharpProjectile = true", the game will crash when the arrow is destroyed

The function "onThrowAttackHitMonster" gets triggered if you *fire* the arrow at a monster and hit (despite the function's name)

Re: Ask a simple question, get a simple answer

Posted: Fri May 29, 2015 10:03 pm
by spectre900
Zo Kath Ra wrote:
spectre900 wrote:Can ammo (say arrows) be able to be programmed to have a chance to break when hitting something?
Do you want the arrow to disappear from the game, or do you want it to turn into a broken_arrow object that can be repaired later? I can only help you with the former:

Code: Select all

defineObject{
	name = "fragile_arrow",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/arrow.fbx",
		},
		{
			class = "Item",
			uiName = "Fragile Arrow",
			gfxIndex = 107,
			impactSound = "impact_arrow",
			stackable = true,
			sharpProjectile = false,
			projectileRotationY = 90,
			weight = 0.1,
            onThrowAttackHitMonster = function(self, monster)
                if (math.random() <= 0.5) then
                    hudPrint("The arrow breaks!")
                    self.go:destroyDelayed()
                end
            end,
		},
		{
			class = "AmmoItem",
			ammoType = "arrow",
		},
	},
}
Problems:
- the arrow only has a chance of breaking when it hits a monster (not if you miss and the arrow falls to the ground in front of the monster, and not if you hit a wall)
- if you set "sharpProjectile = true", the game will crash when the arrow is destroyed

The function "onThrowAttackHitMonster" gets triggered if you *fire* the arrow at a monster and hit (despite the function's name)
Dude that is perfect, exactly what I needed! Many thanks. :D

Re: Ask a simple question, get a simple answer

Posted: Sun May 31, 2015 4:17 pm
by AndakRainor
Is it possible to dynamically update any visual element of a custom condition ?

I tried to change the icon or description field but it raises a "read only" error. I would like to update the description, if possible, as the game does for example for the rage condition (it shows the detail of the bonus strength in real time). It would be used to shows stats details or time remaining, or even changing the icon when the condition is about to expire.

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 03, 2015 1:37 am
by spectre900
Another question. is there any way to make a character class with a trait for "CastSpell" weapons such as the fire blade, similar to that of the Fighter class?

I tried applying the Fighter trait to a custom class but that trait doesn't apply to spell casting weapons which is what I wanted to the class to use. (sure the charge time isn't that horribly slow but less cost and faster casting would have been a good trait for the class and an actual reason to pick it.)

Also is it possible to even make custom traits for character classes?

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 03, 2015 8:45 pm
by zimberzimber
A few questions here: (I'm not sure how simple they are or how simple will the answer be, but hey! Why not?)

1) How do I create a script that would check each character for a certain property* but so it will skip on empty character slots?
* - level, race, class, perks, etc...

2) How do I force on a party to delete all characters and replace them all with one (or more) characters so there will be 3 empty slots and 1 character inside the 1st slot?

3) How would I add a character to a party in case there is an empty slot and set their level to the parties average?

4) How to I print a message on the middle of the screen like the one when you are fighting the Lyndworm, and is it possible to give it a different fade-in effect and/or change its color and/or font?

5) If possible, how do you change the hudPrint text color and/or font?

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 03, 2015 10:19 pm
by Duncan1246
zimberzimber wrote:
2&3: How do I force on a party to delete all characters and replace them all with one (or more) characters so there will be 3 empty slots and 1 character inside the 1st slot?
How would I add a character to a party in case there is an empty slot and set their level to the parties average?
See this thread:

viewtopic.php?f=22&t=8464&hilit=replace ... =10#p86822)
4) How to I print a message on the middle of the screen like the one when you are fighting the Lyndworm, and is it possible to give it a different fade-in effect and/or change its color and/or font?
See this thread: viewtopic.php?f=22&t=9128&hilit=grim+tk&start=80#p92839 and the tool made by JohnWordsworth http://www.nexusmods.com/legendofgrimrock2/mods/23/?

For the others, I think some answers can be found in the threads also

Duncan