Switching Character Entities in In-Game

maxman

Well-known member
OK. I made my first script. I was working on a script for switching characters. I have a problem. I tried to make a character switch to another character, but seemed that I can't. I press a special button as I command on anim freespecial for going to anim follow for spawning another character entity. For example, when I play a first character, I would like to switch him to a second character by pressing a special button and vice versa. However, I press it but first character retains without switching 'cause I dunno how to switch and mine is non-scripted, and I fear it may crash if I remove the #'s in the player txt below.

Note: I put # to avoid running the script in the character text. Otherwise, it crashes.

tag.c:
Code:
void main(){

	void vSelf = getplayerproperty(0, "entity"); // Get calling entity
	void vName = getentityproperty(vSelf, "name"); // Get name of calling entity
	//void vAniID = getentityproperty(vSelf, "animation"); // Get current animation ID
	//void vAniPos = getplayerproperty(vSelf, "anipos"); // Get current animation frame
	int iPlIndex = getlocalvar("player"); //Get calling player
	void vAniID = getentityproperty(vSelf, "animationid"); // Get animation ID
    float fX        = getentityproperty(vSelf, "x");        //Caller X location.
    float fY        = getentityproperty(vSelf, "a");        //Caller Y location.
    float fZ        = getentityproperty(vSelf, "z");        //Caller Z location.

	
    void iUp = playerkeys(iPlIndex, 0, "moveup"); //New key status of "up"
	void iDown = playerkeys(iPlIndex, 0, "movedown"); // New key status of "down"
	void iLeft = playerkeys(iPlIndex, 0, "moveleft"); // New key status of "left"
	void iRight = playerkeys(iPlIndex, 0, "moveright"); // New key status of "right"
	
	void iJump = playerkeys(iPlIndex, 0, "jump"); //New key status of "jump"
	void iAttack = playerkeys(iPlIndex, 0, "attack"); // New key status of "attack"
	void iSpecial = playerkeys(iPlIndex, 0, "special"); // New key status of "special"
	void iAttack2 = playerkeys(iPlIndex, 0, "attack2"); //New key status of "attack2"
	void iAttack3 = playerkeys(iPlIndex, 0, "attack3"); //New key status of "attack3"
	void iAttack4 = playerkeys(iPlIndex, 0, "attack4"); //New key status of "attack4"
	
	void iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "left"
	void iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "right"
	
	// Tagging partner
	// JJ or Max
if(iSpecial){ // iSpecial button pressed?
	if(vName == "Max"){ //are we Max?
	changeentityproperty(vSelf, "model", "Max", 1); // Switch to Max
	changeentityproperty(vSelf, "animationid", openborconstant("ANI_FOLLOW1"), 1);
	changeentityproperty(vSelf, "weapons", 1);
	changeentityproperty(vSelf, "position", "x", "z", "a", 1);
	//changeentityproperty(vSelf, "anipos", openborconstant("ANI_FOLLOW1"), 1);
	}
else if(vName == "JJ"){ //we are not max Max?
	changeentityproperty(vSelf, "model", "JJ", 1); // Switch to JJ
	changeentityproperty(vSelf, "animationid", openborconstant("ANI_FOLLOW1"), 1);
	changeentityproperty(vSelf, "weapons", 1);
	changeentityproperty(vSelf, "position", "x", "z", "a", 1);
	//changeentityproperty(vSelf, "anipos", openborconstant("ANI_FOLLOW1"), 1);
	}
	}
	}


Code:
name	JJ
type	player
health	30
speed	13
shadow	0
icon	data/chars/jj/j2lbicon.png
diesound data/chars/jj/death.wav
keyscript	data/scripts/tag.c
#animationscript data/scripts/tag.c
falldie 1

jumpheight 4.25

atchain 1


keyscript data/scripts/jjkey.c



com	s	freespecial5

Code:
anim freespecial5
#@script
#    void self = getlocalvar("self"); // Get calling entity
#    int x = getentityproperty(self,"x"); // Caller X location
#    int a = getentityproperty(self,"a"); // Caller Y location
#    int z = getentityproperty(self,"z"); // Caller Z location
#    if(frame==2)
#    void name = getentityproperty(self,"name");
#@end_script
	delay	8
	offset	49 95
	followanim 1
	frame	data/chars/jj/jump01.png
	frame	data/chars/jj/jump02.png
	delay	5
	offset	1 1
	frame	data/chars/misc/empty.gif

Code:
anim follow
#@script
#   void self = getlocalvar("self")
#   changeentityproperty(vSelf, "name", "Max", 1);
#@end_script
	delay	3
	offset	1 1
	frame	data/chars/misc/empty.gif
	delay	5
	frame	data/chars/misc/empty.gif
 
Sheesh. I am so lost on what to do. I need help here. Sorry for being impatient of posting this.
 
Let me get this strait. your trying to switch from one player to another during game play  ??? if this is so you don't need script. Ive done this easily with the weapon command. So now the chars switch out like the capcom vs. series
 
I think it doesn't work for me as I did these.

Code:
name	JJ
type	player
health	30
speed	13
shadow	0
icon	data/chars/jj/j2lbicon.png
diesound data/chars/jj/death.wav
#keyscript	data/scripts/tag.c
#animationscript data/scripts/tag.c
falldie 1
weapons	Max
jumpheight 4.25

Code:
anim freespecial5
#@script
#    void self = getlocalvar("self"); // Get calling entity
#    int x = getentityproperty(self,"x"); // Caller X location
#    int a = getentityproperty(self,"a"); // Caller Y location
#    int z = getentityproperty(self,"z"); // Caller Z location
#    if(frame==2)
#    void name = getentityproperty(self,"name");
#@end_script
	delay	8
	offset	49 95
#	followanim 1
	weaponframe 2 Max
	frame	data/chars/jj/jump01.png
	frame	data/chars/jj/jump02.png
	delay	5
	offset	1 1
	frame	data/chars/misc/empty.gif
 
nsw25 said:
vision said:
Let me get this strait. your trying to switch from one player to another during game play  ??? if this is so you don't need script. Ive done this easily with the weapon command. So now the chars switch out like the capcom vs. series

can you please explain how it is done ?

All you would have to do is make a character a weapon of another character and determine the frame they switch in. you can make an animation where 1 character jumps in and the other jumps out or 1 or both do an attack and switch. There are all kinds of ways you can do this. Jus load a character or characters in another character's header and make a freespecial or 2 with commands to do different tags. You can even use custom entities to do tag specials like in Mavel vs Capcom series 8)
 
Back
Top Bottom