Code: Select all
[h:'<!-----------------------------Standard Pit (trapped)---------------------------------->']
<!-- Here you enter the code to apply the effect of the pit Example is given -->
<!-- NOTE THAT ALL OUTPUT IS IGNORED, SO THE ONLY WAY TO GET SOMETHING TO THE CHAT IS BY USING BROADCAST! -->
<!-- check which event this token triggers this can be
- movedOn
- movedOff
- movedOver
- movedReturn when you move the token AND use way points AND leave the token but end the move onto the token
-->
[h:me = arg(0)]
[h:event = arg(1)]
[h:padName = arg(2)]
[h:lastPath = arg(3)]
[h:eventPadTriggered = arg(4)]
[h:triggerType = arg(5)]
<!-- assert that the trigger is a pad event -->
[h:assert(triggerType == "pad", "The GM has assigned a wrong trigger type: <i>"+triggerType+"</i> to this pad", 0)]
[h:switchToken(me)]
[h:trapped = if(event=="movedOff" || event=="movedReturn",1,0)]
[h:attackRoll = 1d20]
[h,if(attackRoll > Dexterity), CODE:{
[h:'<!--Failed Ag Test-->']
[h:entryPoint = json.get(eventPadTriggered, 0)]
[h:x = json.get(entryPoint, "x")]
[h:y = json.get(entryPoint, "y")]
[h:iEntryPoint = json.indexOf (lastPath, entryPoint)]
[h:lastPath = if(trapped, json.get(lastPath, 0, 0), json.get(lastPath, 0, iEntryPoint-1) )]
[h, token(padName): setTokenImage(getTokenHandout())]
[h: moveToken(x, y)]
[h: txtOut = if(trapped,"You failed to climb out<br>","you've fallen into a pit<br>")]
[h: AgTest = "Failed"]
}; {
[h:'<!--Succeeded Ag Test-->']
[h: txtOut = if(trapped,"You succeed to climb out<br>", "You nearly fell into a pit, but succeeded your Ag test. Rethink your next move!!<br>")]
[h: AgTest = "Success"]
[h:'<!-- if you move into (and not over) the pit and succeed your Ag check, you are pushed back to the edge of the pit. This means that a player cannot move into a pit voluntarily -->']
[h, if(event == "movedOn"), CODE: {
[entryPoint = json.get(eventPadTriggered, 0)]
[iEntryPoint = json.indexOf (lastPath, entryPoint)]
[edgePoint = json.get(lastPath, iEntryPoint-1)]
[lastPath = json.get(lastPath, 0, iEntryPoint-1)]
[x = json.get(edgePoint, "x")]
[y = json.get(edgePoint, "y")]
[moveToken(x, y)]
}]
}]
[h:broadcast(txtOut)]
[h:macro.return = lastPath]