who isn't sick of converting the freaking scripts? this negates the need

This commit is contained in:
DarthArgus
2015-11-24 09:27:45 -06:00
parent 2e64106bc8
commit bbee2d328c
11077 changed files with 2604347 additions and 3425075 deletions
@@ -0,0 +1,35 @@
package script.systems.buff_builder;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.utils;
public class buff_builder_cancel extends script.base_script
{
public buff_builder_cancel()
{
}
public static final String SCRIPT_BUFF_BUILDER_CANCEL = "systems.buff_builder.buff_builder_cancel";
public int OnLogin(obj_id self) throws InterruptedException
{
if (isIdValid(self))
{
detachScript(self, SCRIPT_BUFF_BUILDER_CANCEL);
}
return SCRIPT_CONTINUE;
}
public int OnBuffBuilderCanceled(obj_id self) throws InterruptedException
{
if (isIdValid(self))
{
detachScript(self, SCRIPT_BUFF_BUILDER_CANCEL);
}
return SCRIPT_CONTINUE;
}
}
@@ -1,30 +0,0 @@
/* Title: buff_builder_cancel
* Description: trigger when buff builder canceled
*/
/***** INCLUDES ********************************************************/
include library.utils;
/***** CONSTANTS *******************************************************/
const string SCRIPT_BUFF_BUILDER_CANCEL = "systems.buff_builder.buff_builder_cancel";
/***** TRIGGERS ********************************************************/
trigger OnLogin()
{
if (isIdValid(self))
detachScript(self, SCRIPT_BUFF_BUILDER_CANCEL);
return SCRIPT_CONTINUE;
}
trigger OnBuffBuilderCanceled()
{
if (isIdValid(self))
detachScript(self, SCRIPT_BUFF_BUILDER_CANCEL);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,151 @@
package script.systems.buff_builder;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.buff;
import script.library.money;
import script.library.performance;
import script.library.prose;
import script.library.scheduled_drop;
import script.library.utils;
public class buff_builder_response extends script.base_script
{
public buff_builder_response()
{
}
public static final String DATATABLE_BUFF_BUILDER = "datatables/buff/buff_builder.iff";
public static final String SCRIPT_BUFF_BUILDER_RESPONSE = "systems.buff_builder.buff_builder_response";
public static final String SCRIPT_BUFF_BUILDER_CANCEL = "systems.buff_builder.buff_builder_cancel";
public static final String BUILDABUFF_NAME = "buildabuff_inspiration";
public static final float BUFF_BUILDER_RANGE = 8.0f;
public int OnInitialize(obj_id self) throws InterruptedException
{
if (hasScript(self, SCRIPT_BUFF_BUILDER_RESPONSE))
{
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
}
return SCRIPT_CONTINUE;
}
public int OnLogin(obj_id self) throws InterruptedException
{
if (hasScript(self, SCRIPT_BUFF_BUILDER_RESPONSE))
{
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
}
return SCRIPT_CONTINUE;
}
public int OnImmediateLogout(obj_id self) throws InterruptedException
{
if (hasScript(self, SCRIPT_BUFF_BUILDER_RESPONSE))
{
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
}
return SCRIPT_CONTINUE;
}
public int OnBuffBuilderValidate(obj_id self, obj_id bufferId, obj_id recipientId, int startingTime, int bufferRequiredCredits, int recipientPaidCredits, boolean accepted, String[] buffComponentKeys, int[] buffComponentValues) throws InterruptedException
{
if (!accepted)
{
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
float distance = (getLocation(self)).distance(getLocation(recipientId));
if (distance > BUFF_BUILDER_RANGE)
{
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
buffBuilderValidated(bufferId, recipientId, startingTime, bufferRequiredCredits, recipientPaidCredits, accepted, buffComponentKeys, buffComponentValues);
return SCRIPT_CONTINUE;
}
public int OnBuffBuilderCompleted(obj_id self, obj_id bufferId, obj_id recipientId, int startingTime, int bufferRequiredCredits, int recipientPaidCredits, boolean accepted, String[] buffComponentKeys, int[] buffComponentValues) throws InterruptedException
{
if (bufferRequiredCredits > 0 && !money.pay(recipientId, bufferId, bufferRequiredCredits, "", null))
{
sendSystemMessage(recipientId, new string_id("spam", "buildabuff_nsf_buffee"));
sendSystemMessage(bufferId, new string_id("spam", "buildabuff_nsf_buffer"));
return SCRIPT_CONTINUE;
}
if (buffComponentKeys.length > 0 && buffComponentValues.length > 0)
{
utils.setScriptVar(recipientId, "performance.buildabuff.buffComponentKeys", buffComponentKeys);
utils.setScriptVar(recipientId, "performance.buildabuff.buffComponentValues", buffComponentValues);
utils.setScriptVar(recipientId, "performance.buildabuff.bufferId", bufferId);
float currentBuffTime = 30f;
if (utils.hasScriptVar(recipientId, performance.VAR_PERFORM_INSPIRATION))
{
currentBuffTime = utils.getFloatScriptVar(recipientId, performance.VAR_PERFORM_INSPIRATION);
}
if (buff.hasBuff(recipientId, "buildabuff_inspiration"))
{
buff.removeBuff(recipientId, "buildabuff_inspiration");
}
if (bufferId == recipientId)
{
currentBuffTime = performance.inspireGetMaxDuration(bufferId);
}
buff.applyBuff(recipientId, "buildabuff_inspiration", currentBuffTime);
if (utils.hasScriptVar(recipientId, "performance.inspireMaxReached"))
{
utils.removeScriptVar(recipientId, "performance.inspireMaxReached");
}
if (isIdValid(bufferId))
{
obj_id inv = utils.getInventoryContainer(bufferId);
boolean canDrop = scheduled_drop.canDropCard(scheduled_drop.SYSTEM_ENTERTAINER);
boolean hasDelay = scheduled_drop.hasCardDelay(bufferId, scheduled_drop.SYSTEM_ENTERTAINER);
if (isGod(bufferId) && hasObjVar(bufferId, "qa_tcg_always_drop"))
{
canDrop = true;
hasDelay = false;
}
if (isIdValid(inv) && canDrop && !hasDelay && isPlayerActive(bufferId))
{
obj_id card = scheduled_drop.dropCard(scheduled_drop.SYSTEM_ENTERTAINER, inv);
if (isIdValid(card))
{
String[] cardNameList = split(getName(card), ':');
if (cardNameList != null && cardNameList.length > 1)
{
string_id cardName = new string_id(cardNameList[0], cardNameList[1]);
String name = getString(cardName);
prose_package pp = new prose_package();
pp = prose.setStringId(pp, new string_id("spam", "tcg_space_loot"));
pp = prose.setTU(pp, name);
sendSystemMessageProse(bufferId, pp);
}
}
}
else
{
if (isGod(bufferId) && hasObjVar(bufferId, "qa_tcg"))
{
sendSystemMessageTestingOnly(bufferId, "QA TCG ENTERTAINER NOT DROPPED. Random chance passed? " + canDrop + " Has Card Delay? " + hasDelay);
}
}
utils.setScriptVar(bufferId, scheduled_drop.PLAYER_SCRIPTVAR_DROP_TIME, getGameTime());
}
}
else
{
if (hasScript(recipientId, SCRIPT_BUFF_BUILDER_CANCEL))
{
detachScript(recipientId, SCRIPT_BUFF_BUILDER_CANCEL);
}
}
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
public int OnBuffBuilderCanceled(obj_id self) throws InterruptedException
{
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
}
@@ -1,234 +0,0 @@
/*Title: buff_builder_response
* Description: triggers for buff builder
*/
/***** INCLUDES ********************************************************/
include library.buff;
include library.money;
include library.performance;
include library.prose;
include library.scheduled_drop;
include library.utils;
/***** CONSTANTS *******************************************************/
const string DATATABLE_BUFF_BUILDER = "datatables/buff/buff_builder.iff";
const string SCRIPT_BUFF_BUILDER_RESPONSE = "systems.buff_builder.buff_builder_response";
const string SCRIPT_BUFF_BUILDER_CANCEL = "systems.buff_builder.buff_builder_cancel";
const string BUILDABUFF_NAME = "buildabuff_inspiration";
const float BUFF_BUILDER_RANGE = 8.0f;
/***** TRIGGERS ********************************************************/
trigger OnInitialize()
{
// debugSpeakMsg(self, "enter buff_builder_reponse.OnInitialize()");
if (hasScript(self, SCRIPT_BUFF_BUILDER_RESPONSE))
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
trigger OnLogin()
{
// debugSpeakMsg(self, "enter buff_builder_reponse.OnLogin()");
if (hasScript(self, SCRIPT_BUFF_BUILDER_RESPONSE))
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
trigger OnImmediateLogout()
{
// debugSpeakMsg(self, "enter buff_builder_reponse.OnImmediateLogout");
if (hasScript(self, SCRIPT_BUFF_BUILDER_RESPONSE))
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
// TODO: look at OnImmediateLogout in image_design_response.script
return SCRIPT_CONTINUE;
}
trigger OnBuffBuilderValidate(obj_id bufferId, obj_id recipientId, int startingTime, int bufferRequiredCredits, int recipientPaidCredits, boolean accepted, String[] buffComponentKeys, int[] buffComponentValues)
{
//debugSpeakMsg(self, "enter buff_builder_reponse.OnBuffBuilderValidate");
if (!accepted)
{
// debugSpeakMsg(self, "enter buff_builder_reponse.OnBuffBuilderValidate - not accepted");
/*
TODO: handle this
LOG("LOG_CHANNEL", self + " ->" + getFirstName(target) + " has refused your image design offer.");
prose_package pp = prose.getPackage(SID_OFFER_DECLINED, target);
sendSystemMessageProse(self, pp);
utils.removeScriptVar(self, VAR_IMAGE_DESIGN_TIMESTAMP);
if (isIdValid(target))
utils.removeScriptVar(target, VAR_IMAGE_DESIGN_CONFIRM);
*/
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
// Check to see that target is still in range.
float distance = getLocation(self).distance(getLocation(recipientId));
if (distance > BUFF_BUILDER_RANGE)
{
// debugSpeakMsg(self, "enter buff_builder_reponse.OnBuffBuilderValidate distance too great");
/*
TODO: handle this
LOG("LOG_CHANNEL", self + " ->Your target has moved too far away.");
sendSystemMessage(self, SID_OUT_OF_RANGE);
LOG("LOG_CHANNEL", target + " ->You are now too far away from the image designer.");
sendSystemMessage(target, SID_OUT_OF_RANGE_TARGET);
utils.removeScriptVar(self, VAR_IMAGE_DESIGN_TIMESTAMP);
if (isIdValid(target))
utils.removeScriptVar(target, VAR_IMAGE_DESIGN_CONFIRM);
*/
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
/*
TODO: handle any additional validation that is needed
// Subtract the costs for the action.
int cost = IMAGE_DESIGN_COST_BASE * designType;
int action = getAttrib(self, ACTION);
LOG("LOG_CHANNEL", "cost ->" + cost + " action ->" + action);
if (cost > action)
{
LOG("LOG_CHANNEL", self + " ->You don't have enough mind to do that.");
sendSystemMessage(self, SID_INSUFFICIENT_ACTION);
utils.removeScriptVar(self, VAR_IMAGE_DESIGN_TIMESTAMP);
if (isIdValid(target))
utils.removeScriptVar(target, VAR_IMAGE_DESIGN_CONFIRM);
detachScript(self, SCRIPT_IMAGE_DESIGNER_RESPONSE);
return SCRIPT_CONTINUE;
}
drainAttributes(self, cost, 0);
*/
// debugSpeakMsg(self, "enter buff_builder_reponse.OnBuffBuilderValidate -- before buffbuildervalidatedcall");
buffBuilderValidated(bufferId, recipientId, startingTime, bufferRequiredCredits, recipientPaidCredits, accepted, buffComponentKeys, buffComponentValues);
return SCRIPT_CONTINUE;
}
trigger OnBuffBuilderCompleted(obj_id bufferId, obj_id recipientId, int startingTime, int bufferRequiredCredits, int recipientPaidCredits, boolean accepted, String[] buffComponentKeys, int[] buffComponentValues)
{
if(bufferRequiredCredits > 0 && !money.pay(recipientId, bufferId, bufferRequiredCredits, "", null) )
{
sendSystemMessage(recipientId, new string_id("spam", "buildabuff_nsf_buffee") );
sendSystemMessage(bufferId, new string_id("spam", "buildabuff_nsf_buffer") );
return SCRIPT_CONTINUE;
}
//debugSpeakMsg(self, "!!!!!! enter buff_builder_reponse.OnBuffBuilderCompleted");
if(buffComponentKeys.length > 0 && buffComponentValues.length > 0)
{
utils.setScriptVar(recipientId, "performance.buildabuff.buffComponentKeys", buffComponentKeys);
utils.setScriptVar(recipientId, "performance.buildabuff.buffComponentValues", buffComponentValues);
utils.setScriptVar(recipientId, "performance.buildabuff.bufferId", bufferId);
float currentBuffTime = 30f;
if(utils.hasScriptVar(recipientId, performance.VAR_PERFORM_INSPIRATION))
{
currentBuffTime = utils.getFloatScriptVar(recipientId, performance.VAR_PERFORM_INSPIRATION);
}
if(buff.hasBuff(recipientId, "buildabuff_inspiration"))
buff.removeBuff(recipientId, "buildabuff_inspiration");
if(bufferId == recipientId)
{
currentBuffTime = performance.inspireGetMaxDuration(bufferId);
}
buff.applyBuff(recipientId, "buildabuff_inspiration", currentBuffTime);
if(utils.hasScriptVar(recipientId, "performance.inspireMaxReached"))
utils.removeScriptVar(recipientId, "performance.inspireMaxReached");
if(isIdValid(bufferId))
{
// TCG Object Generation
obj_id inv = utils.getInventoryContainer(bufferId);
boolean canDrop = scheduled_drop.canDropCard(scheduled_drop.SYSTEM_ENTERTAINER);
boolean hasDelay = scheduled_drop.hasCardDelay(bufferId, scheduled_drop.SYSTEM_ENTERTAINER);
if(isGod(bufferId) && hasObjVar(bufferId, "qa_tcg_always_drop"))
{
canDrop = true;
hasDelay = false;
}
if(isIdValid(inv) && canDrop && !hasDelay && isPlayerActive(bufferId))
{
obj_id card = scheduled_drop.dropCard(scheduled_drop.SYSTEM_ENTERTAINER, inv);
if(isIdValid(card))
{
string [] cardNameList = split(getName(card), ':');
if(cardNameList != null && cardNameList.length > 1)
{
string_id cardName = new string_id(cardNameList[0], cardNameList[1]);
string name = getString(cardName);
prose_package pp = new prose_package();
pp = prose.setStringId(pp, new string_id("spam", "tcg_space_loot"));
pp = prose.setTU(pp, name);
sendSystemMessageProse(bufferId, pp);
}
}
}
else
{
if(isGod(bufferId) && hasObjVar(bufferId, "qa_tcg"))
{
sendSystemMessageTestingOnly(bufferId, "QA TCG ENTERTAINER NOT DROPPED. Random chance passed? " + canDrop + " Has Card Delay? " + hasDelay);
}
}
utils.setScriptVar(bufferId, scheduled_drop.PLAYER_SCRIPTVAR_DROP_TIME, getGameTime());
}
}
// The above may not be true if the entertainer and patron both click accept without applying any buffs, something the client
// should ideally not allow to happen but it currently does leaving that person in a bad state until they log. So if this happens
// remove the "cancel" script from the player which the client normally removes on cancel and complete. This corrects this issue script-side.
else
{
if(hasScript(recipientId, SCRIPT_BUFF_BUILDER_CANCEL))
{
detachScript(recipientId, SCRIPT_BUFF_BUILDER_CANCEL);
}
}
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
trigger OnBuffBuilderCanceled()
{
//debugSpeakMsg(self, "enter buff_builder_reponse.OnBuffBuilderCanceled");
detachScript(self, SCRIPT_BUFF_BUILDER_RESPONSE);
return SCRIPT_CONTINUE;
}
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *******************************************************/