Half-Life и Adrenaline Gamer форум
http://aghl.ru/forum/

how i can restart spawn stuff of the map ?
http://aghl.ru/forum/viewtopic.php?f=12&t=2672
Страница 1 из 2

Автор:  abdobiskra [ 09 май 2017, 17:44 ]
Заголовок сообщения:  how i can restart spawn stuff of the map ?

Hi
how i can force to spawn weapons and iteams and function health .. etc ( like when map restart again)

Автор:  Lev [ 10 май 2017, 00:04 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

Respawn a weapon should be easy:
- cycle thru entites in the world, search for a weapon with
Код:
pNewWeapon->pev->effects |= EF_NODRAW;// invisible for now
- set
Код:
pNewWeapon->pev->nextthink = gpGlobals->time + 0;      // weapon respawns almost instantly
It should respawn in this or next frame. Same for batteries, ammo, health.
Rechargers should be handle different. Probably you should manually reset them:
Код:
   m_iJuice = gSkillData.healthchargerCapacity;
   pev->frame = 0;
   pev->nextthink = 0;

Автор:  abdobiskra [ 05 авг 2017, 17:00 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

about weapons i try ex:
Код:
public plugin_init() {

    RegisterHam(Ham_Spawn, "weapon_gauss","fw_WeaponGaussSpawn", 1)
    RegisterHam(Ham_Think, "weapon_gauss","fw_WeaponGaussThink")
}

public fw_WeaponGaussSpawn(ent)
    set_pev(ent,pev_nextthink, get_gametime()+1.0)

public fw_WeaponGaussThink(ent){
    if(!pev_valid(ent))
        return HAM_IGNORED
       
    set_pev(ent, pev_effects, pev(ent, pev_effects) & ~EF_NODRAW)

    return HAM_IGNORED
}
I do not have a clear idea how to remove transparency :pardon:


about func_healthcharge & func_recharge :

Can I just set the time m_iReactivate to 0 ?

Автор:  Lev [ 06 авг 2017, 22:37 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

About weapons I meant that you should iterate thru all entites and search for weapons.

abdobiskra писал(а):
Can I just set the time m_iReactivate to 0 ?
Can be done if you have offset.

Автор:  abdobiskra [ 07 авг 2017, 13:55 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

Lev писал(а):
About weapons I meant that you should iterate thru all entites and search for weapons.
Thx done!^^


Lev писал(а):
Can be done if you have offset.
yes i have it but how i can cheak it ?
Here is the code I explain exactly what I want
 

Автор:  Lev [ 07 авг 2017, 18:34 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

Based on HLSDK source you need to do:
Код:
   m_iJuice = gSkillData.healthchargerCapacity;
   pev->frame = 0;         
   SetThink( &CWallHealth::SUB_DoNothing );
I think you can just replace gSkillData.healthchargerCapacity with a constant value and replace SetThink with
Код:
   pev->nextthink = 0;

Автор:  rtxa [ 05 июн 2018, 10:47 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

Hi Lev, setting pev_nexthink to get_gametime() to ammo and items will make respawn them instantly without problems but with weapons doesn't work. Any ideas?

Автор:  Lev [ 06 июл 2018, 04:06 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

Show the code.

Автор:  rtxa [ 07 июл 2018, 10:59 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

This is the code, with ammo and items it works.
 Code

I found that this will respawn weapons, sometimes... (i know this code is messing with pev_nexthink of all entities, i'm just testing)
Код:
// This works just when you: 
// pick up the gun you want to respawn -> drop it -> respawn it
public SpawnWeapons() {
   for (new i; i < entity_count(); i++) {
      //pev(i, pev_classname, classname, charsmax(classname));
      if (pev_valid(i) != 2)
         continue;
      for (new i; i < sizeof gWeaponEnts; i++) {
         if (pev(i, pev_effects) & EF_NODRAW) {
            set_pev(i, pev_nextthink, get_gametime());
         }
      }
   }
}

Автор:  abdobiskra [ 07 июл 2018, 12:36 ]
Заголовок сообщения:  Re: how i can restart spawn stuff of the map ?

rtxa писал(а):
but with weapons doesn't work. Any ideas?
Some thing like this :
Код:
public plugin_init()
   register_touch(Your_Weapon_List[],"worldspawn","Next_Think")

public Next_Think(weapon)
   set_pev(weapon,pev_nextthink,get_gametime() + 5.0)) return weapon //5sec to respawn

Страница 1 из 2 Часовой пояс: UTC + 5 часов [ Летнее время ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/