Property not setting...sometimes

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

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

Property not setting...sometimes

Post by xavram »

I'm assuming this is some kind of concurrency issue but I can't figure it out.

There is more to this macro, but I think posting the whole thing will just cause more confusion. It is the very end of the macro that I'm having issues with.

Code: Select all

[h, if(target != "Solid Object"), code : {
	[broadcast("<b>" + getName(targetId) + "</b> " + targetSide + " armor takes...")]
	[h : RamDamage(targetId, targetSide, round((rammerDM * collisionDamage) * multiTargetDamage, 0))]
	[h : HazardCheckForRam(targetId, targetHC)]
	[broadcast("<b>" + getName(targetId) + "</b> speed is changed to " + targetNewSpeed + "!")]
	[h : setProperty("CurrentSpeed", targetNewSpeed, targetId)]
}]

[broadcast("<b>" + getName(rammerId) + "</b> " + rammerSide + " armor takes...")]
[h : RamDamage(rammerId, rammerSide, round((targetDM * collisionDamage) * multiRammerDamage, 0))]
[h : HazardCheckForRam(rammerId, rammerHC)]
[broadcast("<b>" + getName(rammerId) + "</b> speed is changed to " + rammerNewSpeed + "!")]
[h : setProperty("CurrentSpeed", rammerNewSpeed, rammerId)]
Its the two "setProperty("CurrentSpeed")" lines that are having problems. Sometimes they set the CurrentSpeed property for the specified tokens (targetId and rammerId) and sometimes it doesn't.

WHY???

Also appears that "setProperty" calls within the "HazardCheckForRam" are behaving the same way. The property that changes there does not always get set.

Again...WHY???


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

Re: Property not setting...sometimes

Post by xavram »

Nope....yeah, that would be sneaky one but that's not it.


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

Re: Property not setting...sometimes

Post by xavram »

sorry, have had no internet connection from home all weekend...sigh

run diagnose for the bot...do you mean the Bag of Tricks? Sadly, I don't use that. Any other ideas? Could it be the fact that the token is potentially moved during the "HazardCheckForRam" macro?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Property not setting...sometimes

Post by wolph42 »

well a lot is possible whihc is why the basics are good to cover. if you dont have the bot then just drag the two tokens onto the map to install it, so you can run diagnose, its not that a big deal. it at least rules out all the basic stuff with names and the like

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

Re: Property not setting...sometimes

Post by xavram »

So I finally had time to get back to this project and I think I've diagnosed where/when this happens.

if I comment out the HazardCheckForRam function, then the [h : setProperty("CurrentSpeed", rammerNewSpeed, rammerId)] always works. And even with the HazardCheckForRam in place, it still sometimes works.

So i dug into that and determined what the actual problem is. If the HazardCheck results in a failure the car (which is the token) can sometimes be moved with a MoveToken call (car fishtails or skids as part of the HazardCheck). If this happens (the token gets moved), then all the "setProperty" calls AFTER the movement don't seem to actually set on the token. If the HazardCheck doesn't result in the car moving (IE, they made their roll), then the property DOES set, because the token is never moved.

My problem is...how do I handle this? I need the token to move on a failed roll but I need to have the properties set correctly too. And things like speed have to set AFTER the HazardCheck, as that check needs to be made before the speed is adjusted.

Any ideas on how I might be able to handle this? Thanks!

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Property not setting...sometimes

Post by aliasmask »

I would perhaps defer the moveToken part of the code after all your properties are set using execLink() so it's always done last eventhough it may occur in the middle of your code.

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

Re: Property not setting...sometimes

Post by xavram »

Let me see if i can work out how to do that...there can be more than one "movement" in this, depending on what rolls are made/missed, so that gets really tricky.

Post Reply

Return to “Macros”