mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-28 22:15:54 -04:00
501 lines
11 KiB
Plaintext
501 lines
11 KiB
Plaintext
include library.utils;
|
|
include library.create;
|
|
include library.healing;
|
|
|
|
void end(obj_id self)
|
|
{
|
|
if ( hasObjVar(self, "testPet") )
|
|
{
|
|
obj_id mob = getObjIdObjVar(self, "testPet");
|
|
destroyObject(mob);
|
|
removeObjVar(self, "testPet");
|
|
}
|
|
}
|
|
|
|
void start(obj_id self)
|
|
{
|
|
if ( hasObjVar(self, "testPet") )
|
|
end(self);
|
|
|
|
debugSpeakMsg(self, "--Noodle has begun");
|
|
|
|
createTriggerVolume( "blah", 3, true );
|
|
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
location blah = getLocation(self);
|
|
|
|
blah.x = blah.x + 1.25f;
|
|
|
|
obj_id newmob = create.object(creatureType,blah);
|
|
if ( newmob == null )
|
|
{
|
|
debugSpeakMsg(self, "--Could not spawn pet");
|
|
return;
|
|
}
|
|
detachAllScripts(newmob);
|
|
attachScript(newmob, "test.report_behavior");
|
|
attachScript(newmob, "test.ai_test2");
|
|
setObjVar(self, "testPet", newmob);
|
|
location loc = getLocation(self);
|
|
setHomeLocation(newmob, loc);
|
|
stop(newmob);
|
|
|
|
stopFloating(newmob);
|
|
}
|
|
|
|
void gimme_skills(obj_id speaker)
|
|
{
|
|
grantSkill(speaker, "outdoors_creaturehandler_novice");
|
|
grantSkill(speaker, "outdoors_creaturehandler_taming_01");
|
|
grantSkill(speaker, "outdoors_creaturehandler_taming_02");
|
|
grantSkill(speaker, "outdoors_creaturehandler_taming_03");
|
|
grantSkill(speaker, "outdoors_creaturehandler_taming_04");
|
|
grantSkill(speaker, "outdoors_creaturehandler_training_01");
|
|
grantSkill(speaker, "outdoors_creaturehandler_training_02");
|
|
grantSkill(speaker, "outdoors_creaturehandler_training_03");
|
|
grantSkill(speaker, "outdoors_creaturehandler_training_04");
|
|
grantSkill(speaker, "outdoors_creaturehandler_healing_01");
|
|
grantSkill(speaker, "outdoors_creaturehandler_healing_02");
|
|
grantSkill(speaker, "outdoors_creaturehandler_healing_03");
|
|
grantSkill(speaker, "outdoors_creaturehandler_healing_04");
|
|
grantSkill(speaker, "outdoors_creaturehandler_support_01");
|
|
grantSkill(speaker, "outdoors_creaturehandler_support_02");
|
|
grantSkill(speaker, "outdoors_creaturehandler_support_03");
|
|
grantSkill(speaker, "outdoors_creaturehandler_support_04");
|
|
grantSkill(speaker, "outdoors_creaturehandler_master");
|
|
setObjVar(speaker,"fasttame",1);
|
|
}
|
|
|
|
void start2(obj_id self)
|
|
{
|
|
if ( hasObjVar(self, "testPet") )
|
|
end(self);
|
|
|
|
debugSpeakMsg(self, "--Testing has begun");
|
|
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
location blah = getLocation(self);
|
|
|
|
obj_id newmob = create.object(creatureType,blah);
|
|
if ( newmob == null )
|
|
{
|
|
debugSpeakMsg(self, "--Could not spawn pet");
|
|
return;
|
|
}
|
|
location loc = getLocation(self);
|
|
setHomeLocation(newmob, loc);
|
|
}
|
|
|
|
|
|
void startMounts(obj_id self, obj_id speaker)
|
|
{
|
|
if ( hasObjVar(self, "testPet") )
|
|
end(self);
|
|
|
|
debugSpeakMsg(self, "--Testing has begun");
|
|
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
location blah = getLocation(self);
|
|
|
|
obj_id newmob = create.object(creatureType,blah);
|
|
if ( newmob == null )
|
|
{
|
|
debugSpeakMsg(self, "--Could not spawn pet");
|
|
return;
|
|
}
|
|
location loc = getLocation(self);
|
|
setHomeLocation(newmob, loc);
|
|
attachScript(newmob, "ai.pet_advance");
|
|
|
|
gimme_skills(speaker);
|
|
}
|
|
|
|
|
|
trigger OnTriggerVolumeEntered(string volumeName, obj_id whoTriggeredMe)
|
|
{
|
|
debugSpeakMsg(self,"Trigger Volume Enter");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnTriggerVolumeExited(string volumeName, obj_id whoTriggeredMe)
|
|
{
|
|
debugSpeakMsg(self,"Trigger Volume Exit");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnObjectDamaged( obj_id attacker, obj_id weapon, int damage )
|
|
{
|
|
healing.fullHeal(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnCreatureDamaged(obj_id attacker, obj_id weapon, int[] damage)
|
|
{
|
|
healing.fullHeal(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAttach()
|
|
{
|
|
setObjVar(self, "blahblah", 1);
|
|
|
|
start(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnDetach()
|
|
{
|
|
end(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnHearSpeech(obj_id speaker, string text)
|
|
{
|
|
string[] words = split( text, ' ' );
|
|
|
|
if(words[0].equals("cone"))
|
|
{
|
|
debugSpeakMsg(self, "happy cone cone");
|
|
|
|
float fltConeLength = 64f;
|
|
float fltConeWidth = 15f;
|
|
obj_id objTarget = getLookAtTarget(self);
|
|
obj_id objPlayer = self;
|
|
obj_id[] objDefenders = getCreaturesInCone(objPlayer, objTarget, fltConeLength, fltConeWidth);
|
|
for(int intI = 0; intI<objDefenders.length; intI++)
|
|
{
|
|
debugSpeakMsg(objDefenders[intI], "I am targetsd");
|
|
|
|
|
|
}
|
|
objDefenders = pvpGetTargetsInCone(objPlayer, objPlayer, objTarget, fltConeLength, fltConeWidth);
|
|
for(int intI = 0; intI<objDefenders.length; intI++)
|
|
{
|
|
debugSpeakMsg(objDefenders[intI], "I am PVP targetsd");
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if ( speaker == self )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( words[0].equals("spawn"))
|
|
{
|
|
string toCreate = words[1];
|
|
|
|
location here = getLocation(self);
|
|
// here.x = here.x + 3.25f;
|
|
|
|
obj_id newMob = create.object (toCreate, here);
|
|
|
|
stopFloating(newMob);
|
|
|
|
debugSpeakMsg(newMob, "i am a spatula");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( words[0].equals("start" ))
|
|
{
|
|
start(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if (words[0].equals("start2"))
|
|
{
|
|
start2(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if (words[0].equals("startMounts"))
|
|
{
|
|
startMounts(self,speaker);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if (words[0].equals("setPetType"))
|
|
{
|
|
setObjVar(self,"testPetType",words[1]);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if (words[0].equals("spawnCreatures"))
|
|
{
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
for(int i = 0; i < 10; i++)
|
|
{
|
|
location loc = getLocation(self);
|
|
|
|
create.object(creatureType,loc);
|
|
}
|
|
}
|
|
else if (words[0].equals("spawnRandom300"))
|
|
{
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
for(int i = 0; i < 300; i++)
|
|
{
|
|
// int x = rand(1,2000);
|
|
// int z = rand(1,2000);
|
|
|
|
location loc = getLocation(self);
|
|
|
|
// loc.x += (x - 1000);
|
|
// loc.z += (z - 1000);
|
|
|
|
obj_id mob = create.object(creatureType,loc);
|
|
|
|
loiterTarget(mob,self,10,30,1,2);
|
|
}
|
|
}
|
|
else if (words[0].equals("reload"))
|
|
{
|
|
debugSpeakMsg(self, "Reloading node " + words[1]);
|
|
|
|
obj_id idToReload = utils.stringToObjId(words[1]);
|
|
|
|
obj_id[] ids = new obj_id[1];
|
|
|
|
ids[0] = idToReload;
|
|
|
|
reloadPathNodes(ids);
|
|
}
|
|
else if (words[0].equals("testSwarm"))
|
|
{
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
for(int i = 0; i < 1; i++)
|
|
{
|
|
location loc = getLocation(self);
|
|
|
|
obj_id mob = create.object(creatureType,loc);
|
|
|
|
swarm(mob,speaker);
|
|
|
|
setMovementRun(mob);
|
|
}
|
|
}
|
|
else if (words[0].equals("testSwarm2"))
|
|
{
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
for(int i = 0; i < 1; i++)
|
|
{
|
|
location loc = getLocation(self);
|
|
|
|
obj_id mob = create.object(creatureType,loc);
|
|
|
|
swarm(mob,speaker,8.0f);
|
|
|
|
setMovementRun(mob);
|
|
}
|
|
}
|
|
else if (words[0].equals("testSwarm3"))
|
|
{
|
|
String creatureType = getStringObjVar(self,"testPetType");
|
|
|
|
for(int i = 0; i < 1; i++)
|
|
{
|
|
location loc = getLocation(self);
|
|
|
|
obj_id mob = create.object(creatureType,loc);
|
|
|
|
swarm(mob,speaker,16.0f);
|
|
|
|
setMovementRun(mob);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ( !hasObjVar(self, "testPet") )
|
|
{
|
|
// debugSpeakMsg(self, "--I have not been setup to test");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id mob = getObjIdObjVar(self, "testPet");
|
|
|
|
if ( words[0].equals("follow" ))
|
|
{
|
|
debugSpeakMsg(self, "--Now following");
|
|
follow(mob, speaker, 2f, 5f);
|
|
}
|
|
else if ( words[0].equals("followOffset" ))
|
|
{
|
|
debugSpeakMsg(self, "--Now following");
|
|
follow(mob, speaker, new location(2,0,0,""));
|
|
}
|
|
else if ( words[0].equals("swarm"))
|
|
{
|
|
debugSpeakMsg(self,"--Swarm");
|
|
swarm(mob,speaker);
|
|
}
|
|
else if ( words[0].equals("swarmit"))
|
|
{
|
|
obj_id target = utils.stringToObjId(words[1]);
|
|
|
|
debugSpeakMsg(self,"--Swarming target");
|
|
|
|
swarm(mob,target);
|
|
}
|
|
else if (words[0].equals("wander"))
|
|
{
|
|
debugSpeakMsg(self, "--Wandering");
|
|
wander(mob);
|
|
}
|
|
else if (words[0].equals("loiter"))
|
|
{
|
|
debugSpeakMsg(self, "--Loitering");
|
|
|
|
const location home = getLocation(mob);
|
|
|
|
loiterLocation(mob, home, 15f, 20f, 1f, 2f);
|
|
}
|
|
else if (words[0].equals("loiterNear"))
|
|
{
|
|
debugSpeakMsg(self, "--Loitering");
|
|
loiterTarget(mob, self, 0, 5, 0, 0);
|
|
}
|
|
else if (words[0].equals("stop"))
|
|
{
|
|
debugSpeakMsg(self, "--Stop");
|
|
stop(mob);
|
|
}
|
|
else if (words[0].equals("pathHome"))
|
|
{
|
|
debugSpeakMsg(self, "--Going home");
|
|
location loc = getLocation(self);
|
|
pathTo(mob, loc);
|
|
}
|
|
else if (words[0].equals("pathAway"))
|
|
{
|
|
debugSpeakMsg(self, "--Going to speaker");
|
|
location loc = getLocation(speaker);
|
|
pathTo(mob, loc);
|
|
}
|
|
else if (words[0].equals("moveX"))
|
|
{
|
|
debugSpeakMsg(self, "--Going to speaker");
|
|
location loc = getLocation(mob);
|
|
loc.x += 1;
|
|
pathTo(mob, loc);
|
|
}
|
|
else if (words[0].equals("flee"))
|
|
{
|
|
debugSpeakMsg(self, "--Fleeing");
|
|
flee(mob, speaker, 5, 10);
|
|
}
|
|
else if (words[0].equals("face"))
|
|
{
|
|
debugSpeakMsg(self, "--Facing target");
|
|
faceToBehavior(mob,speaker);
|
|
}
|
|
else if (words[0].equals("faceBehavior"))
|
|
{
|
|
debugSpeakMsg(self, "--Facing behavior");
|
|
faceToBehavior(mob,speaker);
|
|
}
|
|
else if (words[0].equals("end"))
|
|
{
|
|
debugSpeakMsg(self, "--Done with testing");
|
|
end(self);
|
|
}
|
|
else if (words[0].equals("anger"))
|
|
{
|
|
debugSpeakMsg(self, "--Angry at speaker");
|
|
addToMentalStateToward(mob, speaker, ANGER, 40);
|
|
}
|
|
else if (words[0].equals("frenzy"))
|
|
{
|
|
debugSpeakMsg(self, "--Frenzying toward speaker");
|
|
addToMentalStateToward(mob, speaker, ANGER, 100);
|
|
}
|
|
else if (words[0].equals("attack"))
|
|
{
|
|
debugSpeakMsg(self, "--Attacking speaker");
|
|
addToMentalStateToward(mob, speaker, ANGER, 100, BEHAVIOR_ATTACK);
|
|
}
|
|
else if (words[0].equals("attack"))
|
|
{
|
|
debugSpeakMsg(self, "--Attacking speaker");
|
|
addToMentalStateToward(mob, speaker, ANGER, 100, BEHAVIOR_ATTACK);
|
|
}
|
|
else if (words[0].equals("upright"))
|
|
{
|
|
debugSpeakMsg(self, "--setPosture(self, POSTURE_UPRIGHT)");
|
|
setPosture(mob, POSTURE_UPRIGHT);
|
|
}
|
|
else if (words[0].equals("crouch"))
|
|
{
|
|
debugSpeakMsg(self, "--setPosture(self, POSTURE_CROUCHED)");
|
|
setPosture(mob, POSTURE_CROUCHED);
|
|
}
|
|
else if (words[0].equals("prone"))
|
|
{
|
|
debugSpeakMsg(self, "--setPosture(self, POSTURE_PRONE)");
|
|
setPosture(mob, POSTURE_PRONE);
|
|
}
|
|
else if (words[0].equals("lie"))
|
|
{
|
|
debugSpeakMsg(self, "--setPosture(self, POSTURE_LYING_DOWN)");
|
|
setPosture(mob, POSTURE_LYING_DOWN);
|
|
}
|
|
else if (words[0].equals("drive"))
|
|
{
|
|
debugSpeakMsg(self, "--setPosture(self, POSTURE_DRIVING_VEHICLE)");
|
|
setPosture(mob, POSTURE_DRIVING_VEHICLE);
|
|
}
|
|
else if (words[0].equals("stand"))
|
|
{
|
|
debugSpeakMsg(self, "--setLocomotion(self, LOCOMOTION_STANDING");
|
|
setLocomotion(mob, LOCOMOTION_STANDING);
|
|
}
|
|
else if (words[0].equals("walk"))
|
|
{
|
|
debugSpeakMsg(self, "--setLocomotion(self, LOCOMOTION_WALKING");
|
|
setLocomotion(mob, LOCOMOTION_WALKING);
|
|
}
|
|
else if (words[0].equals("run"))
|
|
{
|
|
debugSpeakMsg(self, "--setLocomotion(self, LOCOMOTION_RUNNING");
|
|
setLocomotion(mob, LOCOMOTION_RUNNING);
|
|
}
|
|
else if (words[0].equals("fast"))
|
|
{
|
|
debugSpeakMsg(self, "--setMovementRun(self)");
|
|
setMovementRun(mob);
|
|
}
|
|
else if (words[0].equals("slow"))
|
|
{
|
|
debugSpeakMsg(self, "--setMovementWalk(self)");
|
|
setMovementWalk(mob);
|
|
}
|
|
else if (words[0].equals("pathToName"))
|
|
{
|
|
debugSpeakMsg(self, "--Going to waypoint " + words[1]);
|
|
pathTo(mob,words[1]);
|
|
}
|
|
else if (words[0].equals("canSee"))
|
|
{
|
|
if(canSee(mob,speaker))
|
|
{
|
|
debugSpeakMsg(mob,"Can see you");
|
|
}
|
|
else
|
|
{
|
|
debugSpeakMsg(mob,"Can NOT see you");
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|