View Single Post
rob
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 8,232

Old May 25th, 2006, 02:16 PM
Hmmm. Based on the syntax you're using, I think there's a more fundamental point of confusion going on here. Either I'm not understanding your objective properly or you've misunderstood some of the scripts. You're using the "@cost" special symbol in your example. That symbol only applies to the ChildCost script, which is completely different from the Cost script (for which "@each" and "@single" are the symbols).

If I understand you correctly, your goal is to have the "Cost" script of the option for the drop capsule on the "squad" unit calculate the cost of all drop capsules for the "squad" and all "trooper" children. Assuming this is correct, then the script you have below is nearly correct. The only change should be a last line of "@single=work*price". You also have to define it as the option's "Cost" script instead of "ChildCost".

This brings up the question of what is motivating this particular approach? Is there a reason that you can't assign the cost to the drop capsulte child unit? Or to the option that attaches that child? This will yield more accurate information to the user, since each trooper unit will properly reflect the cost impact of the drop capsules associated with it.

Please give me more details on how the game mechanics work for constructing a platoon with squads and troopers. If I can understand how things need to work for the user, perhaps I can recommend an optimal way of setting up the data files to reflect that.

Thanks, Rob


At 11:30 AM 5/23/2006, you wrote:

Quote:
OK, request for direction on this one...

I have a unit that has a stat that it gets from its children. (drop)

The purpose of the stat is to caculate the cost of an option on the unit's children.

The long version:

The root unit is a Platoon.
The first child is a squad.
The second child is a trooper.
The third child is a drop capsule.

the drop capsule has this in its eval:

parent.unit.stat[drop] = parent.unit.stat[drop] + 1

The trooper has this in its postlink:

var woot as number
woot = unit.stat[drop]

if (woot = 1) then
parent.unit.stat[drop] = parent.unit.stat[drop] + 1
endif

What I wind up with is how many troopers have drop capsules as a unit stat at the squad level. So far so good, the stat adds up right and all is happy.

Now, in the unit squad, there is a option for the drop capsule that gets mirrored to the troopers.

I'm trying to write a cost script that will calculate the cost of the option at the squad level.

I'm trying similar to this in the cost script on the option:

var work as number
var price as number
work = this.unit.stat[drop]
price = @cost ~the cost for the option is only set on the unit getting it; the trooper but not the squad
@cost= (work * price)

This.....does not work
[img]./modules/mdforum/images/smiles/icon_biggrin.gif[/img] *

Easier way of computing that cost? I need to calculate how many troopers (I think I have that part down fine, I use it elsewhere and I'm very pleased with it) by the cost of the capsules....and I am brain locked. I can't use the built in mechanism since each trooper is a new unit.

Answer quickly, or I'll post my "Rename the unit based on its rank and armor" script, garunteed to hurt the brain of any actual programer [img]./modules/mdforum/images/smiles/icon_eek.gif[/img]

Thanks for any direction!
rob is offline   #2 Reply With Quote