Inline math operations?

Forum for scripters of NWN material and third party applications.
Post Reply
Teibidh
Clueless Prime
Posts: 12
Joined: Sat Nov 22, 2003 4:39 am
Contact:

Inline math operations?

Post by Teibidh »

For a script I'm writing I need to apply a damage effect equal to the character's weight divided by 10... The problem I run in to is the division component. In pretty much every syntax I've ever worked at least one of these two variants should work:

EffectDamage(GetWeight(oVictim)/10,DAMAGE_TYPE_BLUDGEON);

Or...

int iDamage = GetWeight(oVictim)/10;
EffectDamage(iDamage,DAMAGE_TYPE_BLUDGEON);


Now, the script applies the damage effect correctly in terms of actually applying damage of the correct type, but in neither case does it do the division. So in the case of my test character with a weight of 16 it's applying 16 points of damage instead of 2 (assuming integer divisions round with normal rounding rules, but even 1 would be fine.). So, what do I need to do to get the result of GetWeight() divided by 10?
You'll see me in Hell? I'm quite sure. Just head for the center. I'll be the guy sitting on the throne with the cold beer in one hand, your sister in the other and your mom as a footrest.
lafferty
Planewalker
Posts: 31
Joined: Mon Nov 24, 2003 9:30 pm
Location: look at my hands... they are HUGE. And they cant touch themselves... (AVLIS)
Contact:

Post by lafferty »

read the manual ;)

http://www.reapers.org/nwn/reference/co ... eight.html

GetWeight() returns the weight of all items carried by a character or one item in tenths of lbs!!

so you need to divide by 100 and not 10 since your 16 lbs make 160 tenths of lbs ;)

aaaand: you may want to apply some value to the weight based on race so the creature itself also gets a weight and not only the inventory's weight is used for the damage (i assume its a trap of some kind)

Edit: ah yes... and inline operations work quite fine in nwscript. you only need to make sure that you pass the right data type.

Edit 2 : ah yes... to make it especially mean you can also take gold into account. i know that gold does not have weight in nwn engine... but that doesnt mean you cant assign weight to it in your script :twisted: like 0.1 lbs per 100 gp should already make a hell of a damage for some players

Laff
[url=http://zope.lafferty.de]Crafter's helper[/url]
Teibidh
Clueless Prime
Posts: 12
Joined: Sat Nov 22, 2003 4:39 am
Contact:

Post by Teibidh »

I thought about taking the character's race and other stuff in to account but the purpose isn't to kill anyone... It's only like a 10 foot drop (1 level according to raise/lower terrain), so it shouldn't be enough to kill. It should be enough to make folks wary of wandering around with 1000 pounds of stuff in their pack though.

Thanks for the link to the manual, I had no idea it was something like that, I figured it just wasn't doing the division. :P
You'll see me in Hell? I'm quite sure. Just head for the center. I'll be the guy sitting on the throne with the cold beer in one hand, your sister in the other and your mom as a footrest.
Mistcaller
Groundling
Posts: 137
Joined: Tue Nov 25, 2003 7:29 am
Location: Avlis Team - Tairis'nadur Team

Post by Mistcaller »

In a related note, do you know if there is a default include file in nwn for math functions?
Functions like mod(x,y), max(x,y), min(x,y), etc?
Post Reply