Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
c#2Bot

C#2Bot Scripter Application

15 posts in this topic

1. Snippets:

  • None.

2. Tutorials:

3. Scripts Available to public:

4. Short biography

Good day gentlemen, i recently graduated from the university holding a first class bachelor of engineering degree, moving forward to masters in BA, i have always loved being an engineer, passionate about how and what makes things work. In my spare time i have worked in our family business developing windows form application through C#, providing automatic solutions to receipts,quoting, and agreements as well as month/yearly profit calculations. When im home i spend my time playing games, including runescape, through which i found about tribot and joined this community, i have been involved from a long time ago, but i took a break to finalize my university work as i did not have any commitments to be abide to in tribot's community, and now i am back developing and enjoying in this wonderful place.

5. Reasons why you deserve scripter

I strongly believed in improving and providing, not only do i wish to learn and expand through this community, but throughout my journey i would love to help and assist all individuals who join tribot as users to become contributors, the aim is to flourish the community by allowing it to be more productive, i also seek to promote positivity within all the members, to allow the idea that everything is achievable where the user will feel that they can suggest and request to find those demands satisfied and granted. Developing in tribot is something i enjoy doing, i will keep developing and producing free open sources scripts because practice makes one better, and when i am providing for others, others will also provide for me. I have lost all my accounts developing my contributions, but i couldn't careless, every time i required an account to do something a member was willing to allow me access to his account, when i couldn't access the members world, Montreal offered me a bond, and gave me free proxy to use on tribot. I strongly believe in the give and take in any relationship.

 

6. What i plan to provide the community with?

I will always continue to develop high quality open sourced to the community as well as tutorials on how they can be developed, as i believe this will create a better chance to have all possible scripts that are in demand.

 

7. Do i agree to not only update but continue providing free open source scripts?

Definitely, this is my objective in tribot.

 

Thank you very much for your time,

C#2bot

 

_________________________________________________________________________________________

@Final Calibur

Thanks for taking your time and leaving me with constructive feedback and generous remarks, ill respond to those critiques in a similar fashion to your listing:

1.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/paint/Paint.java#L76
        -What is the point in the null check when you're already attempting to perform an operation
        on it on the line above? Null check should be before the attempted operation

You are absolutely right, the null check should have been before of the operation, however that method is not use anywhere in the script it was merely for testing, and i forgot to remove it, the paint class is basically where i conducted my testings to display paint, as i still haven't finished my plans with this script, but due to the fact that i got my accounts all banned i released it with those features. however, it is my fault that i haven't proof read this class well and i have mitigated that flaw. I even got some members accounts banned through the development of this script, and they had absolutely no regrets but i also compensated them with all the means i can.

2.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/paint/Paint.java#L76
        -Magic numbers

This refers to the same case as the above and has been revoked.

3.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/tasks/AttackPortals.java#L25
        -While loops should be used with caution. Also, there should be a slight sleep in the loop somewhere,
        otherwise it will use a pretty ridiculous amount of CPU. If your doIdleActions does not do an action,
        the loop will execute again immediately without sleeping

Point noted and understood, and the sleeps are implemented.

4.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/tasks/DefendKnights.java#L35
        -What is the point in the this keyword here? Just noticed this because your usage of the this keyword is
        not consistent across your codebase.

Sometimes i fail to remember method names in my classes, so i use this keyword as reference

5.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L118
        -Is a 100 search distance really necessary? That doesn't seem very efficient.

Certainly not, i have changed that to use the size of the RSTile array getAllTiles()l length

6.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/GearUp.java#L56
In all seriousness, i am a descendant of Egyptians, back to the point, i understand the problems this can cause in terms of debugging, and tracking the script in the long term, to be honest i noticed that but i was selfish to think that i understand the code myself as i did not think that it would give troubles to others who will find it difficult to understand what i am trying to do, and for that i have broken it down to fewer methods, my apology for not considering that fact.

 

_____________________________________________________________________________________________________________________________________

My dear friend @Assume, i would like to thank you for your input in a "Positive" way, and i thank you for appreciating how i like to be addressed and there for i will apologize for my behavior on discord. Moving on, sorry for being inconsiderate, tbh where i come from language is way more sophist acted than how i named my enums, none the less i  acknowledge the fact that it is bad practice and there for have made changes to respect the fact that other people would be reading my code as well.

 

@Assumethanks for the advice, appreciate it, i would also like you to consider mine, and please allow me to decide whatever it is "I" should do. This is a scripter rank application and this discussion is not at point here, however if you feel like to continue with this debate, you can add me on skype and we can sort something out. Lets keep the discussion at the topic.

 

_____________________________________________

@erickho123i agree with you, my initial idea was to make a video commentary, which i did, playing back i realised that my computer fan was making a jet engine noice, but indeed, i like your idea if breaking down the videos into sections, will do so asap, will try to record sound again too. Thanks for that

Started to apply your suggestions to the tutorial

 

 

@UsaGood day, i have allowed 639fd19b41.png, would like my application to be reviewed thank you. thanks for your time and kind comments, points noted and accommodated, abc2 implemented in my cutting script now :)

_____________________________________________________________________________________________________________________________________

@laniaxthank you for your feedback, i really appreciate the time you put to review my code, i will reply to your comments accordingly.

 

Now onto your code, i'll start with the woodcutter.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/api/conditions/Conditions.java
https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/utilities/Conditions.java
Curious, why do you have two classes named Conditions?

Just recently started writing my api, and i forgot to remove that conditions class in the utilities when i implemented my api class, the api is written so that i dont have to rewrite methods over than over.

 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/api/conditions/Conditions.java
Why is one of your Conditions classes a singleton if all you do is return new objects on every call?

Because i want to create a global instance of the class to avoid creating similar instances over and over in my projects.

 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/api/conditions/Conditions.java#L152
This can be a false positive. Game#getUptext might return different values on each call. Please cache it in a variable and do your checks on that.

Also, please refrain from using underscores in your method names.

I understood the point regarding the game#getUptext, cached it, however why should i refrain from using underscores, its readable by you and me, and i am more comfortable with these naming conventions with all due respect.

 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L46
Use dynamic sleeping instead using conditions.

please state why, so i can understand and implement with appreciation, usa suggested using this.

 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L98
Again, possible false positive.

Fixed.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L122
I notice you applied this as a fix after another scripter commented on it. However, i think the way you fixed it was inadequate. You use the size of the RSArea as the distance to search.. In other words, if your RSArea 'trees_Loc' is say an area of 10x10 tiles in which trees reside. You will currently search a distance of 100 tiles! 

Absolutely right, i didnt think of this way my bad, thanks for enlightening me, fixed it

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L159
You're just clicking at the current mouse position? why not use Mouse#click instead?

because mouse.click is a void method, and i need to check if the click has been successful, hence used a boolean method.

I notice you use Walking#blindWalkTo a lot, how are you so certain that it won't get stuck?

For my usage, it did not get stuck, however if someone did and reported i would have added a path save option :)

 

The following is heavily detected and in no way ABC2 compliant! I advise you to remove the ABC2 tags from your script threads until you fix this.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/PowerChop.java#L77
Never move your mouse to the dead center of a object, even if u give a General.random to it. Please read the thread below to develop an understanding of how human mouse movement works. The fix is actually quite simple but i leave that for yourself to figure out.


https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/PowerChop.java#L86
A mouse hop? You instantly receive a No from me here. I'm sorry, but a scripter should be lightyears ahead of this.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/PowerChop.java#L110
Your bot will click on the exact same offset on the chooseoption menu every time. Again, very very detectable. 

you have methods called 'getY' and 'to28' please improve your naming, this is guesswork for people like us trying to figure out what the method is doing.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L194
You set the camera to roughly the same angle every time.

This method you are criticizing i did not write it i took it from the snippet section, from the link above, because i didnt want to right my own, and thats the purpose of that section, so i thought an well established premium scripter contribution is good resource.

 

Dear @Encodedi hope i understood your challenge correctly, this will be my solution to your challenge in this link here. it will have the results shown below:

1b5663341e.gif

@Encodedand @erickho123 yes i am afraid i have to agree that after further browsing into tribots api, my code can potentially throw a null pointer exception, this is not to justify my practices but to explain why i my null checks are not consistent, in c# my methods in null checking is on point, which is not an excuse, i understand now that you would not take from your time to show me those points, unless they are actually valid, not that i am hesitant with regards to your advises, but as a programmer i need to be convinced to amend my practices, as i am able to understand, i have the capability, now that i see your points with regards to the null checking, and the numerous remarks about my naming conventions, i have decided to read the book "The complete reference java seventh edition" to appreciate the language more and to distinguish . as for your challenge encoded, yes your solution is simpler but my solution as well provides the same result and can be simplified to match yours, hence i have done so, if simplicity is what you sought:

	private RSNPC[] grabNpcs(RSNPC[] nearNpcs) {
		if (nearNpcs != null && nearNpcs.length > 0) {
			RSTile tile = Player.getPosition();
			Collections.sort(Arrays.asList(nearNpcs), new Comparator<RSNPC>() {
				@Override
				public int compare(RSNPC a, RSNPC b) {
					double npcADistance = a.getPosition().distanceToDouble(tile);
					double npcBDistance = b.getPosition().distanceToDouble(tile);
					return (int) (npcADistance - npcBDistance);
				}
			});
		}
		return nearNpcs;
	}

@laniax@Encoded@erickho123@Usa i was not being stubborn or hard headed regarding your remarks about the conventions, after i have read the book, i now understand that this is how naming that is practiced in java, appreciating that fact, my c# naming style could be problematic for developers in java, which is why you were trying to notify me, i now have a different feeling than before that should distinguish between the two languages, and give java its own appropriate approach rather than apply my knowledge from c# to be directly applied to java.

	@Override
	public void onPaint(Graphics g) {
		Polygon[] p = null;
		RSNPC[] guards = this.grabNpcs(NPCs.find("Guard"));
		if (guards.length > 0) {
			RSModel model = guards[0].getModel();// cache the model i think this concept is within my understanding, and i can follow up.
			if (model != null) {
				p = model.getTriangles();
			}
		}
		if (p != null) {
			for (Polygon l : p) {
				g.drawPolygon(l);
			}
		}
	}

 

I am not pleading or asking anyone who voted no to change your minds or opinions, i understand the reason behind that is to rectify my errors, i do hope to be accepted as a scripter, but i dont mind being denied either, both ways im in the win, what i have learned and understood i will apply to my atm scripts and will be therein my future scripts, i understand your feeling @erickho123 that if i get accepted i wont have motivation to mitigate those concerns, in fact i might be encouraged to persist, but from your previous comments regarding my tutorial, i think you can appreciate my dedication and in fact i do take constructive criticism seriously.

 

@Assume, this is not an interrogation and you are in no position to interrogate or force me to say anything, since you already stated your opinion which is appreciated, thanks for that, none the less,  i admit my weak points, its okay to be wrong mate. Please refrain from using commanding language with me do this do that. I am a grown up, i decide what i want to do, cheers.

 

@Sphiinxplease read what i posted before i already admitted and already said that i am not justifying, and i said i will work on them, anyways thanks for your feedback.

________________________________________________________________________________________________________

________________________________________________________________________________________________________

________________________________________________________________________________________________________

All in all thanks to everyone who devoted time to leave constructive and generous comments, i have invested time to browse and rectify most of the null pointer exception remarks, changed majority of the naming conventions and applied a lot of amendments based on the recommendations, having said that, i will be leaving this to the hands of the ones responsible, to evaluate and decide, which ever side this application ends, the outcome will be the same, message is delivered, points are noted and lesson learned.

 

@Encodedi have cached the model, please reread it, i am sure your will find that there, just to clarify, i have made amendments, sometimes it takes time to appear in the thread, for some reason, you were referring to something i already fixed, not to be offensive or anything but i assure you that i am not that stupid to post the same mistake twice.

 

I have made 67 commits to my repository since the start of this application, to appreciate remarks and fix issues in my code.

Edited by c#2Bot

Share this post


Link to post
Share on other sites

I like your attitude, and was pretty pleasantly surprised at your code. Skimmed through it and noticed a few things, but overall it seems like you have sufficient ability to write solid and well put together scripts for the community. Here are some of the notes I wrote down: 

1.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/paint/Paint.java#L76
        -What is the point in the null check when you're already attempting to perform an operation
        on it on the line above? Null check should be before the attempted operation
        
2.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/paint/Paint.java#L76
        -Magic numbers

3.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/tasks/AttackPortals.java#L25
        -While loops should be used with caution. Also, there should be a slight sleep in the loop somewhere,
        otherwise it will use a pretty ridiculous amount of CPU. If your doIdleActions does not do an action,
        the loop will execute again immediately without sleeping

4.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/pestcontrol/tasks/DefendKnights.java#L35
        -What is the point in the this keyword here? Just noticed this because your usage of the this keyword is
        not consistent across your codebase.

5.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L118
        -Is a 100 search distance really necessary? That doesn't seem very efficient.

6.) https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/GearUp.java#L56
        -Are you an egyptian? Making a pretty big pyramid of code here.

 

Overall not bad at all, and in my humble opinion, you'll be a great addition to the team. It's a yes from me.
 

2 people like this

Share this post


Link to post
Share on other sites

Your code is terrible and your attitude in Discord was beyond terrible. Absolutely not.

Also, where did you get the idea that naming something using the convention HEYIREALLYHATEITWHENPEOPLECANUNDERSTANDWHATMYVARIABLENAMEIS was a good idea?

Also just some simple life advice, if you can't deal with people cussing or being direct, you need to get out of the computer science and software development world while you can. This is a white collar profession in a blue collar environment. Everyone will be cussing all the time.

Edited by Assume
1 person likes this

Share this post


Link to post
Share on other sites

These video tutorials are completely uncut. An hour+ tutorial without a microphone? It is extremely hard to follow off java comments when it's in a video. As well, the video shows you going back and forth on your "mistakes"/basic concepts that can easily be understood in sections. Explaining what a constructor, how to initialize an object, what a constant is, what a variable is, etc should be in a separate video or section. What about the scriptwriters that already know the fundamentals of java? You're combining so many things into one video that it won't even appeal to anyone who wants to learn how to script. 

Honestly, from what I know, people might consider videos > books or text because of the commentary that is provided. Your type of videos are harder to follow than normal video and text based tutorials. I'm sure many scripters can agree with this.

 

I have yet to read your script code, btw. I will probably do that another time.

Edited by erickho123
2 people like this

Share this post


Link to post
Share on other sites

I can see you are a fan of c#, the naming conventions of your variables/methods show. I'd say _variable and THISISAVARIABLE are less preferred conventions in Java but the most important thing is consistency/readability so I won't gig you on that if it works for you.  (_instance ... CATHERBYGROUNDFLOORLADDERTILE )


RSObject[] tree = Objects.findNearest(Vars.trees_Loc.getAllTiles().length, Vars.tree);
if (tree != null && tree.length > 0) {
"tree" will never be null, but I think you know that.


Antiban.setWaitingSince();
Antiban.get().performReactionTimeWait();
if (tree.click("Chop down")) {
This looks correct however where are you generating your trackers after each reaction time is generated?


while (Combat.isUnderAttack()) {
}
Careful using a loop without a breakout, use a timer with it. Just not good practice in a dynamic environment. i.e. Agility where your player may still be moving/animating but actually isn't.


if (Player.getRSPlayer().getInteractingCharacter() == null)
Player.getRSPlayer() can return null, get interacting character would surely throw an NPE surround with a try/catch or cache the variable before calling on it.


Overall not bad at all. Interesting use of the Conditions class, looks like a useful implementation.

I will leave this topic open pending additional comments from other Scripters. I would like to see you implement ABC correctly as well.

 

1 person likes this

Share this post


Link to post
Share on other sites

Before i start reviewing your code, i want to say to you and any future potential scripter candidate that i'm not impressed with the recent scripts people are applying with. Choppers, Flax pickers and Cookers are amongst the most simplest of scripts one can write and they give me the impression that people want to rush getting scripter. I think anyone would have much greater chances if the scripts were a bit more exotic and showed a real sense of problem solving and creativity.

Now onto your code, i'll start with the woodcutter.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/api/conditions/Conditions.java
https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/utilities/Conditions.java
Curious, why do you have two classes named Conditions?
 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/api/conditions/Conditions.java
Why is one of your Conditions classes a singleton if all you do is return new objects on every call?
 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/api/conditions/Conditions.java#L152
This can be a false positive. Game#getUptext might return different values on each call. Please cache it in a variable and do your checks on that.

Also, please refrain from using underscores in your method names.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L46
Use dynamic sleeping instead using conditions.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L98
Again, possible false positive.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L122
I notice you applied this as a fix after another scripter commented on it. However, i think the way you fixed it was inadequate. You use the size of the RSArea as the distance to search.. In other words, if your RSArea 'trees_Loc' is say an area of 10x10 tiles in which trees reside. You will currently search a distance of 100 tiles! 

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L159
You're just clicking at the current mouse position? why not use Mouse#click instead?

I notice you use Walking#blindWalkTo a lot, how are you so certain that it won't get stuck?

The following is heavily detected and in no way ABC2 compliant! I advise you to remove the ABC2 tags from your script threads until you fix this.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/PowerChop.java#L77
Never move your mouse to the dead center of a object, even if u give a General.random to it. Please read the thread below to develop an understanding of how human mouse movement works. The fix is actually quite simple but i leave that for yourself to figure out.


https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/PowerChop.java#L86
A mouse hop? You instantly receive a No from me here. I'm sorry, but a scripter should be lightyears ahead of this.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/PowerChop.java#L110
Your bot will click on the exact same offset on the chooseoption menu every time. Again, very very detectable. 

you have methods called 'getY' and 'to28' please improve your naming, this is guesswork for people like us trying to figure out what the method is doing.

https://github.com/CSharp2Bot/Scripts/blob/master/src/scripts/cutter/tasks/Chop.java#L194
You set the camera to roughly the same angle every time.
 

 

Well, i've only looked at a few classes in 1 script. I'm not going to continue since i think you get the point. Please don't see this as a negative response, since i wouldn't have taken my time to type it all out if that was the case. I hope you can improve and show us a better version of yourself the next time you apply.

Share this post


Link to post
Share on other sites


@c#2Bot As a response to your remarks:

The snippet by Encoded was made, and last edited, in 2013. This is when tribot had no ABC and scripts could be ran for hundreds of hours without bans. Long story short, the botting scene changed and the snippet isn't as safe as it used to be. Please criticize code before copy pasting it.

For your API with double classes, you mention you are writing your own api. This seems rushed, please apply with code that you are confident with. As for your remark about the singleton, that makes no sense. Currently, the class has absolutely no functional difference from being a singleton or not since you return a new object inside every method.

As for underscores in your method names. Please familiarize yourself with the Java Conventions specifically the Naming Conventions (pt 9).

1 person likes this

Share this post


Link to post
Share on other sites

To earn my vote you will need to complete a coding challenge. The challenge is relatively simple, but the way you solve it will determine my vote.

Sort By Distance
Given an unsorted array of RSNPCs, create a method that returns a sorted array in ascending distance from your RSPlayer. This method should be equivalent to NPCs#sortByDistance.

2 people like this

Share this post


Link to post
Share on other sites

I'm voting no.

Your code is way too inconsistent and even AFTER pointing out mistakes on your code, you keep repeating them over and over. This was my speculation for a whole now and wasn't sure to what to vote until your response to Encoded scripting challenge.

 private RSNPC[] targets(String name) {
        return NPCs.find(new Filter<RSNPC>() {
 
            @Override
            public boolean accept(RSNPC a) {
                if (a == null)
                    return false;
                if (a.getDefinition() == null)
                    return false;
 
                return a.getDefinition().getName().equals(name);
            }
        });
    }
  • To begin with, your naming is very vague in this method. How about something like findTarget for your name instead?
  • You are simply just finding a NPC with a name, use NPCS#find(String... name)? This tells me you are not familiar with the API. You keep making inconsistent and weird mistakes. I don't understand why, but if I have that doubt in you, then my vote is no.
  • You are not PROPERLY null checking. With the criticism you were given in the discord chat and maybe in this application, you are still inproperly nullchecking. This code could result in a NPE. This is not something you can just "mess up" on and go back and fix when pointed out. This should be DONE automatically whenever you are scripting. You still haven't grasped that concept yet despite being told so. You need to cache the definition before using it.

 

 if (target.getModel() != null) {
                    p = target.getModel().getTriangles();
                }
  • Once again, you are not properly null checking. You need to cache the model in a variable then use it.
  • Please check out this link

Also, while your code works, it is written in a weird and complicated way.

 

If you were given script writer now, you would continue to write bad code (As shown in your response to Encoded scripting challenge). You keep repeating the same mistakes for some reason despite being told so.  It will take time and practice to begin writing good code. 

1 person likes this

Share this post


Link to post
Share on other sites

As Erick pointed out, your code has potential to throw a NPE. When you do check for null, it often isn't needed. You also over complicated your code, there is no need to use a map.
Here's the solution I came up with.

/**
 * Sorts the given RSNPC array in ascending order by distance to the player's position.
 * @param npcs RSNPC array to be sorted
 * @return sorted RSNPC array or null if npcs was null
 */
RSNPC[] sortByDistance(RSNPC[] npcs) {
    if (npcs != null && npcs.length > 1) {
        RSTile playerPos = Player.getPosition();
        Arrays.asList(npcs).sort((npc1, npc2) -> Integer.compare(playerPos.distanceTo(npc1), playerPos.distanceTo(npc2)));
    }
    return npcs;
}

 

2 people like this

Share this post


Link to post
Share on other sites

You need to stop. Admit you're wrong, because you are. Don't try to justify your actions, because none of them have been justifiable. Admit your answer to Encoded's problem was terrible because it was. Admit your naming conventions are bad. Admit your API knowledge is terrible. Admit your null checks are nearly always wrong. You will never improve unless you admit you're wrong. Just stop.

4 people like this

Share this post


Link to post
Share on other sites

From what other scripters have pointed out, you have a lot to work on. Specifically, null checking properly and caching values before using them, as this was stated several times before me. As well, you should stop trying to justify your actions as Assume stated and instead admit to your mistakes and fix them.

It's a no from me.

Edited by Sphiinx

Share this post


Link to post
Share on other sites

Here's two different ways to multiply, Karatsuba multiplication and the multiplication operator.

public static void main(String... args) {
    System.out.println(karatsubaMultiply(1504, 1320));
    System.out.println(1504 * 1320);
}

public static long karatsubaMultiply(long x, long y){
    //base case:
    if (x < 10 || y < 10) return x * y;

    //length of digits:
    int xSize = String.valueOf(x).length();
    int ySize = String.valueOf(y).length();
    int halfN = Math.max(xSize, ySize) / 2; // store N/2 instead of N
    int splitX = xSize - halfN;  // count the split point from xSize down
    int splitY = ySize - halfN;  // count the split point from ySize down

    //split each number in half (by length of digits):
    long numXHigh = Long.valueOf((String.valueOf(x).substring(0, splitX)));
    long numXLow = Long.valueOf((String.valueOf(x).substring(splitX)));
    long numYHigh = Long.valueOf((String.valueOf(y).substring(0, splitY)));
    long numYLow = Long.valueOf((String.valueOf(y).substring(splitY)));

    //solve multiplications recursively:
    long z0 = karatsubaMultiply(numXLow, numYLow);
    long z1 = karatsubaMultiply((numXHigh + numXLow),(numYHigh + numYLow));
    long z2 = karatsubaMultiply(numXHigh, numYHigh);

    //answer:
    return (long)(z2 * Math.pow(10,halfN*2)) + (long)((z1-z2-z0) * Math.pow(10,halfN)) + (z0);
}

The output is: 

1985280
1985280

They do the same thing, but obviously you're going to use the * operator every time. The multiplication operator is much easier to understand and provides less code that could potentially contain errors.

Share this post


Link to post
Share on other sites

Double posting since I can't edit my above post.



But enough about complexity, the main issue is you've been told about null checking and yet still fail to do so correctly.
return a.getDefinition().getName().equals(name);

getDefinition and getName can return null here since you didn't cache them. Also you should look into Filters.NPCs class or better yet just use NPCs.find(String... names).

if (a == null || b == null)

a and b will never be null

p = target.getModel().getTriangles();

Again you forgot to cache the value from getModel() so your null check from the line above is useless, also target won't be null.

Share this post


Link to post
Share on other sites

You have met the application requirements, carried yourself well within the application, and shown a strong interest in improving your skills and that you can accept criticism and improve upon that.

This is what the Scripter rank is all about.

We're not here to nitpick, bash, or insult any applicants; we want to recognize anyone who shows a strong interest in providing Scripts to the community and base knowledge with the intent to improve and I believe you have showed that. Please work on cleaning up your conventions and ensure you are null checking appropriately. 

Congrats.

5 people like this

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.