Page 1 of 4

Having some trouble with shootProjectile

Posted: Sun Nov 09, 2014 6:26 pm
by MrChoke
I keep getting an "invalid arch" error when it executes this:

shootProjectile("fireball_large", self.go.level, self.go.x, self.go.y+3, 0, 10, 0, 0, 0, 0, 0, 3, nil, false)

I know the level, x and y values is an open square (its 3 squares behind the button that is "self")

Maybe it has something to do with the offset values? I set zeros because I am not sure what to set. The reference says it is this:
offsetX,offsetY,offsetZ: 3D offset in world space from the center of cell.

If it relative you would think zeros would work. Has anyone used this command yet?

"shootProjectile" does not work

Posted: Sun Nov 09, 2014 11:01 pm
by MrChoke
After far too much trial and error trying to get this command to work, I declare this command BROKEN. Nothing works. Period. Didn't Grimrock 1 have a command like this? Maybe I will see if I can find some examples from 1. Not that it matters.

Re: Having some trouble with shootProjectile

Posted: Sun Nov 09, 2014 11:12 pm
by minmay
shootProjectile(projectile, level, x, y, direction, speed, gravity, velocityUp, offsetX, offsetY, offsetZ, attackPower, ignoreEntity, fragile, championOrdinal)
Shoots a projectile item. The parameters are:

projectile: the name of the item to shoot.
level,x,y: the initial position of the projectile in a level.
direction: the shooting direction (0=north, 1=east, 2=south, 3=west).
speed: the speed of the projectile (metres/second). Typical values around 10.
gravity: the gravity force in y-direction. Typical values around 0.
velocityUp: the initial velocity in y-direction. Typically set to 0.
offsetX,offsetY,offsetZ: 3D offset in world space from the center of cell.
attackPower: attack power of the projectile.
ignoreEntity: the entity to be ignored for collisions (or nil if the entity should not ignore any collisions).
fragile: a boolean flag, if set the projectile is destroyed on impact.
championOrdinal: a champion ordinal number, used for dealing experience points. This parameter is optional.
Notice how it asks for the name of an item. Fireballs are not items.

Re: Having some trouble with shootProjectile

Posted: Sun Nov 09, 2014 11:26 pm
by MrChoke
minmay wrote:
shootProjectile(projectile, level, x, y, direction, speed, gravity, velocityUp, offsetX, offsetY, offsetZ, attackPower, ignoreEntity, fragile, championOrdinal)
Shoots a projectile item. The parameters are:

projectile: the name of the item to shoot.
level,x,y: the initial position of the projectile in a level.
direction: the shooting direction (0=north, 1=east, 2=south, 3=west).
speed: the speed of the projectile (metres/second). Typical values around 10.
gravity: the gravity force in y-direction. Typical values around 0.
velocityUp: the initial velocity in y-direction. Typically set to 0.
offsetX,offsetY,offsetZ: 3D offset in world space from the center of cell.
attackPower: attack power of the projectile.
ignoreEntity: the entity to be ignored for collisions (or nil if the entity should not ignore any collisions).
fragile: a boolean flag, if set the projectile is destroyed on impact.
championOrdinal: a champion ordinal number, used for dealing experience points. This parameter is optional.
Notice how it asks for the name of an item. Fireballs are not items.
If I put an invalid item name in there it tells me so saying "Invalid Type". I need an example of it working. I just hunted down 5 examples from Grimrock 1 too since the command parameters didn't change and none of them work either.

Re: Having some trouble with shootProjectile

Posted: Mon Nov 10, 2014 1:28 am
by Prozail
My guess is it's a leftover from LoG1 that is not used anymore since the new component system, and should simply be removed from the scripting reference.

You can do the same thing, albeit a bit more verbose, like this. Just check the reference for ProjectileComponent

Code: Select all

local s = spawn("poison_bolt",sender.go.level,sender.go.x,sender.go.y,sender.go.facing,0)
	s.projectile:setIgnoreEntity(party)
	s.projectile:setAttackPower(10)
	print(s:getWorldPosition())
	s:setWorldPosition(13.5,1.35,28,5,0) -- just toying around with values here... 

Re: Having some trouble with shootProjectile

Posted: Mon Nov 10, 2014 2:42 am
by MrChoke
Prozail wrote:My guess is it's a leftover from LoG1 that is not used anymore since the new component system, and should simply be removed from the scripting reference.

You can do the same thing, albeit a bit more verbose, like this. Just check the reference for ProjectileComponent

Code: Select all

local s = spawn("poison_bolt",sender.go.level,sender.go.x,sender.go.y,sender.go.facing,0)
	s.projectile:setIgnoreEntity(party)
	s.projectile:setAttackPower(10)
	print(s:getWorldPosition())
	s:setWorldPosition(13.5,1.35,28,5,0) -- just toying around with values here... 
Thanks Prozail! That works great. I gotta start looking at the components closer. Thing is though, if shootProjectile is not valid in LoG2 it really needs to be removed from the scripting reference. It will only cause confusion.

Re: Having some trouble with shootProjectile

Posted: Fri Nov 14, 2014 12:13 pm
by Aisuu
I was messing with projectile component too. It work all right with spells. But I cant get it work with arrow.
Arrow trap is common in most dungeons so I guess it would by great idea to implement it.
It was easy with shootProjectile in LOG1, but in LOG2 Iam lost :(

Re: Having some trouble with shootProjectile

Posted: Fri Nov 14, 2014 2:30 pm
by Prozail
Yup.. came to the same conclusion.. fireing actual items is... strange.

This is as far as i've gotten, so if anyone knows what's missing please say!

Code: Select all


defineObject{
	name ="projectile_arrow",
	baseObject = "arrow",
	components = {
		{
			class = "Item",
			weight = 0.1,
			projectileRotationY = 90,
			sharpProjectile = true,
		},
		{
			class = "Projectile",
			spawnOffsetY = 1.0,
			velocity = 15,
			fallingVelocity = 1,
			angularVelocity = 0,
			gravity = 1,
			radius = 0.5,
			hitEffect = "hit_blood_small",
			attackPower = 10,
			castByChampion = true,	
			onProjectileHit = function(self, what, entity)
				print("onHit",self,what,entity)
			end
		}
	},
}
Image
..It is flying!... just.. sideways....

Re: Having some trouble with shootProjectile

Posted: Sat Nov 15, 2014 1:18 am
by akroma222
Have you guys tried adding a RangedAttack component to the item def??

EDIT - Dont do that^^ that was a very bad idea

Re: Having some trouble with shootProjectile

Posted: Wed Nov 26, 2014 3:22 pm
by AndakRainor
Prozail wrote:My guess is it's a leftover from LoG1 that is not used anymore since the new component system, and should simply be removed from the scripting reference.

You can do the same thing, albeit a bit more verbose, like this. Just check the reference for ProjectileComponent

Code: Select all

local s = spawn("poison_bolt",sender.go.level,sender.go.x,sender.go.y,sender.go.facing,0)
	s.projectile:setIgnoreEntity(party)
	s.projectile:setAttackPower(10)
	print(s:getWorldPosition())
	s:setWorldPosition(13.5,1.35,28,5,0) -- just toying around with values here... 
Well shootProjectile is documented in the global functions examples of the official scripting reference of Grimrock 2. It would be odd if it was there but deprecated.
I tried to build a simple spell that throws a rock, and also tried examples from Grimrock 1 mods, but so far nothing works...
I managed to launch several magic projectiles with your spawn code, fireballs, lightning bolts, poison bolts, ice bolts, etc... But all the projectile items such as "rock" are not considered projectile in Grimrock 2 !!! So s.projectile is an invalid reference if you replace "poison_bolt" by "rock" in your example. What am I missing ?

Also one of my goals would be to build spells similar to meteor storm for the other magic schools, such as the multiple poison bolts that monsters use in the last dungeon.
Do you know how to delay and move the start positions of multiple projectiles to recreate the meteor spell ?