RPTools.net

Discussion and Support

Skip to content

It is currently Fri Nov 17, 2017 12:29 pm 






Reply to topic  [ 5 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Kobold
 
Joined: Thu Jul 20, 2017 6:27 pm
Posts: 8
 Post subject: If Statement that Checks for LoS
PostPosted: Sun Nov 05, 2017 3:13 am 
I have a macro that comes from the GURPS Framework at this link and it features a pretty slick attacking macro that brings up a list of valid targets and whatnot. It works great most of the time, but it seems that the VBL has no effect on whether a token is visible or not.

Here's the code from the macro:
Code:
[h:selectTokens(currentToken())]
[h:currManeuver=getProperty("currManeuver")]

[h, if(json.isEmpty(currManeuver)): continueMacro=0; continueMacro=1 ]
[h:exitMsg=getName(currentToken())+" has not chosen a maneuver.  <br> On your turn, pick a maneuver, pick a weapon, and attack something."]
[s,h: assert (continueMacro,exitMsg,0)] 

<!-- Setting up weapon variables from arguments -->
[h:args=json.fromStrProp(macro.args)]
[h:attacker=json.get(args,"attacker")]
[h:weaponUsedIndex=json.get(args,"currItemIndex")]
[h:methodUsed=json.get(args,"method")]
[h:weaponUsed=json.get(inventory,weaponUsedIndex)]
[r:minReach=json.get(weaponUsed,methodUsed+"minReach")]
[r:maxReach=json.get(weaponUsed,methodUsed+"maxReach")]

<!-- Setting up maneuver bonus variables -->
[h:currManeuverName=json.get(currManeuver,"name")]
[h:manSkillBonus=json.get(currManeuver,"offSkillBonus")]
[h:manSkillLimit=json.get(currManeuver,"offSkillLimit")]
[h:rangeBonus=json.get(currManeuver,"rangeBonus")]
[h:manDamageBonus=json.get(currManeuver,"damageBonus")]

<!-- Determining penalty from attacker's posture -->
[h:postureList=getTokenStates("json", "Postures")]
[h:posture="standing"]
[h:attackerPostureMod=0]
[foreach(p, postureList,""), h , code: { [h,if(getState(p)):posture=p;""] } ]
[h, if (posture == "crouching" || posture == "kneeling" || posture == "sitting" ) : attackerPostureMod=-2;""]
[h, if (posture == "crawling" || posture == "face_up" || posture == "prone" ) : attackerPostureMod=-4;""]

<!-- Setting up conditions to determine which tokens are possible targets -->
[h:range=json.set("{}","token",attacker,"from",minReach,"upto",maxReach+rangeBonus,"distancePerCell",0)]
[h:NPCsInRange=json.set("{}","range",range,"npc",1,"visible",1)]
[h:PCsInRange=json.set("{}","range",range,"pc",1,"visible",1)]

<!-- Setting up list of possible targets -->
[if( isPC() ), h, code : {
  [h:targetListFirst=getTokens(",",NPCsInRange)]
  [h:targetListSecond=getTokens(",",PCsInRange)]
};{
  [h:targetListFirst=getTokens(",",PCsInRange)]
  [h:targetListSecond=getTokens(",",NPCsInRange)]
}]

[h,if(targetListSecond==""):
  targetList=targetListFirst ;
  targetList=listAppend(targetListFirst,targetListSecond) ]

[if (listCount(targetList)==1),h:checkedIfOneTarget="checked";checkedIfOneTarget=""]
[if (listCount(targetList)==0),h:msg="<br><br>You do not see any tokens within melee distance.  Make sure the token you would like to target is visible on your map and is within your weapon's reach.  Then try again.";msg=""]

<!-- Setting up list of dialog box width and form action-->
[h:START_NEW_ROW=6]
[if (listCount(targetList)>START_NEW_ROW),h:
   dialogSpecs="width=470; height=620; temporary=0; input=1; noframe=0";
   dialogSpecs="width=470; height=550; temporary=0; input=1; noframe=0"]
[h:formAction=macroLinkText("evalAttack@"+getMacroLocation(),"all","",currentToken())]

[dialog("meleeAttack", dialogSpecs): {
<html>
<head>
<link rel="stylesheet" type="text/css" href="DialogCSS@Lib:GURPS">
<title>Choose Target and Method of Attack</title>
</head>
<body>
<form name="attack"  action="[r:formAction]">
<input type="hidden" name="weaponUsedIndex" value="[r:weaponUsedIndex]">
<input type="hidden" name="methodUsed" value="[r:methodUsed]">
<h1>[r:upper(json.get(weaponUsed,"name"),1)] [r:json.get(weaponUsed,methodUsed+"descr")] at base skill [r:json.get(weaponUsed,methodUsed+"skill")]</h1>
[r:msg]

<table width="100%" cellspacing="1" cellpadding="2">
<tr>
[foreach(possTarget, targetList,""),code:{
  [token(possTarget),if(getProperty("HP")==getProperty("maxHP")),h: tokenHealth="healthy"; tokenHealth="injured"]
  [token(possTarget),if(getState("healthy")==1),h: tokenHealth="healthy"]
  [token(possTarget),if(getState("injured")==1),h: tokenHealth="injured"]
  [token(possTarget),if(getState("maimed")==1),h: tokenHealth="maimed"]
  [token(possTarget),if(getState("dying")==1),h: tokenHealth="dying"]
<!-- Start a new row of possible targets if you have an even multiple of START_NEW_ROW setting.  Wanted: XmodY.-->
   [if( roll.count/START_NEW_ROW==floor(roll.count/START_NEW_ROW)), r : "</tr><tr>";""]
  <td valign="top" align="center">
  <img src="[token(possTarget),r:getTokenImage(50)]"><br>
  <b>[token(possTarget),r:getName()]</b><br>
   [r:tokenHealth]<br>
  <input type="radio" name="targetID" value="[r:possTarget]" [r:checkedIfOneTarget]></td>
}]
</tr>
</table>

<h1>Select skill modifiers for circumstances and style of attack</h1>

<b>Maneuver Effects: [r:manSkillBonus]</b><input type="hidden" name="maneuver" value="[r:manSkillBonus]">
<br><span style=color:gray>[r:currManeuverName] - [r:json.get(currManeuver,"descr")].</span>
<br>
[h, if(getProperty("shock")==0): textColor="gray";textColor="red"]
<span style=color:[r:textColor]><b>Shock Penalty: [r:shock]</b></span><input type="hidden" name="shock" value="[r:shock]">
<br>
[h, if(posture=="standing"): textColor="gray";textColor="red"]
<span style=color:[r:textColor]><b>Posture: [r:posture]: [r:attackerPostureMod]</b></span><input type="hidden" name="attackerPostureMod" value="[r:attackerPostureMod]">

<br><br>

<table cellspacing="0" cellpadding="0">
  <tr class="oddRow">
  <th valign="middle">Other Modifiers</th>
  <td align="center"><input type="radio" name="miscMod" value="-10"></td>
  <td align="center"><input type="radio" name="miscMod" value="-9"></td>
  <td align="center"><input type="radio" name="miscMod" value="-8"></td>
  <td align="center"><input type="radio" name="miscMod" value="-7"></td>
  <td align="center"><input type="radio" name="miscMod" value="-6"></td>
  <td align="center"><input type="radio" name="miscMod" value="-5"></td>
  <td align="center"><input type="radio" name="miscMod" value="-4"></td>
  <td align="center"><input type="radio" name="miscMod" value="-3"></td>
  <td align="center"><input type="radio" name="miscMod" value="-2"></td>
  <td align="center"><input type="radio" name="miscMod" value="-1"></td>
  <td align="center"><input type="radio" name="miscMod" value="0" checked></td>
  <td align="center"><input type="radio" name="miscMod" value="1"></td>
  <td align="center"><input type="radio" name="miscMod" value="2"></td>
  <td align="center"><input type="radio" name="miscMod" value="3"></td>
  <td align="center"><input type="radio" name="miscMod" value="4"></td>
  <td align="center"><input type="radio" name="miscMod" value="5"></td>
  <td align="center"><input type="radio" name="miscMod" value="6"></td>
  <td align="center"><input type="radio" name="miscMod" value="7"></td>
  <td align="center"><input type="radio" name="miscMod" value="8"></td>
  <td align="center"><input type="radio" name="miscMod" value="9"></td>
  <td align="center"><input type="radio" name="miscMod" value="10"></td></tr>

  <tr class="oddRow">
  <th valign="middle">&nbsp;</th>
  <td align="center">-10</td>
  <td align="center">&nbsp;</td>
  <td align="center">-8</td>
  <td align="center">&nbsp;</td>
  <td align="center">-6</td>
  <td align="center">&nbsp;</td>
  <td align="center">-4</td>
  <td align="center">&nbsp;</td>
  <td align="center">-2</td>
  <td align="center">&nbsp;</td>
  <td align="center">0</td>
  <td align="center">&nbsp;</td>
  <td align="center">2</td>
  <td align="center">&nbsp;</td>
  <td align="center">4</td>
  <td align="center">&nbsp;</td>
  <td align="center">6</td>
  <td align="center">&nbsp;</td>
  <td align="center">8</td>
  <td align="center">&nbsp;</td>
  <td align="center">10</td></tr>

  <tr>
  <td colspan="22">&nbsp;</td></tr>

  <tr>
  <th valign="middle" colspan="3">Other Large Modifiers</th>
  <td align="left" colspan="19"><input type="text"  name="largeMod" value="0" size="2" maxlength="3"></td>
</table>

[macro("bodyPartTable@"+ getMacroLocation()):""]

<p align="center"> <input type="submit" value="attack!"> &nbsp; <input type="reset" value="reset to defaults"></p></form></body></html>
}]
<!-- passes targetID, weaponUsedIndex, methodUsed, maneuver, shock, attackerPostureMod, miscMod, largeMod, targetedLocObj (region, penalty) -->


Basically I want to have some sort of If statement or similar that checks if a token is visible using the canSeeToken() function, if that's at all possible. Because I've played around with the function and it gives a "false" when asking to see a token that is obscured by the VBL. Any help would be appreciated.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7947
Location: Bay Area
 Post subject: Re: If Statement that Checks for LoS
PostPosted: Sun Nov 05, 2017 3:54 am 
I use this for my LoS targeting: viewtopic.php?f=20&t=24635#p249246

Basically, you want to add Wiki: canSeeToken().

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Kobold
 
Joined: Thu Jul 20, 2017 6:27 pm
Posts: 8
 Post subject: Re: If Statement that Checks for LoS
PostPosted: Sun Nov 05, 2017 4:28 am 
aliasmask wrote:
I use this for my LoS targeting: viewtopic.php?f=20&t=24635#p249246

Basically, you want to add Wiki: canSeeToken().


I'm a complete scrub. How would I implement this, exactly?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7947
Location: Bay Area
 Post subject: Re: If Statement that Checks for LoS
PostPosted: Sun Nov 05, 2017 4:48 am 
Without rewriting too much, you could just use my function instead of getTokens().

Code:
...
<!-- Setting up list of possible targets -->
[if( isPC() ), h, code : {
  [h:targetListFirst=getTokens(",",NPCsInRange)]
  [h:targetListSecond=getTokens(",",PCsInRange)]
};{
  [h:targetListFirst=getTokens(",",PCsInRange)]
  [h:targetListSecond=getTokens(",",NPCsInRange)]
}]
...


Replaced with

Code:
<!-- Setting up list of possible targets -->
[if( isPC() ), h, code : {
  [h:targetListFirst=json.toList(getSeenTokens(json.set("{}","npc",1,"range",range)))]
  [h:targetListSecond=json.toList(getSeenTokens(json.set("{}","pc",1,"range",range)))]
};{
  [h:targetListFirst=json.toList(getSeenTokens(json.set("{}","pc",1,"range",range)))]
  [h:targetListSecond=json.toList(getSeenTokens(json.set("{}","npc",1,"range",range)))]
}]


You should set up the function as a UDF in your lib token in the onCampaignLoad macro.
Code:
[H: defineFunction("getSeenTokens","getSeenTokens@"+getMacroLocation(),1,1)]

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Kobold
 
Joined: Thu Jul 20, 2017 6:27 pm
Posts: 8
 Post subject: Re: If Statement that Checks for LoS
PostPosted: Sun Nov 05, 2017 6:07 am 
Thanks man! You're a real help! :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 5 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 2 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman