Page 1 of 1

Reward Objects [DOL.GS.Reward]

PostPosted: Tue Jan 06, 2015 10:45 pm
by Xanth
RewardObject.cs
changed code | INFO HOW-TO-Use the script is in code.
(2.2 KiB) Downloaded 258 times
EDIT: Removed the Radius (foreach) method and changed the code a bit.


Hey guys, i wrote a script which gives u an amount of bps after rightclick the object, so its like opening presents.

So tell me if you like it and i think it could be useful for some other things like if u click on it it casts a spell for 15% bonus dmg for 5min or something, you can be creative. this is just the template and u can work with it. I also added a USE HELP on top for no wrong use of the script.

feel free to post a bug or anything else

best regard :)

xanth

Re: Reward Objects [DOL.GS.Reward]

PostPosted: Wed Jan 07, 2015 8:25 am
by Leodagan
Just for a coding matters :
Code: Select all
player.Out.SendMessage("You gain " + reward + " Bountypoints from " + this.Name, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
You should use string format here,
Code: Select all
player.Out.SendMessage(string.Format("You gain {0} Bountypoints from {1}", reward, this.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
It will improve the performance/memory usage, and it match some other use case such as "Translations" that use similar Formatting.

----

You're also calling multiple time "this.RemoveFromWorld();" for each of the "Name case", and one last time at the end of the method...

And you have an empty loop on "foreach (GamePlayer p in this.GetPlayersInRadius(250))", Get*InRadius methods are pretty expensive, and shouldn't be used for doing nothing ;)

----

And lastly not about code, DataQuest are already able to handle this use case...

there is a Start Type :
InteractComplete = 4, // Interacting with start object grants and finishes the quest
And you can customize the reward
RewardBP - Serialized list of XP rewarded each step. All steps must have a value, 0 is ok.
finally allow unlimited quest accomplishment (or not...)
MaxCount, MinLevel, MaxLevel - Single values to determine who can do quest. All must be provided. MaxCount == 0 for no limit
http://www.dolserver.net/articles/?article=48

Re: Reward Objects [DOL.GS.Reward]

PostPosted: Wed Jan 07, 2015 9:42 am
by Xanth
i dont really understand the dataquest thing and thx for the report with empty loop and what is too much and so on also thank you with the performance and memory example, i learned from you a bit now its quite interesting. thank you very much and i will maybe change it later.

best regards

Re: Reward Objects [DOL.GS.Reward]

PostPosted: Thu Sep 10, 2015 10:37 am
by Terontoy
You know, this is it. Tell me can you?