Page 375 of 396

Re: Ask a simple question, get a simple answer

Posted: Wed Mar 10, 2021 2:22 pm
by Isaac
The object's offset vector could be used for this, or even the 2D subtileOffset.

Code: Select all

setSubtileOffset(x,y)
This moves an object along a 2D x & y grid in a cell, but it's not a function of the projectile component. You would have to obtain the projectile object ID.

*This is easier if using a script instead of a spawner object.

Example: place in script_entity, and connect a timer; timer.facing is the direction of projectile.

Code: Select all

function shoot(self) 
	
	local fireball = self.go:spawn("fireball_small")
	fireball.projectile:setIgnoreEntity(party)
	fireball:setWorldPositionY(1.5)
	fireball:setSubtileOffset(.8,-.5)

end
Image
kelly1111 wrote: Wed Mar 10, 2021 12:50 pmI need a particle that travels close to the wall when fired from a spawner.
How exactly is this to be used? If it's a visual effect, then a custom animation (via Blender) would give more control.

Re: Ask a simple question, get a simple answer

Posted: Wed Mar 10, 2021 6:59 pm
by kelly1111
Thanks Isaac. I have made a wall object with a long indent in it. I want the projectile / lightsource to travel along that path creating an alternative moving light source effect. But I am now wondering if this will work on a wall object because of the projectile collider component....

I got it working the way I want it

Re: Ask a simple question, get a simple answer

Posted: Wed Mar 10, 2021 9:09 pm
by Isaac
kelly1111 wrote: Wed Mar 10, 2021 6:59 pm I got it working the way I want it
8-)

Components can be removed if they are a problem.

The object's position can be determined (or just influenced) with scripting.
Image

But for what you might be doing, a custom animated wall asset could be the best.

Check out the Dark Seal and the in the ORRR3 mod.

Image

Re: Ask a simple question, get a simple answer

Posted: Fri Mar 12, 2021 11:15 am
by Lorial
How can you create a nightsight potion that casts the light spell while consuming the item (in hand and inventory)?

My version is crap as it requires the necessary skill of the spell and teaches the spell which is added to the trait window. Other versions with "primaryAction" let me use it indefinitely (unless I used charges) or only turned into an empty flask when used from within the inventory. Usually I used "setCondition" for these purposes, but can a light spell be a condition?!

SpoilerShow

Code: Select all

defineObject{
	name = "flask_light",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/flask.fbx",
		},
		{
			class = "Item",
			uiName = "Nightsight Potion",
			gfxIndex = 144,
			weight = 0.3,
			traits = { "potion" },
			ConvertToItemOnImpact = "dispel_blast",
		},
		{
			class = "UsableItem",
			sound = "consume_potion",
--			emptyItem = "flask",
			onUseItem = function(self, champion)
				if champion:isAlive() then
				champion:castSpell(25)
				end
			end,
		},

	},
}

Re: Ask a simple question, get a simple answer

Posted: Fri Mar 12, 2021 11:18 pm
by ratman
You could define a new spell that has no requirements and is hidden.

Code: Select all

defineSpell{
	name = "light_potion_spell",
	uiName = "Light",
	gesture = 12321,
	manaCost = 0,
	onCast = "light",
	skill = "concentration",
	--requirements = { "concentration", 2 },
	icon = 58,
	spellIcon = 18,
	description = "Conjures a dancing ball of light that illuminates your path.",
	hidden = true,
}

Re: Ask a simple question, get a simple answer

Posted: Sat Mar 13, 2021 6:23 am
by Isaac
The custom spell (with impossible gesture) would certainly do it, but the nature of the effect is well suited to a being a character condition. As a condition, it can be easily applied to any champion, and effectively handles itself after that; it can also be detected (per champion). Since this is a potion, several PCs might be using them at the same time, whether deliberately or accidental. So the effect should take duplicates into account.

A condition automatically applies an effect icon to the champion's portrait for its duration, and has built in functions to place start, middle, and ending code for both the principle effect, and any cosmetic polishing to it.

Code: Select all

--Place this in one of the starting scripts; eg. spells.lua or other
defineCondition{
   name = "nightvision",
   uiName = "Nightvision",
   description = "Temporarily enhances the ability to see in the dark.",
   icon = 7,										--[icon & iconAtlas can reference a custom image for the portrait-overlay]--
   iconAtlas = "assets/textures/gui/conditions.tga",	--
   beneficial = true,
   harmful = false,
   tickInterval = .05,
   onStart = function(self, champion)
	    if not party.nightsight then party:createComponent("Light", "nightsight") 
  	      party.nightsight:setOffset(vec(0,1.3,-1)) ---------------[Position of light source]--
	   	  party.nightsight:setType("spot")
	   	  party.nightsight:setSpotAngle(117)
	   	  party.nightsight:setSpotSharpness(0)
	   	  party.nightsight:setRange(9)
	   	 end
	   	self:setDuration(60) -----------------------------------[Default duration of nighvision effect]--
   		playSound("spell_out_of_energy")     
   end,
   onStop = function(self, champion)
   		--OPTIONAL message
   			hudPrint(champion:getName():capitalize().."\'s nightvision has expired")
   		--

   		local count = 0
   			for x = 1, 4 do
   				if party.party:getChampion(x):hasCondition("nightvision") then
   					count = count + 1 
   				end
   			end	
   	   		if count < 2 then party:removeComponent("nightsight") end
   	  playSound("spell_expires")
   end,
   onTick = function(self, champion) 
   		local count = 0
   			for x = 1, 4 do
   				if party.party:getChampion(x):hasCondition("nightvision") then
   					count = count + 1 
   				end
   			end	
   	   		if count < 2 then 
		   		if Config.getRenderingQuality()>1 then
			   		if party.nightsight then 
			   			party.nightsight:setColor(vec(5,20,7)) --------------------------------[green tint]--
			   			local jitter = math.abs(math.sin(self:getDuration()*.5)*2)  ----[variable attenuation of the light]--
			   			party.nightsight:setBrightness(jitter)
			   		end
			   	end
			end   			
   end,
}

defineObject{
	name = "potion_nightvision",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/flask.fbx",
		},
		{
			class = "Item",
			uiName = "Nightvision Potion",
			gfxIndex = 146,
			weight = 0.3,
			stackable = true,
			traits = { "potion" },
		},
		{
			class = "UsableItem",
			sound = "consume_potion",
			onUseItem = function(self, champion)
				champion:setCondition('nightvision')
			end,
		},
	},
}

Re: Ask a simple question, get a simple answer

Posted: Sat Mar 13, 2021 8:03 am
by Lorial
Thanks a bunch for that, guys.

Just had the same idea with no requirements today, the gesture is a nice addition indeed.
I have used numerous custom conditions for 1, 2 or all 4 chars, but I never managed to connect a consumable item with casting a spell. Creating complex conditions that replicate a spell is way out of my league. Time to play around with these a bit and see what sticks.

Re: Ask a simple question, get a simple answer

Posted: Sun Mar 14, 2021 11:10 pm
by Eleven Warrior
Isaac wrote: Sat Mar 13, 2021 6:23 am The custom spell (with impossible gesture) would certainly do it, but the nature of the effect is well suited to a being a character condition. As a condition, it can be easily applied to any champion, and effectively handles itself after that; it can also be detected (per champion). Since this is a potion, several PCs might be using them at the same time, whether deliberately or accidental. So the effect should take duplicates into account.

A condition automatically applies an effect icon to the champion's portrait for its duration, and has built in functions to place start, middle, and ending code for both the principle effect, and any cosmetic polishing to it.

Code: Select all

--Place this in one of the starting scripts; eg. spells.lua or other
defineCondition{
   name = "nightvision",
   uiName = "Nightvision",
   description = "Temporarily enhances the ability to see in the dark.",
   icon = 7,										--[icon & iconAtlas can reference a custom image for the portrait-overlay]--
   iconAtlas = "assets/textures/gui/conditions.tga",	--
   beneficial = true,
   harmful = false,
   tickInterval = .05,
   onStart = function(self, champion)
	    if not party.nightsight then party:createComponent("Light", "nightsight") 
  	      party.nightsight:setOffset(vec(0,1.3,-1)) ---------------[Position of light source]--
	   	  party.nightsight:setType("spot")
	   	  party.nightsight:setSpotAngle(117)
	   	  party.nightsight:setSpotSharpness(0)
	   	  party.nightsight:setRange(9)
	   	 end
	   	self:setDuration(60) -----------------------------------[Default duration of nighvision effect]--
   		playSound("spell_out_of_energy")     
   end,
   onStop = function(self, champion)
   		--OPTIONAL message
   			hudPrint(champion:getName():capitalize().."\'s nightvision has expired")
   		--

   		local count = 0
   			for x = 1, 4 do
   				if party.party:getChampion(x):hasCondition("nightvision") then
   					count = count + 1 
   				end
   			end	
   	   		if count < 2 then party:removeComponent("nightsight") end
   	  playSound("spell_expires")
   end,
   onTick = function(self, champion) 
   		local count = 0
   			for x = 1, 4 do
   				if party.party:getChampion(x):hasCondition("nightvision") then
   					count = count + 1 
   				end
   			end	
   	   		if count < 2 then 
		   		if Config.getRenderingQuality()>1 then
			   		if party.nightsight then 
			   			party.nightsight:setColor(vec(5,20,7)) --------------------------------[green tint]--
			   			local jitter = math.abs(math.sin(self:getDuration()*.5)*2)  ----[variable attenuation of the light]--
			   			party.nightsight:setBrightness(jitter)
			   		end
			   	end
			end   			
   end,
}

defineObject{
	name = "potion_nightvision",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/flask.fbx",
		},
		{
			class = "Item",
			uiName = "Nightvision Potion",
			gfxIndex = 146,
			weight = 0.3,
			stackable = true,
			traits = { "potion" },
		},
		{
			class = "UsableItem",
			sound = "consume_potion",
			onUseItem = function(self, champion)
				champion:setCondition('nightvision')
			end,
		},
	},
}
Could you do the same for a fireball potion to Issac? Player drinks potion and launches a fireball.

Re: Ask a simple question, get a simple answer

Posted: Mon Mar 15, 2021 12:21 am
by Zo Kath Ra
Eleven Warrior wrote: Sun Mar 14, 2021 11:10 pm Could you do the same for a fireball potion to Issac? Player drinks potion and launches a fireball.
Potion of Fire Breathing?

Re: Ask a simple question, get a simple answer

Posted: Mon Mar 15, 2021 8:05 am
by Eleven Warrior
yeah