[Solved] Casting custom spells like built in spells
Posted: Mon Feb 02, 2015 2:51 am
So I am creating some new spells. I have a new fireball for example. It is not a built-in spell so I define its onCast() as a function having parms (champion, x, y, dir, elev, skillLevel)
Since we do not have a working shootProjectile() function to call, I spawn the new fireball object using the x and y specified.
Realization number 1: You cannot use the same X and Y specified or the fireball explodes in your tile!
That is a bit annoying but I can use getForward() with the direction given and have it spawn in the tile in front of the party.
Realization 2: Now the fireball casts and looks good, except it clearly has spawned in the next tile and does not look at all like it was cast by a champion. You look at the built-in spells and they spawn directly in front of the champion who cast it. This takes into account what position in the party he is in as well.
Now I am getting annoyed. I can do setWorldPosition() calls on the newly spawned fireball to make it appear closer to the party but how do I put it in front of the champion who cast it?
Realization 3: The Champion component does not return the position he is in in the party!?!?!? I can get the ordinal but that is different if the champions moved around in the party. The object given to the hook is the champion and we cannot get his position to use an offset to place the newly cast spell in front of him. OK, do I need to reference the party now and match the name of the champion to get his position???
Am I missing the boat on how to cast a custom spell or is it very difficult? I am going to have to write many lines of custom LUA code to do something that to me should be a single command.
Thoughts? Comments?
Since we do not have a working shootProjectile() function to call, I spawn the new fireball object using the x and y specified.
Realization number 1: You cannot use the same X and Y specified or the fireball explodes in your tile!
That is a bit annoying but I can use getForward() with the direction given and have it spawn in the tile in front of the party.
Realization 2: Now the fireball casts and looks good, except it clearly has spawned in the next tile and does not look at all like it was cast by a champion. You look at the built-in spells and they spawn directly in front of the champion who cast it. This takes into account what position in the party he is in as well.
Now I am getting annoyed. I can do setWorldPosition() calls on the newly spawned fireball to make it appear closer to the party but how do I put it in front of the champion who cast it?
Realization 3: The Champion component does not return the position he is in in the party!?!?!? I can get the ordinal but that is different if the champions moved around in the party. The object given to the hook is the champion and we cannot get his position to use an offset to place the newly cast spell in front of him. OK, do I need to reference the party now and match the name of the champion to get his position???
Am I missing the boat on how to cast a custom spell or is it very difficult? I am going to have to write many lines of custom LUA code to do something that to me should be a single command.
Thoughts? Comments?