I have this pawn on a wall that fires with a small delay between shots,yet it keeps firing all the time.
I do not know how to make it repeat that fire order for a certain amount of time,then go to an other order to play a delay for some seconds (so you can pass over the trap) and then go back to the fire order.
And,f i could randomize it to use a min and max pause time,even better.
{
Spawn[ ()
{
Console(true);
BoxWidth(16); // set bounding box width/depth
NewOrder("Fire");
} ]
Fire[ ()
{
FireProjectile("Firebolt", "BONE02", 0, 0, 0, "health", "");
Delay("Idle", 0.4, "");
AttributeOrder("health", 20, "Destoyed");
RestartOrder();
} ]
Destoyed[ ()
{
AddExplosion("Firebolt1Explosion", "BONE02", 0,0,0);
SetEventState("Trap1Trigger", true);
Remove(true);
} ]
}
Fire rate (high level)
Re: Fire rate (high level)
Try using the AddTimerOrder() command:
In this example it should fire for 10 seconds then idle for 10 seconds then repeat.
Idle could also look like this:
I'm not sure if the DelTimerOrder() command should be used before setting another timer with the same Timer#.
Or you can do something like this:
Note: I didn't test this code so it could have problems but you should get the idea of what the code is doing.
In this example it should fire for 10 seconds then idle for 10 seconds then repeat.
Code: Select all
{
Spawn[ ()
{
Console(true);
BoxWidth(16); // set bounding box width/depth
AddTimerOrder(1,10,"Idle");
NewOrder("Fire");
} ]
Fire[ ()
{
FireProjectile("Firebolt", "BONE02", 0, 0, 0, "health", "");
Delay("Idle", 0.4, "");
AttributeOrder("health", 20, "Destoyed");
RestartOrder();
} ]
Idle[ ()
{
AddTimerOrder(1,10,"Fire");
AddTimerOrder(2,20,"Idle");
} ]
Destoyed[ ()
{
AddExplosion("Firebolt1Explosion", "BONE02", 0,0,0);
SetEventState("Trap1Trigger", true);
Remove(true);
} ]
}
Code: Select all
Idle[ ()
{
Delay("Idle", 10, "");
AddTimerOrder(1,10,"Idle");
NewOrder("Fire");
} ]
Or you can do something like this:
Code: Select all
{
timer [0]
Spawn[ ()
{
Console(true);
BoxWidth(16); // set bounding box width/depth
timer = time;
NewOrder("Fire");
} ]
Fire[ ()
{
if (time > timer + 10)
{
Delay("Idle", 10, "");
timer = time;
}
FireProjectile("Firebolt", "BONE02", 0, 0, 0, "health", "");
Delay("Idle", 0.4, "");
AttributeOrder("health", 20, "Destoyed");
RestartOrder();
} ]
Destoyed[ ()
{
AddExplosion("Firebolt1Explosion", "BONE02", 0,0,0);
SetEventState("Trap1Trigger", true);
Remove(true);
} ]
}
Last edited by Allanon on Wed Sep 21, 2011 7:10 pm, edited 1 time in total.
Re: Fire rate (high level)
And,f i could randomize it to use a min and max pause time,even better.
Code: Select all
{
min_pause [5]
max_pause [20]
Spawn[ ()
{
Console(true);
BoxWidth(16); // set bounding box width/depth
AddTimerOrder(1,random(min_pause,max_pause),"Idle");
NewOrder("Fire");
} ]
Fire[ ()
{
FireProjectile("Firebolt", "BONE02", 0, 0, 0, "health", "");
Delay("Idle", 0.4, "");
AttributeOrder("health", 20, "Destoyed");
RestartOrder();
} ]
Idle[ ()
{
Delay("Idle", random(min_pause,max_pause), "");
AddTimerOrder(1,random(min_pause,max_pause),"Idle");
NewOrder("Fire");
} ]
Destoyed[ ()
{
AddExplosion("Firebolt1Explosion", "BONE02", 0,0,0);
SetEventState("Trap1Trigger", true);
Remove(true);
} ]
}
Code: Select all
{
timer [0]
min_pause [5]
max_pause [20]
Spawn[ ()
{
Console(true);
BoxWidth(16); // set bounding box width/depth
timer = time;
NewOrder("Fire");
} ]
Fire[ ()
{
if (time > timer + random(min_pause,max_pause))
{
Delay("Idle", random(min_pause,max_pause), "");
timer = time;
}
FireProjectile("Firebolt", "BONE02", 0, 0, 0, "health", "");
Delay("Idle", 0.4, "");
AttributeOrder("health", 20, "Destoyed");
RestartOrder();
} ]
Destoyed[ ()
{
AddExplosion("Firebolt1Explosion", "BONE02", 0,0,0);
SetEventState("Trap1Trigger", true);
Remove(true);
} ]
}