Creating an NPC that buffs

This guide will create a “buff bot” for my test instance, it will apply an “Attack Boost” to a player who clicks on it for 1 hour which modifies the Attack attribute by +5. This buff can only be obtained once per day (done by applying a “Recently Attack Boosted” effect for 24 hours)

This could be expanded to provide one of a set of random buffs, a random chance of a buff, a puzzle rewarded with a buff or whatever your scriptable fancy may be.

Firstly we create a couple of Effects:

/1Effects.Create "Attack Boost"
/1Effects.Create "Recently Attack Boosted"
/1Configuration.SetEffect "Attack Boost" Characters.Attack 5

And an NPC:

/1Characters.Create "Buff Wizard"
/1Characters.MakeNPC "Buff Wizard"

Create an object, name it, place the Objects (SL) script in it (/1Objects.GetDriver</code)

Create a new (GPHUD) script called “Buff Wizard” as follows:

Integer i=0;
Integer duration=gsGetEffectDuration(TARGET,"Recently Attack Boosted");
if (duration>=0) {
  i=gsSayAsChar(CALLER,"Sorry, "+TARGET+", I have already helped you recently");
} else {
  i=gsSayAsChar(CALLER,"Greetings, "+TARGET+", allow me to lend you a hand!");
  i=gsApplyEffect(TARGET,"Attack Boost",1800);
  i=gsApplyEffect(TARGET,"Recently Attack Boosted",60*60*23); 
  // not quite a full day
}

Go to objects configuration, create a new object type called “Buff Wizard”, set it up as an NPC with the recently created character and script. Connect your newly registered object to this object type.

Example interaction:

(Existing /1characters.show)
[12:44:37] GPHUD: 
Character: test989 <Goodies>
Played by:Iain Maltz
Agility: 2 Attack: 2 Block: 0
Class: Thief
(Existing /1effects.show)
[12:44:40] GPHUD: OK : You have no effects applied
(Click on the buff wizard)
[12:44:44] GPHUD: You feel more powerful!
[12:44:44] Buff Wizard: Greetings, test989, allow me to lend you a hand!
(/1Characters.Show)
[12:44:48] GPHUD: 
Character: test989 <Goodies>
Played by:Iain Maltz
Agility: 2 Attack: 7 Block: 0
Class: Thief
(/1Effects.Show)
[12:44:51] GPHUD: OK : Current Effects:
Recently Attack Boosted (22h 59m 53s)
Attack Boost (29m 53s)
(Click on wizard again)
[12:46:15] Buff Wizard: Sorry, test989, I have already helped you recently

And the audit log:

19:44:45 Iain Maltz/Buff Wizard	→	Iain Maltz/test989	Add - Effect		→	Attack Boo...	Applied effect Attack Boost for 30m
19:44:45 Iain Maltz/Buff Wizard	→	Iain Maltz/test989	Add - Effect		→	Recently A...	Applied effect Recently Attack Boosted for 23h

Script