Contain text with choice function within one animation SOLVED

ABK

Well-known member
Hey guys ive got this script with text function working and choosing fighting or talking with left/right but its not what i want in the end , i mean i want it to be super compact and use just one animation for entire negotiation so i can just switch to other animation for other negotiations instead of using new txt files for each, now i had to split this into a couple of animations because i was getting infinite loop issue if i pressed let/right quickly a couple of times and engine crashed.Now it does not crash how i set it up.
Any clue how to do it in one animation ? Theres 3 or 4  options, one is highlighted "fight" , other one is highlighted "talk" and last two are confirmations of the ones above that are activated with attack button.So ideally it would use 4 frames of animation, maybe five because first frame would be sound of menu appearing.
I tried updateframe and one animation but im getting infinite loop, also with "delay -1" detecting keys pressed does not work, delay has to be quite low, 10 or 20.
Its a quick test to try if it works, it does work but i dont want to make new entity for every conversation/negotiation onscreen.
8d27b5da.gif

Code:
name    	dial
type    	text
subject_to_minz 0
subject_to_maxz 0
subject_to_wall 0
subject_to_hole 0


anim idle
	loop	1 2 
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
                void p2 = playerkeys(iPIndex, 0, "moveleft");
				 void at = playerkeys(iPIndex, 0, "attack");
		if ( frame > 1 && p2 ){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
                }
								if (frame > 1 && at){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
                }
	@end_script
	
	OFFSET 1 1
		SOUND  DATA/sounds/LASER2.wav
				frame	NONE
					frame	NONE
			@cmd	settextobj 1 420 300 0 -1 "MAKE_A_CHOICE_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 2 700 400 1 -1 "FIGHT_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 3 200 400 0 -1 "TALK_! " openborvariant("elapsed_time")+150
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE


anim follow1
	loop	1 2
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
                void p1 = playerkeys(iPIndex, 0, "moveright");
				 void at = playerkeys(iPIndex, 0, "attack");
		if (frame > 1 && p1){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
                }
								if (frame > 1 && at){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
                }
	@end_script
	OFFSET 1 1
		SOUND  DATA/sounds/beep.wav
				frame	NONE
						frame	NONE
			@cmd	settextobj 1 420 300 0 -1 "MAKE_A_CHOICE_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 2 700 400 0 -1 "FIGHT_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 3 200 400 1 -1 "TALK_! " openborvariant("elapsed_time")+150
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE

	
anim FOLLOW2
	loop	1 2 
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
                void p2 = playerkeys(iPIndex, 0, "moveleft");
				 void at = playerkeys(iPIndex, 0, "attack");
		if (frame > 1 && p2){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
                }
				if (frame > 1 && at){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
                }
	@end_script
	
	OFFSET 1 1
		SOUND  DATA/sounds/beep.wav
				frame	NONE
					frame	NONE
			@cmd	settextobj 1 420 300 0 -1 "MAKE_A_CHOICE_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 2 700 400 1 -1 "FIGHT_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 3 200 400 0 -1 "TALK_! " openborvariant("elapsed_time")+150
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	
	
	
	anim FOLLOW3
	loop	0
	delay	100
	OFFSET 1 1
	SOUND  DATA/sounds/beep2.wav
	@cmd	settextobj 1 440 300 3 -1 "SUCCESS_! " openborvariant("elapsed_time")+250
	@cmd	settextobj 2 420 400 3 -1 "_ " openborvariant("elapsed_time")+250
	@cmd	settextobj 3 420 500 3 -1 "_ " openborvariant("elapsed_time")+250
	frame	NONE
	frame	NONE
 
I know i can do my own spawn01 but i wanted to use only inline scripts for that, so i guess its not possible, just simple changes of variables and getting variables is possible with them.
 
O Ilusionista said:
There is a bug in openbor do not run any scripts on the first frame as soon as a entity is spawned or it will not work or miss behave.
This is and old belief but...its not a bug. As Damon Caskey  explained some time ago, this is how the engine is intended to work, to save resources.

Hm.. i don't know guys.. i have read about this over and over for years now but to me it seems more like a myth than the reality. This because i do use a lot scripts in various forms on the first frame of the spawn animations for both player/enemies and i have never ever experienced any problems. Maybe this was an older thing on older engine versions or it had to do with a more specific script case, i don't know.. But to me, from engine versions 4xxx until the very latest, again i never had any such issues.. So it's kinda weird to me wnen i read about this.. ???
 
Back
Top Bottom