I’m designing combat for my work, Imminent Threat. For my damage calculation, I have an equation worked out that I am happy with. However, I cannot test it until a lot more options, variables, and such are written out which will take more time. So, my question for y’all awesome choicers, will this code function? Or are there supposed to be more spaces somewhere, or different symbols, or what would make this function? All of the variables for this specific snippet exist.
*fake_choice
*if e1dist = 0 *selectable_if eweapslot = 3 #Strike at the ${e1name} with my ${eweapname}.
*set dmg = mweapdmg x 30 - (edef x 33)
That’s a good notice on the distance thing with the zero. Thank you, I’ll find a way to modify!
And my goal for that is basically to have the option not appear at all if the enemy’s distance (e1dist) is more than 0, but if the enemy is close enough for a melee attack (e1dist = 0), then I want the option only grayed out, so that the player will know to draw their melee weapon if they want to make that choice. Will it work that way the way it is written?
Ah, I got your point. But… yeah. The problem’s there, though.
I’m not sure why you’d want to decide distance [e1dist] as your damage factor, tho. When you think about it, there’s this basic rule of spear > sword > dagger length, thus distance.
Either way, back to the topic.[quote=“CowboyHooah, post:3, topic:27243”]
but if the enemy is close enough for a melee attack (e1dist = 0), then I want the option only grayed out, so that the player will know to draw their melee weapon if they want to make that choice.
[/quote]
For graying out option, you’ll need *selectable_if command. Using *if will cause the option to be disappears instead of grayed out.
Now, back to the off topic.
So, you wanted for the player to draw their weapon first before being able to strike the enemy?
IMO, that’s redundant. I mean, if you’re going into battle, you’ll definitely want to keep your weapon on your hand, don’t you?
However, if your point is about “the advantage of the first move,” which in this case is who draws their weapon first, I think there’s a better way to do it.
I hope this clears things up.
P.S. Use the </> button to pre-format your code, allowing multiple spaces to be shown instead of shrinked into 1 space.
Hmm, makes sense, now.
So, the scenario is our PC are holding a ranged weapon, and the enemy is managed to get into melee-range. We can only use the knife, because the gun option is grayed out, am I right?
Quick addon question, is there a way to make a percentage chance of something happening based on an equation? (In this case a melee attack)
Here is the code I thought up:
*if e1dist = 0 *selectable_if eweapslot = 3 #Strike at the ${e1name} with my ${eweapname}.
*set cover 0
*set dmg (mweapdmg * (20) - (edef * 15))
*set hit (melee / 3 * mweapman * (1.2 ^ conshot))
Focusing on the “*set hit”, man means manuvering and conshot means how many consecutive hits.
I want that [hit] variable to be the chance of hitting.
Well, chance ,or RNG, can be done with *rand command.
The basic use of *rand should be like this:
*rand hit 1 8
The [hit] variable will be assigned a value between 1 as its minimum value, and 8 as its max. The script will automatically roll a dice between 1-8 (the min and max value are included)
I would caution against using any random values to determine the outcome of a fight.
The powers that be don’t seem to like that sort of thing.
However, if it’s a predictable mathematical equation that will work the same way every time (of course, this concept allows for the variables and values to be different, they just have to be consistent and not rely on randomization to achieve success), then I think it should be fine.
Are you testing your code as you go, by the way?
In your ChoiceScript folder --> web --> mygame, there’s an index.html file that opens up in Firefox.
You can use that to test as you go to see if the system will give you any specific errors, like for example, if you’ve got too many or too few parentheses in an equation.
To directly address the problem you’re bringing up about hit chance, I would also think about the opponent’s defense chance. This way we eliminate “chance” altogether and use specific values.
To illustrate:
Let’s say your “chance” to hit turns out to be a value of 18 based on choices you made earlier such as preparedness, situational awareness, etc. So 18 is your hit value.
Normally, the defense value of an opponent is 15, but they caught you off guard (plot reasons) so their defense value gets bumped up to 19.
Their defense is higher than your attack, so you miss.
If their defense is the same as your attack, perhaps they get hit for partial damage?
It’s just a matter of figuring out the design.