Splitting GameNPC class into more classes ?

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Splitting GameNPC class into more classes ?

Postby Leodagan » Sun Sep 15, 2013 9:06 am

As I'm trying to replace LoS check with my los Manager I found that GameNPC class have a lot of method that are dedicated to Fight.

Since there can be NPC's with Peace Flag that should be unable to use any of these method (StartAttack, RangedAttack, etc...) and that most of these are used by Mob and Pets I was thinking a class hierarchy would be better to prevent those 5000+ lines files :)

GameNPC : implements interact, moving, equipment
-- GameMob : implements fighting, LosChecking, Default Brain to aggro or fight
-- -- GamePet (Already exists) : implements Controlled Brain, on top of default brain and default Pet behavior (like orders)

Some other NPC aspects (Merchant, Trainer, Taxi, Teleporter, etc) could be implemented as Interfaces...

I already had trouble when I tried to mix a GameMerchant with a GameTeleporter, I could inherit only one and had to copy most of code of the other one to be able to handle both :) but maybe even Interfaces won't be enough to handle that ;)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Splitting GameNPC class into more classes ?

Postby Graveen » Sun Sep 15, 2013 4:12 pm

For sure !

Same for GamePlayer, the class is way too complex :) but it is less obvious to remove this.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Splitting GameNPC class into more classes ?

Postby Tolakram » Mon Sep 16, 2013 9:11 pm

Technically this is a good idea, but only if it can somehow preserve current scripts. The project is too mature to tolerate these kinds of big changes and there are no benefits to the player, just the devs, of which there might be 10 of us now. Maybe 5. :)
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Splitting GameNPC class into more classes ?

Postby geshi » Mon Sep 16, 2013 10:44 pm

A bit too big of a change to do this far in I think..

Wasn't it like this before? about 5-6 years ago there was GameMob at least.. maybe it was just another name for GameNPC.. or I'm imagining it..
geshi
Contributor
 
Posts: 1826
Joined: Tue Oct 21, 2008 9:16 pm

Re: Splitting GameNPC class into more classes ?

Postby Leodagan » Tue Sep 17, 2013 5:51 am

Yeah I think you're right after all...

Even If there are methods that shouldn't be in there like startAttack() (which should only be available to Mob who have a brain to attack) it can always be override to call the Brain method if existing but should be left there to still offer compatibility with old scripts.
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest