10-30-2011, 20:21
Whenever i try and use this code i always get bad syntax or unknown function plz help
Code:
CreateDoors(open, close, xangle, yangle, zangle, size, height, hp, range)
{
offset = (((size / 2) - 0.5) * -1);
center = spawn("script_model", open, 1);
center SetOwner( level );
for(j = 0; j < size; j++){
door = spawn("script_model", open + ((35, 0, 0) * offset), 1);
door setModel(level.crateModelEnemy);
door SetOwner( level );
door LinkTo(center);
for(h = 1; h < height; h++){
door = spawn("script_model", open + ((35, 0, 0) * offset) - ((0, 95, 0) * h), 1);
door setModel(level.crateModelEnemy);
door SetOwner( level );
door LinkTo(center);
}
offset += 1;
}
if(!isDefined(yangle)){
Temp = VectorToAngles(open - close);
yangle = Temp[1]-90;
}
center.angles = (xangle, yangle, 0-zangle);
center.state = "open";
center.maxhp = hp;
center.hp = hp;
center.range = range;
center thread DoorThinkUse(open, close);
//center thread DoorThinkRepair();
center thread DoorUse();
center thread ResetDoors(open, hp);
wait 0.01;
}
DoorThinkUse(open, close)
{
while(1)
{
if(self.hp > 0){
self waittill ( "triggeruse" , player );
if(player.team == "allies"){
if(self.state == "open"){
self MoveTo(close, level.doorwait);
wait level.doorwait;
self.state = "close";
continue;
}
if(self.state == "close"){
self MoveTo(open, level.doorwait);
wait level.doorwait;
self.state = "open";
continue;
}
}
if(player.team == "axis"){
if(self.state == "close"){
if(player.attackeddoor == 0){
hitChance = 0;
switch(player GetStance())
{
case "prone":
hitChance = 15;
break;
case "crouch":
hitChance = 45;
break;
case "stand":
hitChance = 90;
break;
default:
break;
}
if(randomInt(100) < hitChance){
self.hp--;
player iPrintlnBold("HIT - " + self.hp + "/" + self.maxhp);
if(self.hp <= int(self.maxhp/5)){
self playSound("uin_alert_lockon_start");
}
} else {
player iPrintlnBold("^1MISS - " + self.hp + "/" + self.maxhp);
}
player.attackeddoor = 1;
player thread DoorAttackWait();
continue;
}
}
}
} else {
if(self.state == "close"){
self MoveTo(open, level.doorwait);
}
self.state = "broken";
wait .5;
}
}
}
DoorThinkRepair()
{
while(1)
{
self waittill ( "triggerrepair" , player );
if(self.hp < self.maxhp){
if(self.hp > 0){
player thread RepairDoor(self);
} else {
if(useHoldThink(player, "Fixing Door...", 20000)){
self.hp = self.maxhp;
self.state = "open";
player.bounty += 200;
}
}
}
}
}
RepairDoor(door)
{
self notify("RepairingDoor");
self endon("RepairingDoor");
self endon("disconnect");
self endon("death");
if(useHoldThink(self, "Repairing Door...", 5000)){
if(door.state != "broken"){
door.hp += 1;
self.hprepaired += 1;
self iPrintlnBold("Repaired - " + door.hp + "/" + door.maxhp);
if(self.hprepaired >= 5){
self.bounty += 50;
self.hprepaired = 0;
}
}
}
}
DoorUse()
{
while(1)
{
for(i = 0; i < level.players.size; i++)
{
if(DistanceSquared(self.origin, level.players[i].origin) <= Power(self.range, 2)){
if(level.players[i].team == "allies"){
if(level.players[i] getCurrentWeapon() == "onemanarmy_mp"){
if(self.state == "broken"){
level.players[i].hint = "^1Door is Broken. ^7Press and Hold ^3[{+activate}] ^7to ^2Fix ^7the door";
} else {
if(self.hp < self.maxhp){
level.players[i].hint = "Press and Hold ^3[{+activate}] ^7to ^2Repair ^7the door";
}
}
} else {
if(self.state == "open"){
level.players[i].hint = "Press ^3[{+activate}] ^7to ^2Close ^7the door";
}
if(self.state == "close"){
level.players[i].hint = "Press ^3[{+activate}] ^7to ^2Open ^7the door";
}
if(self.state == "broken"){
level.players[i].hint = "^1Door is Broken";
}
}
}
if(level.players[i].team == "axis"){
if(self.state == "close"){
level.players[i].hint = "Press ^3[{+activate}] ^7to ^2Attack ^7the door";
}
if(self.state == "broken"){
level.players[i].hint = "^1Door is Broken";
}
}
if(level.players[i] getCurrentWeapon() == "onemanarmy_mp"){
if(level.players[i] UseButtonPressed()){
self notify( "triggerrepair" , level.players[i]);
}
} else {
if(level.players[i] UseButtonPressed()){
self notify( "triggeruse" , level.players[i]);
}
}
}
}
wait .045;
}
}
DoorAttackWait()
{
self notify("attackwait");
self endon("attackwait");
self endon("disconnect");
self endon("death");
wait 1;
self.attackeddoor = 0;
}
ResetDoors(open, hp)
{
while(1)
{
level waittill("RESETDOORS");
self.hp = hp;
self MoveTo(open, level.doorwait);
self.state = "open";
}
}