Jump to content

Photo

item ->Pickup


  • Please log in to reply
3 replies to this topic

#1 nyrox

nyrox

    Junior

  • Members
  • Gender:Male
  • Location:Québec

Posted 15 August 2021 - 09:15 AM

i want to put 2 attribute of a pickup item in same time 

before i try to do like this

 

item Hcoeur = CreateItemAt(28, 120, 72);

Hcoeur->Pickup = IP_HOLDUP;

Hcoeur->Pickup  = IP_ST_SPECIALITEM;

 

but Link never holdup the item

 

 

if i want the 2 attributes of a item pickup i need to ADD it together like that?

i think is worked

 

item Hcoeur = CreateItemAt(28, 120, 72);
Hcoeur->Pickup = IP_HOLDUP + IP_ST_SPECIALITEM;
 
 
or you have a other methode?
 
 
 


#2 Saffith

Saffith

    IPv7 user

  • ZC Developers
  • Gender:Male

Posted 15 August 2021 - 09:44 AM

The proper thing to use is bitwise OR:

Hcoeur->Pickup = IP_HOLDUP | IP_ST_SPECIALITEM;

But in this case, the result is the same.

Pickup is a bit flag field, meaning each individual bit in the number has a meaning rather than the total number.

IP_HOLDUP  = 0010
IP_ST_ITEM = 0100
IP_DUMMY   = 1000

Given those, 0110 means both IP_HOLDUP and IP_ST_ITEM are set, and 1110 means all three flags are set.


  • ShadowTiger likes this

#3 Emily

Emily

    Scripter / Dev

  • ZC Developers
  • Gender:Female

Posted 15 August 2021 - 03:47 PM

^ The main difference between adding and or'ing is if you have duplicates.

For instance, if you did:

->Pickup = IP_HOLDUP + IP_HOLDUP + IP_ST_SPECIALITEM;

That would not work, as it just.... won't have the right values. But instead,

->Pickup = IP_HOLDUP | IP_HOLDUP | IP_ST_SPECIALITEM;

That would work, as it won't care about the duplicate.

As such, if you have an item that exists, and you want to force it to be holdup, WITHOUT possibly removing another flag it has, you can just do:

it->Pickup |= IP_HOLDUP;

That will make sure holdup is set (even if it already was set, it won't cause any issues); and also won't remove other flags that might already be set.



#4 nyrox

nyrox

    Junior

  • Members
  • Gender:Male
  • Location:Québec

Posted 16 August 2021 - 06:23 PM

wow thanks a lot! i use the | is the best way :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users