About Store Forum Documentation Contact



Post Reply 
how can i delay something
Author Message
fhl41 Offline
Member

Post: #1
how can i delay something
i have the spell fireball on the attackRightHand ();
but i want to delay the fireball from spawning so the animation is first playing
how can i delay something
12-07-2016 06:05 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: how can i delay something
You would need to use a timer.

Code:
// init
flt time=0;

// update
time+=Time.d();
if(time>=some_value)
{
  do something
}
12-07-2016 09:01 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #3
RE: how can i delay something
if you want to trigger it only at a certain point in animation you can add Events to your animations, that way you can check the currently played animation and check for EventOccured(),EventBetween or eventAfter
(This post was last modified: 12-07-2016 09:41 PM by Zervox.)
12-07-2016 09:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: how can i delay something
Yes, as Zervox mentions, this is even better.
If you're using Motion class, then you can just use Motion.eventOccurred
12-07-2016 10:16 PM
Find all posts by this user Quote this message in a reply
fhl41 Offline
Member

Post: #5
RE: how can i delay something
yes i see that in the attack animation hit-from and hit-to

i want to make a bow and arrow out of it it is shooting firebals will replace that with arrow grin


here is what i have but is not delaying. if(!attack.eventBetween(8"hit-from", 8"hit-to")) under is more of the code can someone shine some light on it

[Image: wmczzr.jpg]

Quote:if(Ms.b(1))if(!attack.is() || Ms.bp(1))
{
if(inv.slot[SLOT_ARM_R].valid())
{
if(Contains(inv.slot[SLOT_ARM_R]->name, "Bloody Nail Bat") && inv.slot[SLOT_ARM_R]->type==ITEM_WEAPON)
attackRightHandPlayer ();
if(!attack.eventBetween(8"hit-from", 8"hit-to")) //HERE IT IS
if(mana>20)
{
Object obj_params; obj_params.base(UID(1384215308, 1338586313, 1308053163, 408650403)); obj_params.type(true, ObjType.elmID(OBJ_FIREBALL));
if(Fireball *fb=CAST(Fireball, Game.World.objCreateNear(obj_params, Matrix(0.45, skel.getSlot(8"HandR").pos))))
{
(This post was last modified: 12-08-2016 12:27 PM by fhl41.)
12-08-2016 11:41 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #6
RE: how can i delay something
if(!attack.eventBetween(8"hit-from", 8"hit-to")) //HERE IT IS
well as you say, HERE IT IS, as in here lies your problem(atleast from what I understand that you want to do), remove the !
(This post was last modified: 12-08-2016 01:01 PM by Zervox.)
12-08-2016 01:00 PM
Find all posts by this user Quote this message in a reply
fhl41 Offline
Member

Post: #7
RE: how can i delay something
i thought allready that but was not sure but when i do that its not casting a fireball
at all
12-08-2016 01:13 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #8
RE: how can i delay something
you can launch the project in visual studio and place breakpoint on the code inside the if statements and see if its ever executed, if it gets to the line if(mana>20) then it works and instead it is if mana which is not working properly or it is the spawn code. smile

does it spawn the fireball if you have the ! there?(eg checks if its not between those events).
(This post was last modified: 12-08-2016 01:30 PM by Zervox.)
12-08-2016 01:28 PM
Find all posts by this user Quote this message in a reply
Post Reply