Skip to content

Commit

Permalink
Fixed stock size bug. Made cancel reload work!
Browse files Browse the repository at this point in the history
  • Loading branch information
jguevara committed Apr 6, 2018
1 parent b677124 commit 91383cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Behaviors/jj_weapon/edittime.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ AddCmpParam("Comparison", "Time in miliseconds to compare.");
AddNumberParam("Last shoot time", "Last shoot time in miliseconds.");
AddCondition(8, 0, "Last shoot time", "", "{my} Last shoot time {0} {1}", "True when has passed some time since last shoot.", "lastShootTime");

AddCondition(9, 0, "Is reloading", "", "{my} is reloading", "True when the weapon is currently reloading.", "isReloading");


//////////////////////////////////////////////////////////////
// Actions
Expand Down Expand Up @@ -96,7 +98,7 @@ AddAction(11, 0, "Set reload key", "", "Reload key for {my} is {0} now.", "Set t
AddObjectParam("Bullet", "Choose the bullet object for weapon");
AddAction(12, 0, "Set bullet instance", "", "Bullet of {my} now is {0}.", "Set the weapon bullet type.", "setBullet");

AddAction(13, 0, "Reload", "", "{my} reload now.", "Start reload.", "simulateReload");
AddAction(16, 0, "Reload", "", "{my} reload now.", "Start reload.", "simulateReload");

AddAction(14, 0, "Cancel reload", "", "{my} cancel reload.", "Cancel the current reload.", "cancelReload");

Expand Down
7 changes: 6 additions & 1 deletion Behaviors/jj_weapon/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ cr.behaviors.jj_Weapon = function (runtime) {
if (this.reloadCancel) {
this.reload = false;
this.runtime.trigger(this.behavior.cnds.isReloadCanceled, this.inst);
this.reloadCancel = false;
}

if (this.reload && Date.now() - this.start_reload_time >= this.reload_time && this.clip_size != 0 && this.clip_bullets_count != -1 && this.bullets_count != 0) {
Expand Down Expand Up @@ -325,6 +326,10 @@ cr.behaviors.jj_Weapon = function (runtime) {
var was_reload_start = this.was_reload_start;
this.was_reload_start = false;
return was_reload_start;
};

cnds.isReloading = function () {
return this.reload;
};

cnds.isReloadFinish = function () {
Expand Down Expand Up @@ -367,7 +372,7 @@ cr.behaviors.jj_Weapon = function (runtime) {
};

acts.cancelReload = function () {
if (this.was_reload_start) {
if (this.reload) {
this.reloadCancel = true;
}
};
Expand Down

0 comments on commit 91383cf

Please sign in to comment.