PDA

View Full Version : 508/525 Vengtimer event 508/525.



Nathan
November 21st, 2010, 01:55
Yes im owner nathan of *********** so dont say i leeched.

instead of having vengTimer in process and idk if this code is correct but works fine for me. Note: im trying to use events if this event is wrong correct me plz

player.java.

My method

public void vengtimer(final Player p) {
EventManager.getSingleton().addEvent(
new Event() {
public void execute(EventContainer c) {
if (vengeanceDelay > 0) {
vengeanceDelay--;
}
if (vengeanceDelay == 0) {
vengeanceDelay = -1;
c.stop();
}
}
}, 30000);
};

Leanbows method.

public void vengtimer(final Player p) {
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer c) {
if (vengeanceDelay > 0) {
vengeanceDelay--;
vengeanceDelay = -1;
c.stop();
}
}
}, 30000);
};


both methods work so yh.

declare all ints ect.

PlayerMagic.java

search
Code:

case 14: //Vengeance

implent these 2 at the bottom of the code.

Code:

p.vengtimer(p);
p.vengeanceDelay = 1;

brkownz
November 21st, 2010, 19:25
It's the same method, leanbows is much more cleaner tbh.

dymnExtigo
December 10th, 2011, 19:21
It works for most cases. I experienced no real performance loss using the event system. Are you sure you arent doing slow stuff in your event code? Does calling setCollisionEvent"blah" make a performance difference already even when no DirectObject is accepting "blah"?

dymnExtigo
December 11th, 2011, 04:43
I havent experienced such a large slowdown. Happen to have some sample code that shows that its very slow?
Also, you should only call setCollisionEvent on the OdeSpaces that you really want an event from.