-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add agatus proxy #323
Closed
Closed
add agatus proxy #323
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/github/manolo8/darkbot/core/objects/facades/AgatusEventProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.manolo8.darkbot.core.objects.facades; | ||
|
||
import eu.darkbot.api.managers.AgatusAPI; | ||
|
||
public class AgatusEventProxy extends DefaultNpcEventProxy implements AgatusAPI { | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/github/manolo8/darkbot/core/objects/facades/DefaultNpcEventProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.github.manolo8.darkbot.core.objects.facades; | ||
|
||
import com.github.manolo8.darkbot.core.itf.Updatable; | ||
import com.github.manolo8.darkbot.core.utils.ByteUtils; | ||
import eu.darkbot.api.managers.DefaultNpcEventAPI; | ||
|
||
import static com.github.manolo8.darkbot.Main.API; | ||
|
||
public class DefaultNpcEventProxy extends Updatable implements DefaultNpcEventAPI { | ||
public double time; | ||
public String eventID; | ||
public String npcName; | ||
public String eventDescriptionID; | ||
public String eventDescription; | ||
public String npcLeftDescription; | ||
public int npcCount; | ||
public int bossCount; | ||
public boolean eventActive; | ||
|
||
@Override | ||
public double getRemainingTime() { | ||
return time; | ||
} | ||
|
||
@Override | ||
public String getNpcName() { | ||
return npcName; | ||
} | ||
|
||
@Override | ||
public String getEventID() { | ||
return eventID; | ||
} | ||
|
||
@Override | ||
public String getEventDescription() { | ||
return eventDescription; | ||
} | ||
|
||
@Override | ||
public String getNpcLeftDescription() { | ||
return npcLeftDescription; | ||
} | ||
|
||
@Override | ||
public int npcLeft() { | ||
return npcCount; | ||
} | ||
|
||
@Override | ||
public int bossNpcLeft() { | ||
return bossCount; | ||
} | ||
|
||
@Override | ||
public DefaultNpcEventAPI.Status getStatus() { | ||
if (this.eventActive) { | ||
return Status.ACTIVE; | ||
} else { | ||
return Status.INACTIVE; | ||
} | ||
} | ||
|
||
public void update() { | ||
long data = API.readMemoryLong(address + 48) & ByteUtils.ATOM_MASK; | ||
|
||
this.eventActive = API.readBoolean(data + 0x44); | ||
this.time = API.readMemoryDouble(API.readMemoryLong(data + 0x50) + 0x38); | ||
this.eventDescription = API.readMemoryString(API.readMemoryLong(data + 0x60)); | ||
this.npcLeftDescription = API.readMemoryString(API.readMemoryLong(data + 0x68)); | ||
this.eventDescriptionID = API.readMemoryString(API.readMemoryLong(data + 0x70)); | ||
this.eventID = API.readMemoryString(API.readMemoryLong(data + 0x78)); | ||
this.npcName = API.readMemoryString(API.readMemoryLong(data + 0x80)); | ||
this.npcCount = API.readInt(data + 0x88); | ||
this.bossCount = API.readInt(data + 0x90); | ||
} | ||
} |
73 changes: 1 addition & 72 deletions
73
src/main/java/com/github/manolo8/darkbot/core/objects/facades/NpcEventProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,6 @@ | ||
package com.github.manolo8.darkbot.core.objects.facades; | ||
|
||
import com.github.manolo8.darkbot.core.itf.Updatable; | ||
import com.github.manolo8.darkbot.core.utils.ByteUtils; | ||
import eu.darkbot.api.managers.NpcEventAPI; | ||
|
||
import static com.github.manolo8.darkbot.Main.API; | ||
|
||
public class NpcEventProxy extends Updatable implements NpcEventAPI { | ||
public double time; | ||
public String eventID; | ||
public String eventName; | ||
public String eventDescriptionID; | ||
public String eventDescription; | ||
public String npcLeftDescription; | ||
public int npcCount; | ||
public int bossCount; | ||
public boolean eventActive; | ||
|
||
@Override | ||
public double getRemainingTime() { | ||
return time; | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return eventName; | ||
} | ||
|
||
@Override | ||
public String getEventID() { | ||
return eventID; | ||
} | ||
|
||
@Override | ||
public String getEventDescription() { | ||
return eventDescription; | ||
} | ||
|
||
@Override | ||
public String getNpcLeftDescription() { | ||
return npcLeftDescription; | ||
} | ||
|
||
@Override | ||
public int npcLeft() { | ||
return npcCount; | ||
} | ||
|
||
@Override | ||
public int bossNpcLeft() { | ||
return bossCount; | ||
} | ||
|
||
@Override | ||
public NpcEventAPI.Status getStatus() { | ||
if (this.eventActive) { | ||
return Status.ACTIVE; | ||
} else { | ||
return Status.INACTIVE; | ||
} | ||
} | ||
|
||
public void update() { | ||
long data = API.readMemoryLong(address + 48) & ByteUtils.ATOM_MASK; | ||
|
||
this.eventActive = API.readBoolean(data + 0x44); | ||
this.time = API.readMemoryDouble(API.readMemoryLong(data + 0x50) + 0x38); | ||
this.eventDescription = API.readMemoryString(API.readMemoryLong(data + 0x60)); | ||
this.npcLeftDescription = API.readMemoryString(API.readMemoryLong(data + 0x68)); | ||
this.eventDescriptionID = API.readMemoryString(API.readMemoryLong(data + 0x70)); | ||
this.eventID = API.readMemoryString(API.readMemoryLong(data + 0x78)); | ||
this.eventName = API.readMemoryString(API.readMemoryLong(data + 0x80)); | ||
this.npcCount = API.readInt(data + 0x88); | ||
this.bossCount = API.readInt(data + 0x90); | ||
} | ||
public class NpcEventProxy extends DefaultNpcEventProxy implements NpcEventAPI{ | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a pretty bad pattern to be extending a class without any changes at all. Is the issue here simply that this should be a higher-level api?
Instead of a
DefaultNpcEventAPI
maybe it should be aNpcEventAPI
which returns a list or a map ofNpcEvent
objects.The implementation can use the Agatus proxy and the generic npc event proxy, and in the plugin-side you can:
NpcEventAPI.getEvent(EventType.AGATUS)
to get anNpcEvent
with the info related to agatus.