Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

log function

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Rinku




Joined: 02 Feb 2003
Posts: 690

PostPosted: Sun May 15, 2005 1:17 am    Post subject: log function Reply with quote

does anyone know how to simulate the log function in integer math like the ohrrpgce uses? for example, would something like this work?



script, log, value, base
(
# RETURNS THE INTEGER LOG 'value' IN BASE 'base'.
# DEFAULT BASE IS 10.

if ((n / base) >> 1) then (return (1))
if (((n / base) / base) >> 1) then (return (2))
if ((((n / base) / base) / base) >> 1) then (return (3))
# etc.
)
_________________
Tower Defense Game
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sun May 15, 2005 4:06 am    Post subject: Reply with quote

My 'math.hss' file is getting so large.

Code:
define script (-1, log, 2, 0, 10)

script, log, value, base, begin
  variable (result)
  while (value >= 1) do (
    value := value / base
    result += 1
  )
  return (result -- 1)
end


Always rounds down. What use is this script, you ask? log of a number to base 10 + 1 returns its length in digits, possibly useful when displaying numbers.

(rinku, ignore the difference in scripts)
Back to top
View user's profile Send private message Send e-mail
Rinku




Joined: 02 Feb 2003
Posts: 690

PostPosted: Sun May 15, 2005 5:16 am    Post subject: Reply with quote

that should work.

btw, you should release math.hss with quaternion!

better: we should have a public place to post general-use scripts, and they'd be auto-added to new versions of the ohrrpgce. i could include the best script ever, maybe. here's the simplest version of it.

script, maybe
(
if (random (0,1) then (return (1)) else (return (0))
)

it's amazingly useful! you can do things like

maybe + maybe + maybe and get a weighted random number between 0 and 3, but it'd much more often be 1 or 2 than 0 or 3.

also useful for if (maybe) then (do something) for something that should happen half of the time. every game should have a maybe!
_________________
Tower Defense Game
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Sun May 15, 2005 1:12 pm    Post subject: Reply with quote

Hmm, that might be an interesting new addition to the CP update (The script uploading idea, that is). I thought about it before in the past, but totally forgot until now XD. It'd be nice if there was a library that the community can freely contribute to.

But also, a while back I created a chance script that's used in a similar way as that maybe script. It's actually part of that library I have posted as a sticky. But instead of just being true or false, it would return true based on a percentage. I dunno if you'd use it or not, but you never know:

Code:

script, Chance, CPercent, begin
if ((random (1, 100)) <= CPercent, and, CPercent <> 0) then (
   return (true)
) else (
   return (false)
)
end


So you could have something happen 67% of the time if you wanted it to.

For that maybe script too, you could just shorten it to simply this:

Code:

script, maybe
(
return(random(0, 1))
)


Since you're just returning the numbers created by the random function in the first place Oookay...

But yeah, I'll talk to IM about adding a plotscripting section itself to CP somewhere. Script sharing is always fun Raspberry!.
Back to top
View user's profile Send private message
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Sun May 15, 2005 6:25 pm    Post subject: Reply with quote

That's a fairly decent idea! Only problem being that it'll delay the new CP...
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Rinku




Joined: 02 Feb 2003
Posts: 690

PostPosted: Mon May 16, 2005 4:06 am    Post subject: Reply with quote

i do have a percent-based version of maybe, which works much like the one you posted (the default value for the percent is 50). it's pretty useful too.
_________________
Tower Defense Game
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group