You mean because of the way XP is granted. I suppose but there may be another reason depending on what you want to do. I can't think of anything right now. But its good there is way to get it working just in case.minmay wrote:But you don't need this. You can just changeMrChoke wrote:The above code will not work like that unless it is cast as a built-in spell. I experimented quite a bit on it.Code: Select all
onHitMonster = function(self, monster) monster:setCondition("poisoned", 25) -- mark condition so that exp is awarded if monster is killed by the condition local poisonedCondition = monster.go.poisoned local ord = self:getCastByChampion() if poisonedCondition and ord then poisonedCondition:setCausedByChampion(ord) end end,
toCode: Select all
poisonedCondition:setCausedByChampion(ord)
and get the same effect.Code: Select all
poisonedCondition:setCausedByChampion(1)
[Solved] Casting custom spells like built in spells
Re: How do I cast a custom spell like built in spells are ca
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: [Solved] Casting custom spells like built in spells
@MrChoke; To move the starting position of a projectile I use GameObject:setSubtileOffset(dx, dy), knowing your caster you will have no difficulty to find the correct values. I use it to mimic the meteor spell.
@minmay; iirc the xp system of grimrock 1 was insane . But I agree, all this is unnecessary with equal xp in grimrock 2. I didn't know the dangers of this variable, so thank you for the warning, I will adapt my code. However the function onProjectileHit still needs to be custom to set an ordinal for the tileDamager spawned. I would be curious to see the build-in spells code, as even if I don't plan to modify the xp system I am not comfortable with arbitrary ordinal, I'd like the code to be universal enough to share it with other modders who may or may not want to use unequal xp. I doubt now, didn't grimrock 1 grant more xp to the performer of the killing action ?
@minmay; iirc the xp system of grimrock 1 was insane . But I agree, all this is unnecessary with equal xp in grimrock 2. I didn't know the dangers of this variable, so thank you for the warning, I will adapt my code. However the function onProjectileHit still needs to be custom to set an ordinal for the tileDamager spawned. I would be curious to see the build-in spells code, as even if I don't plan to modify the xp system I am not comfortable with arbitrary ordinal, I'd like the code to be universal enough to share it with other modders who may or may not want to use unequal xp. I doubt now, didn't grimrock 1 grant more xp to the performer of the killing action ?
Re: [Solved] Casting custom spells like built in spells
Man, setSubtileOffset(), another new command. Thanks! So dx and dy, these are world coordinate offsets, not map ones?AndakRainor wrote:@MrChoke; To move the starting position of a projectile I use GameObject:setSubtileOffset(dx, dy), knowing your caster you will have no difficulty to find the correct values. I use it to mimic the meteor spell.
@minmay; iirc the xp system of grimrock 1 was insane . But I agree, all this is unnecessary with equal xp in grimrock 2. I didn't know the dangers of this variable, so thank you for the warning, I will adapt my code. However the function onProjectileHit still needs to be custom to set an ordinal for the tileDamager spawned. I would be curious to see the build-in spells code, as even if I don't plan to modify the xp system I am not comfortable with arbitrary ordinal, I'd like the code to be universal enough to share it with other modders who may or may not want to use unequal xp. I doubt now, didn't grimrock 1 grant more xp to the performer of the killing action ?
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: [Solved] Casting custom spells like built in spells
Yes, try -0.25 or 0.25, something like that !
Re: [Solved] Casting custom spells like built in spells
Grimrock 1 granted half experience to champions that did not damage a monster.
If you really do want to attach arbitrary data to a projectile for whatever reason, using a ScriptComponent is probably the best way, yeah. Trying to directly add additional fields to a component or GameObject probably won't end well.
If you really do want to attach arbitrary data to a projectile for whatever reason, using a ScriptComponent is probably the best way, yeah. Trying to directly add additional fields to a component or GameObject probably won't end well.
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.