Lone Wolf Development Forums Cost script and unit stat
 Register FAQ Members List Search Today's Posts Mark Forums Read

 Notices Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528. If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com. - The Lone Wolf Development Team

Member

Join Date: Jan 2006
Location: Iowa City, IA
Posts: 78

May 23rd, 2006, 10:30 AM
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

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 :shock:

Thanks for any direction!
#1
rob
Senior Member
Lone Wolf Staff

Join Date: May 2005
Posts: 8,005

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!
#2
Member

Join Date: Jan 2006
Location: Iowa City, IA
Posts: 78

May 26th, 2006, 08:01 AM
Wrong symbol....AH! OK, still learning on much of the scripting, but OK, that makes sense now.

Now, the reason I'm using this method to try to compute the cost is....uh....

ops:

That I was working too long without a break and was trying to make something simple complicated ops:

Looking at it again after reading your post, I thought of course I must have done it diffrently for some reason...and after the 5 min it took to implement it correctly just now, realized that no, I had just tried to do something silly .

Well, I learned more about scripting at least.....

Thanks for the mental nudge
#3

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Lone Wolf Development Web Site Announcements Realm Works Forums     Realm Works Discussion         Realm Works in Action         Realm Works Feature Requests     Realm Works in Action     Realm Works Feature Requests Hero Lab Online Forums     Hero Lab Online Discussion     HLO - Pathfinder 2nd Edition     HLO - Starfinder Hero Lab Forums     HL - Pathfinder Roleplaying Game     HL - D&D 5th Edition SRD     HL - Shadowrun     HL - Mutants & Masterminds     HL - d20 System     HL - World of Darkness     HL - Call of Cthulhu     HL - 4th Edition     HL - Savage Worlds     HL - Cortex System     HL - Authoring Kit     HL - User Projects     HL - Alternity (user-created)     Hero Lab Discussion Army Builder Forums     Army Builder Army Builder Data Files     Babylon 5: A Call to Arms     Battlefleet Gothic     Blood Bowl     Black Powder, Bolt Action, Hail Caesar, Judge Dredd, and Pike & Shotte     Confrontation - English     Kings of War (2nd Edition)     Lord of the Rings (Tabletop)     Mordheim     Necromunda     Starship Troopers     Star Wars: X-Wing and Armada Miniatures Game     The 9th Age     Warhammer Ancient Battles     Warhammer 40,000     Warhammer Fantasy 8th Ed.     Warhammer Historical: The Great War     Warhammer Fantasy 3rd Ed.     Warlord     Warmachine & Hordes     Warmaster Card Vault Forums     Card Vault Card Vault Data Files     MLB Showdown     Lord of the Rings CCG     .hack//ENEMY     Vs. System     Yu-Gi-Oh!     D&D Miniatures

All times are GMT -8. The time now is 03:02 AM.

 -- Default Style -- Majestic Contact Us - Lone Wolf Development Forums - Archive - Top