Item DEATH

  • Thread starter Thread starter zvitor
  • Start date Start date
Z

zvitor

Guest
i can make a item peform any anim after player get it? like death or something.
 
AFAIK item is gone after getting it so the only way is to run script in item's didhitscript.

What's exactly you want to make here?

(couple minutes later)

I read Marvel First Alliance thread and I understand what you want. You want to summon NPC by getting item right?
 
Okay, since I don't know which NPCs you'd like to summon, I made a rather generic script for this.

1st of all, this script, didhitscript to be exact can be declared in any item but to avoid clash, let's just generic item like this:

name NPCItem
score 1
type item
nolife 1
didhitscript data/scripts/summon.c


anim idle
delay 10
offset 35 50
bbox 20 30 30 20
frame data/chars/misc/rolbar1.png

You can change the name of this item and change anything set in IDLE if you like but the ones in red shouldn't be changed.

Since I can't upload anything here, here's the whole summon.c:

Code:
void main()
{//Script for summoning based on item's alias
    void self = getlocalvar("self");
    char Item = getentityproperty(self,"name");
    void target = getlocalvar("damagetaker"); // Get player who picks the item
    int  PIndex = getentityproperty(target,"playerindex"); // Get player's index
    int  PScore = getplayerproperty(PIndex,"score"); // Get player's score
    int Direction = getentityproperty(target, "direction");
    int fZ = getentityproperty(target, "z"); //Get Z location
    int XPos = openborvariant("xpos"); //Get screen edge's position
    int Screen = openborvariant("hResolution"); // Get screen width
    int fX = -60; // Set distance from screen edge
    void vSpawn; //Spawn object.

    if(PScore == NULL()){
      PScore=0;
    }

    changeplayerproperty(PIndex, "score", PScore-1); // Reduce score a bit

    clearspawnentry(); //Clear current spawn entry.
    setspawnentry("name", Item); //Acquire spawn entity by name.

    if (Direction == 0){ //Is entity facing left?                  
      fX = Screen-fX; //Reverse X direction to match facing and screen length
    }

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", XPos+fX, fZ); //Set spawn location.
    changeentityproperty(vSpawn, "direction", Direction); //Set direction
}

Save this as summon.c and put it in data/scripts/ folder.

Of course, don't forget to set this item in models.txt

To use this, spawn it like this:

spawn Rollitem
alias Flau
coords 300 195
at 0

spawn Rollitem
alias RollBarrel
coords 300 170
at 0

If you get rollItem whose alias is Flau, a Flau (enemy) will appear from behind you. OTOH if you get the other whose alias is RollBarrel, Rollbarrel will appear from behind.

So if you want these items to spawn certain NPC say She_Hulk, you should set it like this:

spawn Rollitem
alias She_Hulk
coords (anything)
at (anything)

There are 2 things you need to pay attention to:
1. She Hulk or anything you want to spawn must be loaded prior to this. If you're not sure about that, just set load to all NPCs in models.txt instead of know.
2. Name set with alias must match NPC's name, so if She Hulk is typed She_Hulk, you should type it same way. It's not case sensitive however.

HTH
 
Hi Bloodbane, thanks for this script, it works perfectly. I'm wondering how I can spawn 3 shadow clones with this type of item (this is 3 times the same entity)?
Currently, I spawn 3 times the same item at the same place but it's just a patch before I know how to spawn in only one item :).
 
Thanks Bloodbane for this 3 summoning entity script:

Code:
void main()
{//Script for summoning 3 shadow clones
    void self = getlocalvar("self");
    void target = getlocalvar("damagetaker"); // Get player who picks the item
    int PIndex = getentityproperty(target,"playerindex"); // Get player's index
    int PScore = getplayerproperty(PIndex,"score"); // Get player's score
    int XPos = openborvariant("xpos"); //Get screen edge's position
    int fX = -60; // Set distance from screen edge
    int Zenter = (openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z"))/2;
    void vSpawn; //Spawn object.

    if(PScore == NULL()){
      PScore=0;
    }

    changeplayerproperty(PIndex, "score", PScore-1); // Reduce score a bit
//1st spawn
    vSpawn = spawn01("Billyshadow", 0, 0, 0);

    changeentityproperty(vSpawn, "position", XPos+fX, Zenter);
    changeentityproperty(vSpawn, "direction", 1);
//2nd spawn
    vSpawn = spawn01("Billyshadow", 0, 0, 0);

    changeentityproperty(vSpawn, "position", XPos+fX, Zenter-10);
    changeentityproperty(vSpawn, "direction", 1);
//3rd spawn
    vSpawn = spawn01("Billyshadow", 0, 0, 0);

    changeentityproperty(vSpawn, "position", XPos+fX, Zenter+10);
    changeentityproperty(vSpawn, "direction", 1);
}

void spawn01(void vName, float fX, float fY, float fZ)
{
	//spawn01 (Generic spawner)
	//Damon Vaughn Caskey
	//07/06/2007
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location
	//fY: Y location
	//fZ: Z location

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.

	clearspawnentry(); //Clear current spawn entry.
	setspawnentry("name", vName); //Acquire spawn entity by name.

	vSpawn = spawn(); //Spawn in entity
	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location. 

	return vSpawn; //Return spawn
 
Back
Top Bottom