DropsBombBehavior
by rennie moffat · in Torque Game Builder · 09/22/2009 (2:24 pm) · 0 replies
edit. I posted earlier, that problem was solved. I have a new issue tho. my player has two weapons bomb and missile. the player shoots missiles for missiles and missiles for bombs. when the image projectile for bomb is set to bomb, he shoots nothing. but can shoot missile. I have named my image bomb properly, beyond that I am unsure what to do.
EditSolution:
I am not sure why, but I renamed my image map with a hyphen. So BombImageMap became Bomb_ImageMap and it works. Surprising.
original:
Hi, I have taken the Shoots.cs file from TGB behaviors and made a few adjustments in order to make it look to drop a bomb rather than shoot a missile. However the problem is, due to similar names in files beyond the behavior title, I think TGB can not separate them. So in order for my player to have both I renamed the a few or all of the "fire" words to "drop" thinking this was no issue, well I still can not have this behavior to work. Can someone please see if you notice anything wrong with it that I am missing?
edit:solution:
instead of renaming commands just renaame the cs file and the behavior itself.
EditSolution:
I am not sure why, but I renamed my image map with a hyphen. So BombImageMap became Bomb_ImageMap and it works. Surprising.
original:
Hi, I have taken the Shoots.cs file from TGB behaviors and made a few adjustments in order to make it look to drop a bomb rather than shoot a missile. However the problem is, due to similar names in files beyond the behavior title, I think TGB can not separate them. So in order for my player to have both I renamed the a few or all of the "fire" words to "drop" thinking this was no issue, well I still can not have this behavior to work. Can someone please see if you notice anything wrong with it that I am missing?
edit:solution:
instead of renaming commands just renaame the cs file and the behavior itself.
if (!isObject(DropsBombBehavior))
{
%template = new BehaviorTemplate(DropsBombBehavior);
%template.friendlyName = "Drops Bomb";
%template.behaviorType = "Input";
%template.description = "Drops a bomb";
%template.addBehaviorField(projectile, "The projectile to clone and drop", object, "", t2dSceneObject);
%template.addBehaviorField(dropKey, "The key to drop the bomb with", keybind, "keyboard B");
%template.addBehaviorField(dropRate, "The rate to fire when the drop key is held down (seconds)", float, "0.1");
%template.addBehaviorField(projectileSpeed, "The speed of projectiles (world units per second)", float, "30");
}
function DropsBombBehavior::onBehaviorAdd(%this)
{
if (isObject(moveMap))
moveMap.bindObj(getWord(%this.dropKey, 0), getWord(%this.dropKey, 1), "drop", %this);
}
function DropsBombBehavior::onBehaviorRemove(%this)
{
if (isObject(moveMap))
moveMap.unbindObj(getWord(%this.dropKey, 0), getWord(%this.dropKey, 1), %this);
}
function DropsBombBehavior::dropsBomb(%this, %val)
{
if (%val == 0)
{
cancel(%this.dropSchedule);
return;
}
if (!isObject(%this.projectile))
return;
%projectile = %this.projectile.cloneWithBehaviors();
%projectile.setPosition(%this.owner.position);
%projectile.setLinearVelocityPolar(180, %this.projectileSpeed);
if (!isEventPending(%this.dropSchedule))
%this.dropSchedule = %this.schedule(%this.dropRate * 1000, "drop", 1);
}About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.