Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Army Builder Forums > Army Builder

Notices

Reply
 
Thread Tools Display Modes
Jamz
Senior Member
 
Join Date: Aug 2005
Location: Chicagoland
Posts: 397

Old May 5th, 2009, 09:39 PM
OK, I'm completely stumped. I'm trying to create a unit that has random stats. The problem I ran into is, the "eval" script for options run everytime ANY option change is made. So if a user changes an option on this unit, all his stats are re-randomized.

I tried to add another option and auto toggle it's selection to track the state, so randomize stat on first eval, set counter to true. And checking if counter = true at the top and skipping the rest of the script. Therefore it should only set the random stat once.

Except it just doesn't work. The option is set, but the stat doesn't change (if I remove the first if/then check, the stats randomize fine so that works, just not the boolean check).

HELP! Is there an easier/better way to run a script just once for a unit (EVER!)?? I also tried setting tags, but the tagis/tagcount always returned 0 even though I saw the tags for the unit under debug.

The unit is a child under a single parent if that makes a difference.



[EVAL SCRIPT]

var x as number
var y as number


if ( this.unit.option[neCounter].selection = 1 ) then
done
endif


x = random(10) + 1

if (x = 1) then
y = 8
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 2) then
y = 9
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 3) then
y = 9
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 4) then
y = 10
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 5) then
y = 10
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 6) then
y = 10
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 7) then
y = 10
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 8) then
y = 11
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 9) then
y = 11
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

if (x = 10) then
y = 12
this.unit.basestat[mp] = y
this.unit.option[neCounter].selection = 1
done
endif

-Jamz

RPTools.net | MapTool Discord Invite

Download Latest MapTool Release | Download Latest TokenTool Release
Jamz is offline   #1 Reply With Quote
Jamz
Senior Member
 
Join Date: Aug 2005
Location: Chicagoland
Posts: 397

Old May 5th, 2009, 09:55 PM
Given some further testing...

I had a similiar option that DOES work, sort of...The difference was that this one just selected a random option, and that option may have set some stat changes.

So, as a test, i added this.unit.basestat[mp] = x to the first test condition, and sure enough, it doesn't set the stat. It sets the option selection to 1 sure enough but that's it.

Is setting an option selection (or checking it) throwing my context out or something?



[EVAL Script]

if ( this.unit.option[BlankLine].selection = 1 ) then
done
endif


var x as number

x = random(5)

this.unit.name = this.unit.name & x

if (x = 0) then
x = 22
this.unit.basestat[mp] = x
this.unit.option[neFrenzy].selection = 1
this.unit.option[BlankLine].selection = 1
done
endif

if (x = 1) then
this.unit.option[neCarapace].selection = 1
this.unit.option[BlankLine].selection = 1
done
endif

if (x = 2) then
this.unit.option[neDurable].selection = 1
this.unit.option[BlankLine].selection = 1
done
endif

if (x = 3) then
this.unit.option[neQuicken].selection = 1
this.unit.option[BlankLine].selection = 1
done
endif

if (x = 4) then
this.unit.option[neIrradiat].selection = 1
this.unit.option[BlankLine].selection = 1
done
endif

-Jamz

RPTools.net | MapTool Discord Invite

Download Latest MapTool Release | Download Latest TokenTool Release
Jamz is offline   #2 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 12,873

Old May 6th, 2009, 08:16 AM
Look in the authoring kit manual, in the Tips & Tricks section, for the "Supporting Random Values" topic. Summary: generating random values within HL is not supported, but they give you tips on how to record the results of the random rolls you've made (which you're already close to, just reference a range-based link instead of your random roll).
Mathias is offline   #3 Reply With Quote
Jamz
Senior Member
 
Join Date: Aug 2005
Location: Chicagoland
Posts: 397

Old May 7th, 2009, 02:29 PM
Reference the range-based link where?

The random statements work (ie I can randomly set the selection status of options) but in the same if/then block, I can NOT set a unit.basestat.

Well, I CAn set the basestat if I remove the:
if ( this.unit.option[neCounter].selection = 1 ) then
But then it continually randomizes. I've tried to set neCounter to a range-based option as well but that seems to change nothing.

-Jamz

RPTools.net | MapTool Discord Invite

Download Latest MapTool Release | Download Latest TokenTool Release
Jamz is offline   #4 Reply With Quote
Reply

Thread Tools
Display Modes

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 Jump


All times are GMT -8. The time now is 01:52 AM.


Powered by vBulletin® - Copyright ©2000 - 2021, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.