• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Solved How to edit using props

Question that is answered or resolved.

pudu

Well-known member
How to edit and use items, for example, when 1P picks up item 1, you can use this item ↓↑a, if you pick up 2 different items, it will overwrite the previous item. Do you have any relevant information or tutorials? thanks
 
Let's elaborate this further, when you say 1P picks up item 1 , 1P stores the item instead of immediately use it right?
Then ↓↑a is how to use the item, will player play fail to use item animation when there's nothing to be used?
Picking another item will remove stored item and put latest one instead. I prefer dropping former item though.

If this is how it works, you'd need to code inventory system. At least inventory with one slot. I recommend coding display script also to show player what item player is currently carrying.
There's no tutorial for this (yet) cause inventory and display system are designed to fit certain game only, both gameplaywise and visually. IOW you'd need to code these system yourself.
 
Let's elaborate this further, when you say 1P picks up item 1 , 1P stores the item instead of immediately use it right?
Then ↓↑a is how to use the item, will player play fail to use item animation when there's nothing to be used?
Picking another item will remove stored item and put latest one instead. I prefer dropping former item though.

If this is how it works, you'd need to code inventory system. At least inventory with one slot. I recommend coding display script also to show player what item player is currently carrying.
There's no tutorial for this (yet) cause inventory and display system are designed to fit certain game only, both gameplaywise and visually. IOW you'd need to code these system yourself.
Thank you for the answer, yes, when the player picks up the item and saves it, if you want to use it, ↓↑A use it, if the player does not have the item, the use failure animation will be executed, if there are 2 items, the first one will be covered (first pick up prop 1 then prop 2 overrides prop 1).
If possible, it is best to use only 1P for 1P pickup, and only 2P for 2P pickup.
 
if it is like castlevania the way you pick up lots of different weapons but use the same throw animation to throw them you could record the item name into the players entityvar using a didhitscript and spawn it with a generic throw animation and have a check if the entityvar is empty go to fail animation remember to clear the entityvar after the throw animation.
 
First create an item as follows
Code:
name    BriannaSummon
type    item
score    1
shadow    0
gfxshadow    1
nolife        1
facing         1
icon    data/chars/misc/empty.gif
didhitscript data/scripts/item/summonNpc.c

anim idle
    loop    0
    delay    1
    offset    8 15
    bbox    0 0 16 16
    frame    data/chars/misc/BriannaSummon.gif
didhitscript data/scripts/item/summonNpc.c

This script is for the case of 2 items Note: When you pick up 2 items at the same time, the previous one will be overwritten

Code:
void main()
{
    void self = getlocalvar("self");
    void target = getlocalvar("damagetaker");
    void name = getentityproperty(self, "defaultname");
    int pIndex = getentityproperty(target, "playerindex");

    if(name == "BriannaSummon"){setglobalvar("summon"+pIndex, "BriannaNpc");}
    if(name == "ZoeSummon"){setglobalvar("summon"+pIndex, "ZoeNpc");}
}
Then create an npc text
Code:
name    ZoeNpc
type    npc
health  1
shadow    0
gfxshadow 1
nomove 1 1
icon    data/chars/misc/empty.gif
diesound data/sounds/di1.wav
candamage    enemy obstacle
subject_to_wall 1
subject_to_hole 1
subject_to_screen 1
no_adjust_base 0
animationscript    data/scripts/animation.c

anim idle
        loop    0
    delay    999
    offset    72 131
     jumpframe  2 4 1 0
        hitflash blood
    hitfx    data/sounds/swd.wav
        frame   .................
Players add script animationscript data/scripts/scripts.c
and animation
com a4 freespecial1

anim freespecial1
loop 0
delay 35
offset 72 131
bbox 63 102 16 29
@cmd summonNpc
frame data/chars/pla01/0bl1.gif

animationscript data/scripts/scripts.c
Code:
void summonNpc()
{
    void self = getlocalvar("self");
    int pIndex = getentityproperty(self, "playerindex");
    void summon = getglobalvar("summon"+pIndex);

    if(summon != NULL()){
        loadmodel(summon);
        spawn01(summon, 0, 250, 0);
        setglobalvar("summon"+pIndex, NULL());
    }
}

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 adjustment.
    //fZ: Y location adjustment.
    //fY: Z location adjustment.

    void self         = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");

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

    if(iDirection == 0){ //Is entity facing left?               
        fX = -fX; //Reverse X direction to match facing.
    }

    fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
    fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
    fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
  
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    return vSpawn; //Return spawn.
}
Finally the item icon
Add ondrawscript data/scripts/ondraw/player.c to player text
player.c text
Code:
void main()
{
    void self        = getlocalvar("self");
    int dead    = getentityproperty(self,"dead");
    void type    = getentityproperty(self, "type");
    int p             = getentityproperty(self, "playerindex");
    void summon = getglobalvar("summon"+p);
    int layer        = 60000;
    int xPos    = 119;
    int yPos    = 18;
    int xDif    = 160;
    int xAdd    = xDif*p;

    if(getglobalvar("BriannaIcon") == NULL()){setglobalvar("BriannaIcon", loadsprite("data/chars/misc/BriannaSummon.gif"));}
    if(getglobalvar("ZoeIcon") == NULL()){setglobalvar("ZoeIcon", loadsprite("data/chars/misc/ZoeSummon.gif"));}

    if(openborvariant("in_level") && type == openborconstant("TYPE_PLAYER")){
        if(dead != 1 ){
            if(summon != NULL()){
                void icon;

                if(summon == "BriannaNpc"){icon = getglobalvar("BriannaIcon");}
                if(summon == "ZoeNpc"){icon = getglobalvar("ZoeIcon");}
                drawsprite(icon, xPos+xAdd, yPos, layer);
            }
        }
    }
}
 
Last edited:
Back
Top Bottom