copyToken questions

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: copyToken questions

Post by xavram »

For anyone who cares, I finally got this working. It does require a "DroppedBase" token to exist on the "game" map.

Code: Select all

[h : arguments = macro.args]

[broadcast("in create dropped")]

[h : ownerId = json.get(arguments, "Shooter")]
[h : wpnSys = json.get(arguments, "Weapon")]

[h : droppedId = findToken("DroppedBase")]
[h : switchToken(droppedId)]
[h: names =  getAllPropertyNames("DroppedItem")]
[h, foreach(name, names, ""), code : {
  [h : resetProperty(name)]
}]

[h : weaponName = json.get(wpnSys, "Name")]
[h : ammo = json.get(wpnSys, "Ammo")]
[h : location = json.get(wpnSys, "Location")]
[h : size = json.get(wpnSys, "Size")]
[h : imageId = json.get(wpnSys, "ImageId")]
[h : damage = json.get(wpnSys, "Damage")]
[h : burnMod = json.get(wpnSys, "BurnMod")]
[h : burnDur = json.get(wpnSys, "BurnDur")]
[h : metalOn = json.get(wpnSys, "Metal")]

[h : tokenSizeList = stringToList(size, "x")]
[h : tokenWidth = listGet(tokenSizeList,0)]
[h : tokenHeight = listGet(tokenSizeList,1)]
[h : setTokenWidth(tokenWidth, droppedId)]
[h : setTokenHeight(tokenHeight, droppedId)]

[h : setTokenImage(tableImage("DroppedItems", imageId))]

[h : setProperty("Owner", ownerId)]

[h : damageList = stringToList(damage, "/")]
[h : setProperty("TireDamage", listGet(damageList,0))]
[h : setProperty("UnderBodyDamage", listGet(damageList,1))]
[h : setProperty("AllDamage", listGet(damageList,2))]

[h : setProperty("BurnMod", burnMod)]
[h : setProperty("BurnDur", burnDur)]
[h : setProperty("Metal", metalOn)]
<!--IsX properties have to be set based on weapon name--!>
[h, if(indexOf(weaponName, "Spike") >= 0), code : { 
	[h : setProperty("IsSpike", 1)]
	[h : setProperty("DoesDamage", 1)]
}]
[h, if(indexOf(weaponName, "Mine") >= 0 || indexOf(weaponName, "Spear") >= 0), code : {
	[h : setProperty("IsMine", 1)]
	[h : setProperty("DoesDamage", 1)]
}]
[h, if(indexOf(weaponName, "Oil") >= 0) : setProperty("IsOil", 1)]
[h, if(indexOf(weaponName, "Ice") >= 0) : setProperty("IsIce", 1)]
[h, if(indexOf(weaponName, "Paint") >= 0), code : {
	[h : setProperty("IsPaint", 1)]
	[h : setProperty("PhaseCountdown", 13)]
}] 
[h, if(indexOf(weaponName, "Smoke") >= 0), code : {
	[h : setProperty(setProperty("IsSmoke", 1)]
	[h : setProperty("PhaseCountdown", 300)]
}]
[h, if(indexOf(weaponName, "Flaming Oil") >= 0 || indexOf(ammo, "Flaming Oil") >= 0), code : {
	[h : setProperty("IsFOJ", 1)]
	[h : setProperty("PhaseCountDown", 2)]
}]
[h, if(indexOf(weaponName, "Flame Cloud") >= 0 || indexOf(ammo, "Flame Cloud") >= 0), code : {
	[h : setProperty("IsFCE", 1)]
	[h : setProperty("PhaseCountDown", 2)]
}]

[h : shooterCenter = getProperty("LastCenter", ownerId)]
[h : shooterX = json.get(shooterCenter, "X")]
[h : shooterY = json.get(shooterCenter, "Y")]
[h : moveToken(shooterX - (tokenWidth * 0.5), shooterY-(tokenHeight*0.5), 1, droppedId)]
[h : setTokenFacing(getTokenFacing(ownerId), droppedId)]

[h : moveThisMuch = -155]
[h, if(tokenHeight == 75) : moveThisMuch = -117.5]
[h, if(tokenHeight == 300) : moveThisMuch = -230]
[h, if(location != "Back") : moveThisMuch = Sum(moveThisMuch, 75)]
[h : facingToUse = getTokenFacing(ownerId)]
[h : sin = math.sin(facingToUse)]
[h : cos = math.cos(facingToUse)]
[h :  yMove = round(sin,5)]
[h : xMove = round(-cos,5)]
[h: CurrentX = getTokenX(1, droppedId)]
[h: CurrentY = getTokenY(1, droppedId)]
[h: NewX = CurrentX + (xMove*moveThisMuch) ]
[h: NewY = CurrentY + (yMove*moveThisMuch)]
[h: moveToken(NewX, NewY, 1, droppedId)]

[h, if(location != "Back"), code : {
	[h, if(location == "Right") : TurnDir = 1 ; TurnDir = -1]	
	[h : driftAmount = 80]
	[h, if(tokenHeight == 300) : driftAmount = 117.5]
	[h : currentFacing = getTokenFacing(ownerId)]
	[h : facing90 = currentFacing -(90 * TurnDir)]
	[h: sin = math.sin(facing90)]
	[h : cos = math.cos(facing90)]
	[h :  yMoveOrigin = round(sin,5)]
	[h : xMoveOrigin = round(-cos,5)]
	[h: CurrentX = getTokenX(1, droppedId)]
	[h: CurrentY = getTokenY(1, droppedId)]
	[h: NewX = CurrentX + (xMoveOrigin * driftAmount) ]
	[h: NewY = CurrentY + (yMoveOrigin * driftAmount)]
	[h: moveToken(NewX, NewY,1, droppedId)]
}]

<!--Random Spin, to make the image look different--!>
[h, if(d10 > 5) : setTokenFacing(Sum(getTokenFacing(droppedId),180))]

[h, MACRO("Set4Corners@lib:Math"):droppedId]
[h : setName(table("DroppedItems", imageId), droppedId)]

[h: copyToken(droppedId)]

[h : setName("DroppedBase", droppedId)]
[h : moveToken(getTokenX(1, "Firing_Orders"), getTokenY(1, "Firing_Orders"), 1, droppedId)]
[h, foreach(name, names, ""), code : {
  [h : resetProperty(name, droppedId)]
}]

Results look like...

Image

In this pic, car with a back mounted Spike dropped, left HD Paint sprayer and right HD Oil jet has fired them all.

Post Reply

Return to “Macros”