Item counter...

kdo

Member
Hello guys, I need some help here ...

In my mod  the player's goal is to get the most items.
is there any way to make an item counter that display on the screen to show
the number of collected itens?  :)

Is there a mod that use something like this?

 
First of all, that sounds interesting  :D

And I'm sure someone with more experience will get you the mod or the right answer,  but if it was me I would look into tricking the weapon system to act as an item and use the counter system.

reload {int}

For items.If a player picks up an item that has this command, it will restore their ammunition by {int}.Does nothing if a player doesn't have a weapon.Should be used with 'shootnum'.Don't forget that items can only give one bonus.
 
Well, technically Rise of Warduke has item counter but instead of counting collected items, it simply shows how many items players have.

kdo said:
In my mod  the player's goal is to get the most items.

Wait a second, aah it reminds me of gif you showed before about two players collecting acorns. Do you want acorn counter?

There are workaround method and scripted method to create this counter.
1. Use MP as player's item counter and use script to set players MP to 0 at beginning of game. Set acorns to give player 1 MP when picked up. Use scripted MP display which displays MP with numbers.

AND

2. Set acorns to increment player's item counter, the counter will be a global variable (one for each player). Use update script to display both counters.

Obviously #1 can't be used if you already use MP for something else.
 
Yes!! Bloodbane , this system is for that mod TOTORO, this is the ideia  player collecting acorns, but just one player, the little girl running arround is an enemy to dificult the player action.
Thanks Bloodbane, i'll try use the MP trick  ;)

Is there some way to make the player loose MP if  gat touched by an enemy?

I need to make the player gain MP if he touches the acorn and lose MP if he is touched by the enemy if he takes damage. :)
 
You can use this script:
mphit.c
Code:
void main(){
    void self = getlocalvar("self");
    void target = getlocalvar("damagetaker");
    int TMP = getentityproperty(target,"mp");

    if(TMP >= 1){
      changeentityproperty(target, "mp", TMP -1);
    } else {
      changeentityproperty(target, "mp", 0);
    }
}

Save that in data/scripts folder and declare it in enemy's header with this:

didhitscript data/scripts/mphit.c
 
Hey Bloodbane, this script works perfect!!! Thank yuou again my friend... :)

I tried the MP script to display the mp counter and it works, but there are 2 things I don't know how to solve it, i  appreciate it if you can help me again.

1 - The MP Display shows MP and MPMAX, i just need to show the MP.

2 - The MP start with maximum value, i need start it with counter at 0 . ( script to set players MP to 0 at beginning of game ) I didnt find this one.

Iam using the Clafan Advance MP Script:

// in update.c
void main()
{ 
//
    void p1 = getplayerproperty(0, "entity");
    void p2 = getplayerproperty(1, "entity");
    void p3 = getplayerproperty(2, "entity");
    void p4 = getplayerproperty(3, "entity");
    char p1health;
    char p2health;
    char p3health;
    char p4health;
    char p1mp;
    char p2mp;
    char p3mp;
    char p4mp;
     
//HP text script
    if(getentityproperty(p1, "exists")) {
        int p1disphealth = getentityproperty(p1, "health");
        if(p1disphealth < 0) p1disphealth = 0;
        p1health = p1disphealth+"/"+getentityproperty(p1, "maxhealth");
        drawstring(1000, 1000, 0, p1health);
    }
   
    if(getentityproperty(p2, "exists")) {
        int p2disphealth = getentityproperty(p2, "health");
        if(p2disphealth < 0) p2disphealth = 0;
        p2health = p2disphealth+"/"+getentityproperty(p2, "maxhealth");
        drawstring(117, 205, 0, p2health);
    }

    if(getentityproperty(p3, "exists")) {
        int p3disphealth = getentityproperty(p3, "health");
        if(p3disphealth < 0) p3disphealth = 0;
        p3health = p3disphealth+"/"+getentityproperty(p3, "maxhealth");
        drawstring(193, 205, 0, p3health);
    }

    if(getentityproperty(p4, "exists")) {
        int p4disphealth = getentityproperty(p4, "health");
        if(p4disphealth < 0) p4disphealth = 0;
        p4health = getentityproperty(p4, "health")+"/"+getentityproperty(p4, "maxhealth");
        drawstring(272, 205, 0, p4health);
    }

//MP text script
    if(getentityproperty(p1, "exists")) {
        int p1dispmp = getentityproperty(p1, "mp");
        if(p1dispmp < 0) p1dispmp = 0;
        p1mp = p1dispmp+"/"+getentityproperty(p1, "maxmp");
        drawstring(222, 10, 5, p1mp);
    }
   
    if(getentityproperty(p2, "exists")) {
        int p2dispmp = getentityproperty(p2, "mp");
        if(p2dispmp < 0) p2dispmp = 0;
        p2mp = p2dispmp+"/"+getentityproperty(p2, "maxmp");
        drawstring(117, 215, 0, p2mp);
    }

    if(getentityproperty(p3, "exists")) {
        int p3dispmp = getentityproperty(p3, "mp");
        if(p3dispmp < 0) p3dispmp = 0;
        p3mp = p3dispmp+"/"+getentityproperty(p3, "maxmp");
        drawstring(193, 215, 0, p3mp);
    }

    if(getentityproperty(p4, "exists")) {
        int p4dispmp = getentityproperty(p4, "mp");
        if(p4dispmp < 0) p4dispmp = 0;
        p4mp = getentityproperty(p4, "mp")+"/"+getentityproperty(p4, "maxmp");
        drawstring(272, 215, 0, p4mp);
    }
 
1 - The MP Display shows MP and MPMAX, i just need to show the MP.

Ah, I see.

Let's see this part:
Code:
    if(getentityproperty(p1, "exists")) {
        int p1dispmp = getentityproperty(p1, "mp");
        if(p1dispmp < 0) p1dispmp = 0;
        p1mp = p1dispmp+"/"+getentityproperty(p1, "maxmp");
        drawstring(222, 10, 5, p1mp);
    }

4th line defines what to display. You can simplify it to this:
Code:
 p1mp = p1dispmp;

That will display Player 1's current MP.
You should do similar for other player's MP.

2 - The MP start with maximum value, i need start it with counter at 0 . ( script to set players MP to 0 at beginning of game ) I didnt find this one.

There are 2 ways to do that,
1. Script in player's spawn, either in onspawnscript or on SPAWN animation.
2. Script in level spawn.

For #1, here's an example:
Code:
anim	spawn
@script
    if(frame==0){
      void self = getlocalvar("self");
      changeentityproperty(self,"mp", 0);
    }
@end_script
...

When this player is spawned, he/she will start with 0 MP.

For #2, here's an example:
Code:
spawn	Empty
@script
void main()
{
    void P1 = getplayerproperty(0, "entity");

    if(P1){
      changeentityproperty(P1,"mp", 0);
    }
}
@end_script
coords	320 460
at	0

That script will make player 1 start with 0 MP when level starts.
It doesn't have to be declared on empty entity, it can be declared on any entity as long it is spawned at 0

Each method has pros and cons so choose which you like best :D
 
@BBloodbane MY FRIEND I ONLY HAVE TO THANK YOU, THANK YOU SO MUCH WORKED PERFECTLY ... the Script in player's spawn to turn hp=0
it was just what I needed.

Thank you  :) :) :)
 
One more question...please... :)

In my mod the player must catch the largest number of hazelnuts within the given time of 60 seconds, but when the time is up the game returns to the main menu.
How do I create a custom score screen when time runs out?
 
You're welcome  8)

As custom score screen, now this could be complex depending on when exactly the screen is shown. If it's shown right after time is over, it could be simpler. But if it's shown on next level, it could be complex.

I hope it's the former since it's simpler as you only need custom timer which aside of showing time, is also displaying score screen. Since it's still in same level, it could directly acquire player's MP and show it.
 
I think it will be simpler case  because my mod has only 1 level, the player must beat his own score always at the same level, and when the time runs out the score screen appears showing how many nuts were collected (MP) by the player.

 
Custom screen is easy to create, however before that you'd need custom timer for this purpose. Default timer will end the game right away after time is over so you can't use that.
This is scripted timer:
Code:
name    	Timer
health	 	100
type    	none
antigravity	100
subject_to_wall	0
offscreenkill	3000
load		CompliSc
script	@script
void main()
{
    void self = getlocalvar("self");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


anim	idle
@script
    if(frame==2){
      void self = getlocalvar("self");
      int Health = getentityproperty(self, "health");

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
@end_script
	delay	1
	offset	1 1
	spawnframe 3 160 200 0 1
	custentity CompliSc
	frame	data/chars/misc/empty.gif
	delay	99
	frame	data/chars/misc/empty.gif
	delay	1
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

anim	spawn
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif

  It displays its health as timer with Health:Time = 10: 1. IOW if you want to set 60 seconds timer, you set 600 health to Timer. You can adjust timer position from drawstring parameters.
  It loses 10 HP each second and when it reaches 0, it will spawn CompliSc, the custom screen.

Of course, you'd need to disable default timer when using this.

This is CompliSc:
Code:
name		CompliSc
type		text
setlayer 	10000
script	@script
void main()
{
    void P1 = getplayerproperty(0, "entity");
    int P1MP = getentityproperty(P1,"mp");

    drawstring(80, 100, 4, "Acorns_=_" + P1MP);
}
@end_script


anim	idle
	delay	200
	offset	160 300
	frame	data/chars/misc/screen.png
	@cmd	jumptobranch "Lanjut" 1
	frame	data/chars/misc/screen.png

This screen shows screen.png covering the screen (depends on its size) while also displaying text: "Acorns = " and player 1's MP right after that text. Just like timer, you can adjust text position from drawstring function above.
Actually you can put the text on screen.png and let script only display's player 1's MP next to the text if you want :).

Give these a try and hope it helps :D
 
Back
Top Bottom