Page 5 of 6

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Wed Feb 18, 2015 6:06 am
by akroma222
Ahh good to know, thank you guys

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Sun May 29, 2016 9:41 am
by THOM
I was wondering if anyone ever made a ranged weappon for underwater use?

Would be very interested in how it has been done.

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Mon May 30, 2016 7:37 pm
by Zo Kath Ra
THOM wrote:I was wondering if anyone ever made a ranged weappon for underwater use?

Would be very interested in how it has been done.
Just add the "aquatic" trait.

Example of a throwing weapon:

Code: Select all

defineObject{
	name = "rock_underwater",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/rock.fbx",
		},
		{
			class = "Item",
			uiName = "Rock (underwater)",
			gfxIndex = 45,
			impactSound = "impact_blunt",
			stackable = true,
			projectileRotationSpeed = 10,
			projectileRotationZ = -30,
			weight = 0.7,
			traits = { "throwing_weapon", "aquatic" },
		},
		{
			class = "ThrowAttack",
			attackPower = 4,
			cooldown = 4,
		},
		{
			class = "AmmoItem",
			ammoType = "rock",
		},
	},
	tags = { "weapon", "weapon_throwing" },
}
Example of a missile weapon:

Code: Select all

defineObject{
	name = "short_bow_underwater",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/short_bow.fbx",
		},
		{
			class = "Item",
			uiName = "Short Bow (underwater)",
			gfxIndex = 13,
			gfxIndexPowerAttack = 466,
			impactSound = "impact_blunt",
			weight = 1.0,
			traits = { "missile_weapon", "aquatic" },
		},
		{
			class = "RangedAttack",
			attackPower = 12,
			cooldown = 4,
			attackSound = "swipe_bow",
			ammo = "arrow",
			powerAttackTemplate = "volley",
		},
	},
	tags = { "weapon", "weapon_missile" },
}
The missile weapon's ammunition does not need the "aquatic" trait.

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Mon May 30, 2016 9:00 pm
by THOM
Thank you for responding. I was aware of the aquatic trait thing.

But in my opinion it is a bit weird to fire an arrow with a bow underwater.

What I had in mind was, if anyone made a weapon which fires not an arrow or a rock but - let's say - a waterbubble or a waterjet... ??

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Wed Jun 22, 2016 2:56 pm
by THOM
Okay, after all I made an underwater ranged weapon.

Image

It shoots a ball of "compressed water" and works only under water.

Thanks to minmay for the projectile-code.

Code: Select all

defineObject{
	name = "water_shooter",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/revolver.fbx",
			material = "zarchton_wand",
		},
		{
			class = "Item",
			uiName = "Water Shooter",
			description = "A strange mechanics makes this weapon compressing water and launching it in some kind of a jet.",
			gfxAtlas = "mod_assets/textures/iconatlas/iconatlas.dds",
			gfxIndex = 33,
			weight = 1.5,
			traits = { "weapon", "aquatic" },
			primaryAction = "waterbolt",
		},
		{
			class = "ItemAction",
			name = "waterbolt",
			uiName = "Water Bolt",
			cooldown = 5,
			onAttack = function(self, champion, slot, chainIndex)
			   local tile = party.map:getAutomapTile(party.x,party.y)
            		   if tile == 2 then
				local spl = spawn ("water_bolt",party.level,party.x,party.y,party.facing,party.elevation)
				spl.projectile:setIgnoreEntity(party)
          			local ord = champion:getOrdinal()
          			spl.projectile:setCastByChampion(ord)
          			local left = nil
        			for i = 1,4 do
    			       	   if party.party:getChampion(i):getOrdinal() == ord then
  			            	left = i == 1 or i == 3
  			            	break
 			           end
  			        end
  			        local wpos = party:getWorldPosition()
   			       	local dx = nil
 			        local dz = nil
   			       	if party.facing == 0 then
   			          dx = left and -0.1 or 0.1
  			          dz = -1
 			        elseif party.facing == 1 then
			          dz = left and 0.1 or -0.1
 			          dx = -1
 			        elseif party.facing == 2 then
     			          dx = left and 0.1 or -0.1
     			          dz = 1
     			        else -- party.facing == 3
     			          dz = left and -0.1 or 0.1
    			          dx = 1
  			        end
  			        spl:setWorldPosition(vec(wpos[1]+dx,wpos[2]+1.35,wpos[3]+dz))
			   else
				hudPrint("There is no water around that could be compressed by the shooter.")
			   end
			end,
		},
	},
	tags = { "weapon" },
}



defineObject{
  name = "water_bolt",
  baseObject = "base_spell",
  components = {
    		{
      			class = "Particle",
      			particleSystem = "water_bolt", 
    		},
		{
			class = "Light",
			color = vec(0.25, 0.5, 1),
			brightness = 3,
			range = 2,
			castShadow = true,
		},
		{
			class = "Projectile",
			spawnOffsetY = 1.35,
			velocity = 10,
			radius = 0.1,
			hitEffect = "water_bolt_blast",
		},
		{
			class = "Sound",
			sound = "blob",
		},
		{
			class = "Sound",
			name = "launchSound",
			sound = "dispel_launch", 
		},
  },
}



defineObject{
	name = "water_bolt_blast",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "water_bolt_hit",
			destroyObject = true,
		},
		{
			class = "Light",
			color = vec(0.25, 0.5, 1),
			brightness = 5,
			range = 5,
			fadeOut = 0.5,
			disableSelf = true,
		},
		{
			class = "TileDamager",
			attackPower = 12,
			damageType = "cold",
			sound = "dispel_hit",  --"water_hit_large", 
			screenEffect = "water_bolt_screen",
		},
	},
}


defineParticleSystem{
	name = "water_bolt",
	emitters = {
		-- projectile
		{
			emissionRate = 400,
			emissionTime = 0,
			maxParticles = 1800,
			boxMin = { 0, 0, 0},
			boxMax = { 0, 0, 0},
			sprayAngle = {0,360},
			velocity = {0.1,0.2},
			objectSpace = false,
			texture = "assets/textures/particles/bubble.tga",
			lifetime = {0.2,0.4},
			color0 = {0.58, 0.588, 0.6},
			opacity = 0.45,
			fadeIn = 0.01,
			fadeOut = 0.6,
			size = {0.28, 0.38},
			gravity = {0,0,0},
			airResistance = 0.1,
			rotationSpeed = 3,
			blendMode = "Additive",
		},
		--bubbles
 		{
			 emissionRate = 62,
			 emissionTime = 0,
			 spawnBurst = false,
			 maxParticles =3000,
			 boxMin = {-0.35,-0.3,-0.35},
			 boxMax = {0.35,0.3,0.35},
			 objectSpace = false,
			 sprayAngle = {0,0}, 
			 velocity = {0.1,0.2},  
			 texture = "assets/textures/particles/bubble.tga",
 			 lifetime = {0.5, 3},
			 colorAnimation = false,
			 color0 = {0.7, 0.85, 0.9},
 			 opacity = 0.4,
			 fadeIn = 0.1,
			 fadeOut = 0.4,
 			 size = {0.03, 0.04},
			 gravity = {0,0.01,0},
 			 airResistance = 1,
 			 rotationSpeed = 0.7,
			 blendMode = "Additive",
		},
		--spray
		 {
			 emissionRate = 100,
			 emissionTime = 0,
			  spawnBurst = false,
			 maxParticles =1500,
			 boxMin = {-0.2,-0.3,-0.2},
			  boxMax = {0.2,0.3,0.2},
			 objectSpace = false,
			  sprayAngle = {0,120},
			 velocity = {-1,-1.5},
 			 texture = "assets/textures/particles/glitter_silver.tga",
 			 lifetime = {0.9, 1.5},  
			 colorAnimation = false,
			 color0 = {0.5, 0.6, 1},
 			 opacity = 0.65,
			 fadeIn = 0.1,
			 fadeOut = 0.5,
 			 size = {0.06, 0.12},
			 gravity = {0,2,0},
 			 airResistance = 1,
 			 rotationSpeed = 0.7,
			 blendMode = "Additive",
		},
	}
}



defineParticleSystem{
	name = "water_bolt_hit",
	emitters = {
		-- burst
		{
			spawnBurst = true,
			maxParticles = 20,
			sprayAngle = {0,360},
			velocity = {0.2,0.9},
			objectSpace = true,
			texture = "assets/textures/particles/bubble.tga",
			lifetime = {0.5,1.35},
			color0 = {0.7, 0.85, 0.9},
			opacity = 0.4,
			fadeIn = 0.05,
			fadeOut = 0.5,
			size = {0.2, 0.4},
			gravity = {0,0,0},
			airResistance = 0.5,
			rotationSpeed = 1,
			blendMode = "Additive",
		},
		--spray
		 {
			 emissionRate = 900,
			 emissionTime = 0,
			 spawnBurst = true,
			 maxParticles =1500,
			 boxMin = {-0.2,-0.5,-0.2},
			 boxMax = {0.2,0.2,0.2},
			 objectSpace = false,
			 sprayAngle = {0,120},
			 velocity = {-1,-1.5},
			 texture = "assets/textures/particles/bubble.tga",
 			 lifetime = {1.1, 4},
			 colorAnimation = false,
			 color0 = {0.7, 0.85, 0.9},
 			 opacity = 0.75,
			 fadeIn = 1,
			 fadeOut = 2.7,
 			 size = {0.01, 0.04},
			 gravity = {0,2,0},
 			 airResistance = 1,
 			 rotationSpeed = 0.7,
			 blendMode = "Additive",
		},
		-- dust
		{
			spawnBurst = true,
			maxParticles = 20,
			sprayAngle = {0,360},
			velocity = {0.2,0.9},
			objectSpace = true,
			texture = "assets/textures/particles/fog.tga",
			lifetime = {0.2,0.7},
			color0 = {0.8, 1, 1.3},
			opacity = 0.8, --0.4,
			fadeIn = 0.05,
			fadeOut = 0.3,
			size = {0.2, 0.8},
			gravity = {0,0,0},
			airResistance = 0.5,
			rotationSpeed = 2,
			blendMode = "Translucent",
		},
		-- flash
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,-0.1},
			boxMax = {0,0,-0.1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {0.5, 0.5},
			colorAnimation = false,
			color0 = {0.42, 0.42, 0.6},
			opacity = 0.6,
			fadeIn = 0.01,
			fadeOut = 0.5,
			size = {1, 1},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 2,
			blendMode = "Additive",
		}
	}
}

defineParticleSystem{
	name = "water_bolt_screen",
	emitters = {
                --burst
		{
			spawnBurst = true,
			maxParticles = 300,
			sprayAngle = {0,360},
			velocity = {0,0.3},
			boxMin = {-1.1,-0.9,1},
			boxMax = {1.1,0.9,1},
			objectSpace = true,
			texture = "assets/textures/particles/bubble.tga",
			lifetime = {0.3, 0.5},
			color0 = {0.7, 0.85, 0.9},
			opacity = 0.38,
			fadeIn = 0.001,
			fadeOut = 1,
			size = {0.005, 0.3},
			gravity = {0,0,0},
			airResistance = 0.5,
			rotationSpeed = 6,
			blendMode = "Additive",
		},
		--spray
		 {
			 emissionRate = 900,
			 emissionTime = 0,
			 spawnBurst = true,
			 maxParticles =1500,
			 boxMin = {-0.2,-1,-0.2},
			 boxMax = {0.2,0.2,0.2},
			 objectSpace = false,
			 sprayAngle = {0,120},
			 velocity = {-1,-1.5},
 			 texture = "assets/textures/particles/bubble.tga",
 			 lifetime = {100, 100},
			 colorAnimation = false,
			 color0 = {0.7, 0.85, 0.9},
 			 opacity = 0.65,
			 fadeIn = 1,
			 fadeOut = 2.5,
 			 size = {0.03, 0.06},
			 gravity = {0,2,0},
 			 airResistance = 1,
 			 rotationSpeed = 0.7,
			 blendMode = "Additive",
		},	
		-- dust
		{
			spawnBurst = true,
			maxParticles = 20,
			sprayAngle = {0,360},
			velocity = {0.2,0.9},
			objectSpace = true,
			texture = "assets/textures/particles/fog.tga",
			lifetime = {0.2,0.7},
			color0 = {0.8, 1, 1.3},
			opacity = 0.8,
			fadeIn = 0.05,
			fadeOut = 0.3,
			size = {0.8, 1.7},
			gravity = {0,0,0},
			airResistance = 0.5,
			rotationSpeed = 2,
			blendMode = "Translucent",
		},
		-- flash
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,1},
			boxMax = {0,0,1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {0.5, 0.5},
			colorAnimation = false,
			color0 = {1.2,1.2,1.2},
			opacity = 0.8,
			fadeIn = 0.001,
			fadeOut = 0.1,
			size = {3.2, 3.2},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 2,
			blendMode = "Additive",
			objectSpace = true,
		}
	}
}

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Thu Jun 23, 2016 8:53 am
by Isaac
"compressed water"

Water cannot compress [afaik].

*I wonder... if the weapon is intended to be used underwater, would they not design the machine to take in the surrounding water as ammo?
(Kind of like a Jet-Ski.)

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Thu Jun 23, 2016 9:23 am
by THOM
Isaac wrote:Water cannot compress [afaik].
We are talking of a world with ogres, fireballs and bear-potions. ;)

But I'm open to every other suggestion...
Isaac wrote:*I wonder... if the weapon is intended to be used underwater, would they not design the machine to take in the surrounding water as ammo?
(Kind of like a Jet-Ski.)
In some kind it alredy does: It won't work over water. My aim wasn't to create also a type of ammo that you have to have to use it.

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Thu Jun 23, 2016 9:47 am
by minmay
Isaac wrote:"compressed water"

Water cannot compress [afaik].
https://en.wikipedia.org/wiki/Propertie ... essibility

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Thu Jun 23, 2016 9:25 pm
by Isaac
minmay wrote:
Isaac wrote:"compressed water"

Water cannot compress [afaik].
https://en.wikipedia.org/wiki/Propertie ... essibility
I meant practical of course.

Re: [Solved/Item/Spell] Way to tell if party is underwater?

Posted: Mon Jul 04, 2016 1:52 am
by Eleven Warrior
Well done Thom. :D

I love this gun man. Is it ok to use this in my Mod??