I'd appreciate it if you could help me with code for a summoning skill

kimduck

Member
I’ve added a summoning skill to a character. It consumes mana, but currently there are very few restrictions.


Although the summoned creatures aren’t very powerful, if the player has enough mana, they can keep using the summoning skill while the previous summons are still alive. This allows for infinite summoning, which I want to limit.


So, if there are already a certain number of summoned creatures of type "a" on the current map, I want the skill to either:


  • Only summon up to a fixed number of them as defined in the code,
  • Prevent any further summoning beyond that number, or
  • How to forcibly kill 'a' entities beyond the specified number when the count of summoned 'a' on the current map exceeds the limit.

Is there a way to implement this?I would be grateful if you could help me
 
Last edited:
Solution
How can I actually do that? Where is the summon count stored?

With something like this:
C:
void summonL(void Name, float dx, float dy, float dz, int Limit)
{// Summons entity at relative coords.
// Summon is not allowed after limit is reached. 
  void self = getlocalvar("self");
  int Sums = getentityvar(self, "Summon");

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

  if(Sums < Limit){
    spawn01(Name, dx, dy, dz);
    setentityvar(self, "Summon", Sums+1);
  }
}

This function runs spawn01 to spawn a summon but each time it's done, a counter increments and it is stored in self's entity variable. If the counter hits limit, no more spawn is allowed.
This function is still rough though and it requires other script to...
I’ve added a summoning skill to a character. It consumes mana, but currently there are very few restrictions.


Although the summoned creatures aren’t very powerful, if the player has enough mana, they can keep using the summoning skill while the previous summons are still alive. This allows for infinite summoning, which I want to limit.


So, if there are already a certain number of summoned creatures of type "a" on the current map, I want the skill to either:


  • Only summon up to a fixed number of them as defined in the code,
  • Prevent any further summoning beyond that number, or
  • How to forcibly kill 'a' entities beyond the specified number when the count of summoned 'a' on the current map exceeds the limit.

Is there a way to implement this?I would be grateful if you could help me

How many is the limit? If only one, the engine has this as a native function using summon/unsummon. If the limit is two or more we will need to script it.

DC
 
How many is the limit? If only one, the engine has this as a native function using summon/unsummon. If the limit is two or more we will need to script it.

DC
3
The summon type is set to NPC. I made it so that using the summon skill once summons 3 creatures at a time. Consequently, when one dies and you use the summon skill again, two more are summoned. When two have died and you use the summon skill, one more is summoned. I would appreciate it if you could let me know how to implement this.
 
  • Only summon up to a fixed number of them as defined in the code,
  • Prevent any further summoning beyond that number, or
  • How to forcibly kill 'a' entities beyond the specified number when the count of summoned 'a' on the current map exceeds the limit.

The first two are doable, you could count how many times you have summoned an entity, store the counter and use it to limit number of summons. Though if the summons died (in any way), the summoner needs to update the counter.

I don't understand why you'd need to kill the summons. If you've done the summoning properly as mentioned above, number of summons should be within limit.
 
체를 소환한 횟수
The first two are doable, you could count how many times you have summoned an entity, store the counter and use it to limit number of summons. Though if the summons died (in any way), the summoner needs to update the counter.

I don't understand why you'd need to kill the summons. If you've done the summoning properly as mentioned above, number of summons should be within limit.
The first two are doable, you could count how many times you have summoned an entity, store the counter and use it to limit number of summons.


How can I actually do that? Where is the summon count stored? I would really appreciate it if you could show me. I truly respect you.
 
The first two are doable, you could count how many times you have summoned an entity, store the counter and use it to limit number of summons. Though if the summons died (in any way), the summoner needs to update the counter.

I don't understand why you'd need to kill the summons. If you've done the summoning properly as mentioned above, number of summons should be within limit.
I defined the entity header like this:
name skeleton
type npc
hostile enemy
candamage enemy

And for the summon skill, I used:
@cmd spawn01 "skeleton" 5 0 0

The problem is that I can keep using the summon skill, and every time I use it, the number of summoned skeletons keeps increasing.
I’m not sure where or how to limit the number of summons. Could you please help me?Or maybe summoning isn't supposed to be done using the @cmd spawn01 command?
 
How can I actually do that? Where is the summon count stored?

With something like this:
C:
void summonL(void Name, float dx, float dy, float dz, int Limit)
{// Summons entity at relative coords.
// Summon is not allowed after limit is reached. 
  void self = getlocalvar("self");
  int Sums = getentityvar(self, "Summon");

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

  if(Sums < Limit){
    spawn01(Name, dx, dy, dz);
    setentityvar(self, "Summon", Sums+1);
  }
}

This function runs spawn01 to spawn a summon but each time it's done, a counter increments and it is stored in self's entity variable. If the counter hits limit, no more spawn is allowed.
This function is still rough though and it requires other script to decrement counter if a summon dies.
 
Solution
Back
Top Bottom