Marco R. said: For Spiritual Weapon I can share this piece of code, which is creating a token, giving it an attack ability and granting the player access to the token. maybe it is that what you are looking for. The function is embedded in the "custom spell book" by Nick O. . var pxSize = 70;
var pageID = token.get("pageid");
var curPage = (findObjs({_type: "page", _id: pageID})[0]||{get:()=>''});
//var curPageScale = curPage.get("scale_number");
var curPageFactor = curPage.get("snapping_increment");
var stdPxDist = pxSize*curPageFactor;
function spiritualWeapon(spellLevel, tok, player, tokenName,stdPxDist){ var tokImage = LINKTOIMAGE ; var namePart = "Spiritual Weapon"; //+ @{${tokenName}|spellcasting_ability} var abb = `&{template:default} {{name=Spiritual Weapon}}{{attack =[[1d20+@{${tokenName}|spell_attack_bonus}]] }} {{damage = [[ @{${tokenName}|spellcasting_ability}((${spellLevel}/2)-0.5)d8]]}}`; //{{Spiritual Weapon attack hits AC [[1d20+@{${tokenName}|spell_attack_bonus}]]= It inflicts [[${numDice}d8]] force damage and [[${numDice}d8]] additional crit. damage, if applicable}}`; var canName = tok.get("name")+"'s " + namePart; //var abb = `&{template:atkdmg}{{mod = @{${tokenName}|spell_attack_bonus}}}{{always=1}}{{rname = Spiritual Weapon Attack}}{{attack=1}}{{r1 = [[1d20]]cs>20}}{{damage=1}}{{dmg1flag=1}}{{dmg1 =[[((${spellLevel}/2)-0.5)d8]]}}{{dmg1type = force}}{{crit=1}}{{crit1=[[((${spellLevel}/2)-0.5)d8]]}}{{charname=canName}}`; helpCharacter = findObjs({type:'character',name:canName})[0]; if(helpCharacter){ //char = findObjs({type:'character',name:canName})[0]; eldritchChar = getObj('character',helpCharacter.id); var existingAbbs = findObjs({type: 'ability', characterid: helpCharacter.id}); _.each(existingAbbs, function(abil) { abil.remove(); }); createObj('ability',{ characterid:eldritchChar.get("id"), name:'Attack!', action:abb, istokenaction:true }); let canTok = createObj('graphic',{ left:tok.get("left") + stdPxDist, top:tok.get("top"), height:stdPxDist, width:stdPxDist, pageid:tok.get("pageid"), layer:"objects", imgsrc: tokImage, name:canName, represents: eldritchChar.get("id"), controlledby:player.get("id"), isdrawing:false }); setDefaultTokenForCharacter(eldritchChar, canTok); } else{ let eldritchChar = createObj('character',{ name:canName, inplayerjournals:player.get("id"), controlledby:player.get("id") }) createObj('ability',{ characterid:eldritchChar.get("id"), name:'Attack!', action:abb, istokenaction:true }); let canTok = createObj("graphic",{ left:tok.get("left") + stdPxDist, top:tok.get("top"), height:stdPxDist/2, width:stdPxDist/2, pageid:tok.get("pageid"), layer:"objects", imgsrc:tokImage, name:canName, represents: eldritchChar.get("id"), controlledby:player.get("id"), isdrawing:false }); setDefaultTokenForCharacter(eldritchChar, canTok) } sendChat(tok.get("name"), `I summoned a spiritual weapon at Level ${spellLevel}.`); spawnFx(tok.get("left")+stdPxDist, tok.get("top"), "burst-holy", tok.get("pageid")); } Thank you for this. It's very similar to what I'm already doing, but I hadn't thought about building a token action on the token I create that contains the attack. I will definitely play with this I think and see how my cleric player feels about using it like that. I could definitely do similar things with the Storm Sphere spell if I have that throw a specific spell template on the map too.