Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 06-20-2003, 09:34 AM
used_pawn
Sarnak
 
Join Date: Apr 2003
Posts: 53
Default Added code for random numbers in quests =)

Ok, here it is! :worship:

usage is: $random(x)
where x is the upper limit of a random number 0 < n < x

also, put it in quotes when you use it (ie. givecash("random(10)","random(10)","random(5)","ra ndom(5)"

enjoy!

../zone/parser.cpp : line 1456 (or thereabouts) INSERT this
Code:
//used_pawn
	else if (!strcmp(varname,"random")) {
		char temp[10];
		Replace(origstring,format,itoa(rand()%varparms[0],temp,10));
	}
//used_pawn
Reply With Quote
  #2  
Old 06-21-2003, 08:57 PM
used_pawn
Sarnak
 
Join Date: Apr 2003
Posts: 53
Default

bah, i hadnt updated my cvs lately, try putting it here

../zone/parser.cpp : line 1497

Code:
	else if (!strcmp(varname,"chr")) {
		char temp[4];
		memset(temp, 0x0, 4);
		temp[0] = atoi(varparms);
		Replace(origstring,format,temp);
	}
//used_pawn
	else if (!strcmp(varname,"random")) {
		char temp[10];
		Replace(origstring,format,itoa(rand()%varparms[0],temp,10));
	}
//used_pawn
	else if (!strcmp(varname,"asc")) {
		char temp[10];
		Replace(origstring,format,itoa(varparms[0],temp,10));
	}
Sorry, Im not very good at my postings.
Reply With Quote
  #3  
Old 06-21-2003, 09:36 PM
Trumpcard
Demi-God
 
Join Date: Jan 2002
Location: Charlotte, NC
Posts: 2,614
Default

ok.. got it
__________________
Quitters never win, and winners never quit, but those who never win and never quit are idiots.
Reply With Quote
  #4  
Old 06-22-2003, 08:49 PM
killspree
Dragon
 
Join Date: Jun 2002
Posts: 776
Default

I've been testing this out and it doesn't seem to use the amount you enter in $random() as the max.
__________________
Xeldan
Lead Content Designer
Shards of Dalaya
Reply With Quote
  #5  
Old 06-23-2003, 02:06 AM
Bigpull
Discordant
 
Join Date: Feb 2003
Posts: 305
Default

are yoou using $random("10") or $random(10) ?
Reply With Quote
  #6  
Old 06-23-2003, 05:42 AM
killspree
Dragon
 
Join Date: Jun 2002
Posts: 776
Default

Tried with both, neither work 100% of the time.

And this is with creating a script to where the npc responds with all of the possible numbers in the quest.
__________________
Xeldan
Lead Content Designer
Shards of Dalaya
Reply With Quote
  #7  
Old 06-23-2003, 06:16 AM
Bigpull
Discordant
 
Join Date: Feb 2003
Posts: 305
Default

Bleh

Change:
Replace(origstring,format,itoa(rand()%varparms[0],temp,10));
To:
Replace(origstring,format,itoa(rand()%atoi(varparm s[0]),temp,10));


Should maybe do the trick
Reply With Quote
  #8  
Old 06-23-2003, 02:44 PM
used_pawn
Sarnak
 
Join Date: Apr 2003
Posts: 53
Default

the number you put in will never be chosen, that is by design.
as I stated 0<n<x where x is the number you put in random(x), easy to put in one number higher than you need, or change it in the code, doesnt really matter to me either way.

I have noticed strange things with quotes on many commands, some use them, some dont, some dont seem to work the same way twice in a row. Wasnt sure if it was things ive done to my code or if everyone had the problem

ah well, these things happen
Reply With Quote
Reply


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 -4. The time now is 03:28 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3