Having some trouble with shootProjectile
Having some trouble with shootProjectile
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("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
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
Notice how it asks for the name of an item. Fireballs are not items.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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Having some trouble with shootProjectile
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.minmay wrote:Notice how it asks for the name of an item. Fireballs are not items.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.
Re: Having some trouble with shootProjectile
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
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...
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Having some trouble with shootProjectile
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.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 ProjectileComponentCode: 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
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
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
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!
..It is flying!... just.. sideways....
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
}
},
}
..It is flying!... just.. sideways....
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Having some trouble with shootProjectile
Have you guys tried adding a RangedAttack component to the item def??
EDIT - Dont do that^^ that was a very bad idea
EDIT - Dont do that^^ that was a very bad idea
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Having some trouble with shootProjectile
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.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 ProjectileComponentCode: 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...
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 ?