Increments to SDFs

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Increments to SDFs
Agent
Member # 4506
Profile Homepage #0
IS there a way to increment an SDF higher (or lower). I want to simulate "Reputation" like there was in the Avernum series for my scenario, but I don't know how... :( :( :(

- Archmagi Micael

--------------------
"You dare Trifle with Avernum?" ~ Erika the Archmage
--------------------
My Scenarios:
Undead Valley : A small Undead problem, what could possibly go wrong?
--------------------
Richard Black - PROOF of his existance (the Infernal one's website).
--------------------
MY FORUM! Randomosity at it's highest! :)
Posts: 1370 | Registered: Thursday, June 10 2004 07:00
...b10010b...
Member # 869
Profile Homepage #1
i = get_flag(x,y);
i = i + 1;
set_flag(x,y,i);
Caution: depending on what you want to do with this, you may also need to add checks to make sure the variable's value is within the legal range for an SDF after you increment it.

[ Thursday, June 09, 2005 22:29: Message edited by: Thuryl ]

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
? Man, ? Amazing
Member # 5755
Profile #2
Ephesos used the following in Druids of Krell in order to gather the approval rating for Oakleaf.

inc_flag (x,y,inc_value);

so inc_flag(2,15,2); would increment flag 2,15 by 2 points.

I assume you could use negative values as well.

Edit - This works perfectly. This code...
beginstate 13;
clear_buffer();
append_string("Start ");
append_number(get_flag(4,3));
inc_flag(4,3,15);
append_string(" then ");
append_number(get_flag(4,3));
inc_flag(4,3,-10);
append_string(" then ");
append_number(get_flag(4,3));
get_buffer_text(test);
print_str(test);
break;
Produced this text
"Start 0 then 15 then 5"

Nice...

[ Thursday, June 09, 2005 22:44: Message edited by: Smoked Salmon ]

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
...b10010b...
Member # 869
Profile Homepage #3
There's an inc_flag call? Whoops. I guess that'd make things easier.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
? Man, ? Amazing
Member # 5755
Profile #4
Further testing shows that it will Not exceed the sdf ranges. No way to exceed 255 or go negative.
:)

Edit - Explanation
inc_flag (x,y,355) produces a SDF value of 255
inc_flag (x,y,-355) produces a SDF value of 0

[ Thursday, June 09, 2005 22:50: Message edited by: Smoked Salmon ]

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
Agent
Member # 4506
Profile Homepage #5
Can you use this call to lower the SDF as well?

I need the "Reputation" to be able to be lowered as well, so they can either be famous, or infamous.

- Archmagi Micael

--------------------
"You dare Trifle with Avernum?" ~ Erika the Archmage
--------------------
My Scenarios:
Undead Valley : A small Undead problem, what could possibly go wrong?
--------------------
Richard Black - PROOF of his existance (the Infernal one's website).
--------------------
MY FORUM! Randomosity at it's highest! :)
Posts: 1370 | Registered: Thursday, June 10 2004 07:00
Post Navel Trauma ^_^
Member # 67
Profile Homepage #6
Yes.

--------------------
Barcoorah: I even did it to a big dorset ram.

New Mac BoE
Posts: 1798 | Registered: Thursday, October 4 2001 07:00